From 1a22af34711be86061a57abd5140262f27568b5f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 5 Nov 2026 12:27:37 +0100 Subject: refactor(app): take the app's own code off AppCompat Activities extend FragmentActivity, window themes derive from the platform's Material theme and night mode uses UiModeManager. APSTheme colors the system bars, which DynamicColors did through the window theme. AppCompat stays in the APK through zxing. Co-Authored-By: Claude Sonnet 5.5 --- .../kotlin/app/passwordstore/ui/compose/theme/Theme.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'ui/compose/src') diff --git a/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt b/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt index a268c4b4..957bf543 100644 --- a/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt +++ b/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt @@ -6,6 +6,8 @@ package app.passwordstore.ui.compose.theme import android.app.Activity +import android.graphics.Color as AndroidColor +import android.view.Window import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme @@ -14,6 +16,7 @@ import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat @@ -97,8 +100,19 @@ public fun APSTheme( if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window - WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme + val bars = WindowCompat.getInsetsController(window, view) + bars.isAppearanceLightStatusBars = !darkTheme + bars.isAppearanceLightNavigationBars = !darkTheme + paintBars(window, colorScheme.background.toArgb()) } } MaterialTheme(colorScheme = colorScheme, typography = AppTypography, content = content) } + +/** Colors the system bars, except in windows that keep them see-through (autofill decryption). */ +@Suppress("DEPRECATION") // Deprecated with edge-to-edge, which targetSdk 34 does not force. +private fun paintBars(window: Window, color: Int) { + if (window.statusBarColor == AndroidColor.TRANSPARENT) return + window.statusBarColor = color + window.navigationBarColor = color +} -- cgit v1.2.3