fix: fix splashscreen issues by removing it on Android<12
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
4e7998b294
commit
aae63df08e
|
|
@ -250,7 +250,7 @@ dependencies {
|
||||||
implementation("androidx.documentfile:documentfile:1.0.1")
|
implementation("androidx.documentfile:documentfile:1.0.1")
|
||||||
implementation("androidx.browser:browser:1.8.0")
|
implementation("androidx.browser:browser:1.8.0")
|
||||||
implementation("androidx.webkit:webkit:1.12.1")
|
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")
|
implementation("androidx.palette:palette-ktx:1.0.0")
|
||||||
|
|
||||||
// Libraries used for legacy View-based UI
|
// Libraries used for legacy View-based UI
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:configChanges="orientation|screenSize|colorMode"
|
android:configChanges="orientation|screenSize|colorMode"
|
||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:theme="@style/Theme.Revolt.Starting">
|
android:theme="@style/Theme.Revolt">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import android.view.KeyEvent
|
||||||
import android.view.KeyboardShortcutGroup
|
import android.view.KeyboardShortcutGroup
|
||||||
import android.view.KeyboardShortcutInfo
|
import android.view.KeyboardShortcutInfo
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewTreeObserver
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
|
@ -38,7 +40,6 @@ import androidx.compose.ui.graphics.toArgb
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.IntOffset
|
import androidx.compose.ui.unit.IntOffset
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
|
@ -310,12 +311,6 @@ class MainActivity : AppCompatActivity() {
|
||||||
window.statusBarColor = Color.Transparent.toArgb()
|
window.statusBarColor = Color.Transparent.toArgb()
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
|
||||||
installSplashScreen().apply {
|
|
||||||
setKeepOnScreenCondition {
|
|
||||||
!viewModel.isReady.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RevoltAPI.hydrateFromPersistentCache()
|
RevoltAPI.hydrateFromPersistentCache()
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
|
|
@ -334,6 +329,23 @@ class MainActivity : AppCompatActivity() {
|
||||||
viewModel::updateNextDestination
|
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(
|
override fun onProvideKeyboardShortcuts(
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -7,10 +7,11 @@
|
||||||
<item name="textAppearanceTitleLarge">@style/TextAppearance.Revolt.TitleLarge</item>
|
<item name="textAppearanceTitleLarge">@style/TextAppearance.Revolt.TitleLarge</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Revolt.Starting" parent="Theme.SplashScreen" tools:targetApi="tiramisu">
|
<!-- We temporarily don't use a dedicated splash screen theme due to Samsung specific issues.
|
||||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
|
This theme is unused. -->
|
||||||
<item name="android:windowSplashScreenBackground">@color/splashscreen_background</item>
|
<style name="Theme.Revolt.Starting" parent="Theme.SplashScreen">
|
||||||
<item name="android:windowSplashScreenBehavior">icon_preferred</item>
|
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
|
||||||
|
<item name="windowSplashScreenBackground">@color/splashscreen_background</item>
|
||||||
<item name="postSplashScreenTheme">@style/Theme.Revolt</item>
|
<item name="postSplashScreenTheme">@style/Theme.Revolt</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue