|
@@ -16,8 +16,10 @@ import androidx.compose.foundation.layout.WindowInsets
|
|
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
|
|
import androidx.compose.foundation.layout.statusBars
|
|
|
import androidx.compose.material3.AlertDialog
|
|
|
+import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.material3.TextButton
|
|
|
+import androidx.compose.material3.surfaceColorAtElevation
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.getValue
|
|
@@ -28,12 +30,11 @@ import androidx.compose.runtime.setValue
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
import androidx.core.animation.doOnEnd
|
|
|
import androidx.core.splashscreen.SplashScreen
|
|
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
|
|
-import androidx.core.view.ViewCompat
|
|
|
import androidx.core.view.WindowCompat
|
|
|
-import androidx.core.view.WindowInsetsCompat
|
|
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
|
|
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
@@ -68,11 +69,11 @@ import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
|
|
import eu.kanade.tachiyomi.ui.more.NewUpdateScreen
|
|
|
import eu.kanade.tachiyomi.util.Constants
|
|
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
|
|
+import eu.kanade.tachiyomi.util.system.isNavigationBarNeedsScrim
|
|
|
import eu.kanade.tachiyomi.util.system.logcat
|
|
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
|
|
import eu.kanade.tachiyomi.util.system.toast
|
|
|
import eu.kanade.tachiyomi.util.view.setComposeContent
|
|
|
-import eu.kanade.tachiyomi.util.view.setNavigationBarTransparentCompat
|
|
|
import kotlinx.coroutines.cancel
|
|
|
import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.flow.drop
|
|
@@ -84,6 +85,7 @@ import uy.kohesive.injekt.Injekt
|
|
|
import uy.kohesive.injekt.api.get
|
|
|
import uy.kohesive.injekt.injectLazy
|
|
|
import kotlin.time.Duration.Companion.seconds
|
|
|
+import androidx.compose.ui.graphics.Color.Companion as ComposeColor
|
|
|
|
|
|
class MainActivity : BaseActivity() {
|
|
|
|
|
@@ -150,13 +152,33 @@ class MainActivity : BaseActivity() {
|
|
|
downloadedOnlyMode = download,
|
|
|
incognitoMode = incognito,
|
|
|
)
|
|
|
+
|
|
|
+ // Set statusbar color
|
|
|
val systemUiController = rememberSystemUiController()
|
|
|
+ val isSystemInDarkTheme = isSystemInDarkTheme()
|
|
|
val active = incognito || download
|
|
|
- val useDarkIcons = if (isSystemInDarkTheme()) active else !active
|
|
|
- LaunchedEffect(systemUiController, useDarkIcons) {
|
|
|
+ val useDarkStatusBarIcons = if (isSystemInDarkTheme) active else !active
|
|
|
+ LaunchedEffect(systemUiController, useDarkStatusBarIcons) {
|
|
|
systemUiController.setStatusBarColor(
|
|
|
- color = androidx.compose.ui.graphics.Color.Transparent,
|
|
|
- darkIcons = useDarkIcons,
|
|
|
+ color = ComposeColor.Transparent,
|
|
|
+ darkIcons = useDarkStatusBarIcons,
|
|
|
+ transformColorForLightContent = { ComposeColor.Black },
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ // Set navigation bar color
|
|
|
+ val context = LocalContext.current
|
|
|
+ val navbarScrimColor = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp)
|
|
|
+ LaunchedEffect(systemUiController, isSystemInDarkTheme, navbarScrimColor) {
|
|
|
+ systemUiController.setNavigationBarColor(
|
|
|
+ color = if (context.isNavigationBarNeedsScrim()) {
|
|
|
+ navbarScrimColor.copy(alpha = 0.7f)
|
|
|
+ } else {
|
|
|
+ ComposeColor.Transparent
|
|
|
+ },
|
|
|
+ darkIcons = !isSystemInDarkTheme,
|
|
|
+ navigationBarContrastEnforced = false,
|
|
|
+ transformColorForLightContent = { ComposeColor.Black },
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -296,20 +318,7 @@ class MainActivity : BaseActivity() {
|
|
|
*/
|
|
|
private fun setSplashScreenExitAnimation(splashScreen: SplashScreen?) {
|
|
|
val root = findViewById<View>(android.R.id.content)
|
|
|
- val setNavbarScrim = {
|
|
|
- // Make sure navigation bar is on bottom before we modify it
|
|
|
- ViewCompat.setOnApplyWindowInsetsListener(root) { _, insets ->
|
|
|
- if (insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom > 0) {
|
|
|
- window.setNavigationBarTransparentCompat(this@MainActivity, 3.dpToPx.toFloat())
|
|
|
- }
|
|
|
- insets
|
|
|
- }
|
|
|
- ViewCompat.requestApplyInsets(root)
|
|
|
- }
|
|
|
-
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S && splashScreen != null) {
|
|
|
- val oldStatusColor = window.statusBarColor
|
|
|
- val oldNavigationColor = window.navigationBarColor
|
|
|
window.statusBarColor = Color.TRANSPARENT
|
|
|
window.navigationBarColor = Color.TRANSPARENT
|
|
|
|
|
@@ -335,17 +344,12 @@ class MainActivity : BaseActivity() {
|
|
|
}
|
|
|
doOnEnd {
|
|
|
splashProvider.remove()
|
|
|
- window.statusBarColor = oldStatusColor
|
|
|
- window.navigationBarColor = oldNavigationColor
|
|
|
- setNavbarScrim()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
activityAnim.start()
|
|
|
splashAnim.start()
|
|
|
}
|
|
|
- } else {
|
|
|
- setNavbarScrim()
|
|
|
}
|
|
|
}
|
|
|
|