fix: fix splashscreen issues by removing it on Android<12

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2025-03-08 22:12:02 +01:00
parent 4e7998b294
commit aae63df08e
5 changed files with 37 additions and 14 deletions

View File

@ -250,7 +250,7 @@ dependencies {
implementation("androidx.documentfile:documentfile:1.0.1")
implementation("androidx.browser:browser:1.8.0")
implementation("androidx.webkit:webkit:1.12.1")
implementation("androidx.core:core-splashscreen:1.2.0-alpha02")
implementation("androidx.core:core-splashscreen:1.2.0-beta01")
implementation("androidx.palette:palette-ktx:1.0.0")
// Libraries used for legacy View-based UI

View File

@ -69,7 +69,7 @@
android:exported="true"
android:configChanges="orientation|screenSize|colorMode"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.Revolt.Starting">
android:theme="@style/Theme.Revolt">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -10,6 +10,8 @@ import android.view.KeyEvent
import android.view.KeyboardShortcutGroup
import android.view.KeyboardShortcutInfo
import android.view.Menu
import android.view.View
import android.view.ViewTreeObserver
import android.widget.Toast
import androidx.activity.compose.setContent
import androidx.activity.viewModels
@ -38,7 +40,6 @@ import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@ -310,12 +311,6 @@ class MainActivity : AppCompatActivity() {
window.statusBarColor = Color.Transparent.toArgb()
WindowCompat.setDecorFitsSystemWindows(window, false)
installSplashScreen().apply {
setKeepOnScreenCondition {
!viewModel.isReady.value
}
}
RevoltAPI.hydrateFromPersistentCache()
setContent {
@ -334,6 +329,23 @@ class MainActivity : AppCompatActivity() {
viewModel::updateNextDestination
)
}
val content: View = findViewById(android.R.id.content)
content.viewTreeObserver.addOnPreDrawListener(
object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
// Check whether the initial data is ready.
return if (viewModel.isReady.value) {
// The content is ready. Start drawing.
content.viewTreeObserver.removeOnPreDrawListener(this)
true
} else {
// The content isn't ready. Suspend.
false
}
}
}
)
}
override fun onProvideKeyboardShortcuts(
@ -512,7 +524,7 @@ fun AppEntrypoint(
}
)
}
composable("login2/init") { InitScreen(navController, windowSizeClass) }
composable("chat",

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Revolt.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="windowSplashScreenBackground">@color/splashscreen_background</item>
<item name="android:windowSplashScreenBehavior">icon_preferred</item>
<item name="postSplashScreenTheme">@style/Theme.Revolt</item>
</style>
</resources>

View File

@ -7,10 +7,11 @@
<item name="textAppearanceTitleLarge">@style/TextAppearance.Revolt.TitleLarge</item>
</style>
<style name="Theme.Revolt.Starting" parent="Theme.SplashScreen" tools:targetApi="tiramisu">
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="android:windowSplashScreenBackground">@color/splashscreen_background</item>
<item name="android:windowSplashScreenBehavior">icon_preferred</item>
<!-- We temporarily don't use a dedicated splash screen theme due to Samsung specific issues.
This theme is unused. -->
<style name="Theme.Revolt.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="windowSplashScreenBackground">@color/splashscreen_background</item>
<item name="postSplashScreenTheme">@style/Theme.Revolt</item>
</style>