Skip to content

Commit a550bcc

Browse files
Merge pull request #2912 from CatimaLoyalty/fix/2911
Fix Compose status and navigation bar theming
2 parents 2c0efcb + 17d3d86 commit a550bcc

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

app/src/main/java/protect/card_locker/AboutActivity.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package protect.card_locker
22

33
import android.os.Bundle
4-
import androidx.activity.ComponentActivity
54
import androidx.activity.OnBackPressedDispatcher
65
import androidx.activity.compose.setContent
76
import androidx.compose.foundation.layout.Column
@@ -26,12 +25,15 @@ import protect.card_locker.compose.CatimaAboutSection
2625
import protect.card_locker.compose.CatimaTopAppBar
2726
import protect.card_locker.compose.theme.CatimaTheme
2827

29-
class AboutActivity : ComponentActivity() {
28+
class AboutActivity : CatimaComponentActivity() {
3029
private lateinit var content: AboutContent
3130

3231
@OptIn(ExperimentalMaterial3Api::class)
3332
override fun onCreate(savedInstanceState: Bundle?) {
3433
super.onCreate(savedInstanceState)
34+
35+
fixedEdgeToEdge()
36+
3537
content = AboutContent(this)
3638
title = content.pageTitle
3739

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

Comments
 (0)