1+ package protect.card_locker
2+
3+ import android.graphics.Color
4+ import android.os.Bundle
5+ import android.os.PersistableBundle
6+ import androidx.activity.ComponentActivity
7+ import androidx.activity.SystemBarStyle
8+ import androidx.activity.enableEdgeToEdge
9+ import androidx.appcompat.app.AppCompatDelegate
10+ import protect.card_locker.preferences.Settings
11+
12+ open class CatimaComponentActivity () : ComponentActivity() {
13+ fun fixedEdgeToEdge () {
14+ // Fix edge-to-edge
15+ // When overriding onCreate this does not correctly get applied, which is why it is its own function
16+
17+ // We explicitly need to set the systemBarStyle ourselves, to prevent issues where Android
18+ // for example renders white icons on top of a white statusbar (or black on black)
19+ val settings = Settings (this )
20+ val systemBarStyle = when (settings.theme) {
21+ AppCompatDelegate .MODE_NIGHT_NO ->
22+ SystemBarStyle .light(
23+ scrim = Color .TRANSPARENT ,
24+ darkScrim = Color .TRANSPARENT ,
25+ )
26+ AppCompatDelegate .MODE_NIGHT_YES ->
27+ SystemBarStyle .dark(
28+ scrim = Color .TRANSPARENT ,
29+ )
30+ else ->
31+ SystemBarStyle .auto(
32+ lightScrim = Color .TRANSPARENT ,
33+ darkScrim = Color .TRANSPARENT
34+ )
35+ }
36+
37+ enableEdgeToEdge(
38+ statusBarStyle = systemBarStyle,
39+ navigationBarStyle = systemBarStyle
40+ )
41+ }
42+ }
0 commit comments