Files
Android/app/src/main/java/protect/card_locker/CatimaComponentActivity.kt
Sylvia van Os 17d3d86127 Fix Compose status and navigation bar theming
Especially affects Android 14 and below, but also slightly 15 and up
2025-12-31 12:43:11 +01:00

42 lines
1.5 KiB
Kotlin

package protect.card_locker
import android.graphics.Color
import android.os.Bundle
import android.os.PersistableBundle
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatDelegate
import protect.card_locker.preferences.Settings
open class CatimaComponentActivity() : ComponentActivity() {
fun fixedEdgeToEdge() {
// Fix edge-to-edge
// When overriding onCreate this does not correctly get applied, which is why it is its own function
// We explicitly need to set the systemBarStyle ourselves, to prevent issues where Android
// for example renders white icons on top of a white statusbar (or black on black)
val settings = Settings(this)
val systemBarStyle = when (settings.theme) {
AppCompatDelegate.MODE_NIGHT_NO ->
SystemBarStyle.light(
scrim = Color.TRANSPARENT,
darkScrim = Color.TRANSPARENT,
)
AppCompatDelegate.MODE_NIGHT_YES ->
SystemBarStyle.dark(
scrim = Color.TRANSPARENT,
)
else ->
SystemBarStyle.auto(
lightScrim = Color.TRANSPARENT,
darkScrim = Color.TRANSPARENT
)
}
enableEdgeToEdge(
statusBarStyle = systemBarStyle,
navigationBarStyle = systemBarStyle
)
}
}