aboutsummaryrefslogtreecommitdiffstats
path: root/ui/compose/src/main
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-05 12:27:37 +0100
committerDanilo M. <danix@danix.xyz>2026-11-05 12:36:08 +0100
commit1a22af34711be86061a57abd5140262f27568b5f (patch)
tree30add05371c418c19b797ff9aca46fc20a57e6f2 /ui/compose/src/main
parent68714bf78feb5a5a59354da624f2d69d6705e8ab (diff)
downloadHardenedPass-1a22af34711be86061a57abd5140262f27568b5f.tar.gz
HardenedPass-1a22af34711be86061a57abd5140262f27568b5f.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'ui/compose/src/main')
-rw-r--r--ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt16
1 files changed, 15 insertions, 1 deletions
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
+}