summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorGravatar Charles Lombardo2023-04-23 19:57:24 -0400
committerGravatar bunnei2023-06-03 00:05:54 -0700
commitf2cadc4ce17cbe80eae3c8fce9d2454bebdf0309 (patch)
tree4261f8780b2b40cb4155a0081543c572cf6a20bb /src/android
parentandroid: Use navigation bar shade view for settings activity (diff)
downloadyuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar.gz
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar.xz
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.zip
android: Fix black backgrounds bug
Start using a specific night mode check because black backgrounds could apply incorrectly when using the light app mode, dark system mode, and black backgrounds. Launching the settings activity will show light mode colors/navigation bars but with black backgrounds.
Diffstat (limited to 'src/android')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt
index 7c8f1d80b..1295b4257 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt
@@ -33,7 +33,13 @@ object ThemeHelper {
33 DEFAULT -> activity.setTheme(R.style.Theme_Yuzu_Main) 33 DEFAULT -> activity.setTheme(R.style.Theme_Yuzu_Main)
34 MATERIAL_YOU -> activity.setTheme(R.style.Theme_Yuzu_Main_MaterialYou) 34 MATERIAL_YOU -> activity.setTheme(R.style.Theme_Yuzu_Main_MaterialYou)
35 } 35 }
36 if (preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false)) { 36
37 // Using a specific night mode check because this could apply incorrectly when using the
38 // light app mode, dark system mode, and black backgrounds. Launching the settings activity
39 // will then show light mode colors/navigation bars but with black backgrounds.
40 if (preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false)
41 && isNightMode(activity)
42 ) {
37 activity.setTheme(R.style.ThemeOverlay_Yuzu_Dark) 43 activity.setTheme(R.style.ThemeOverlay_Yuzu_Dark)
38 } 44 }
39 } 45 }
@@ -84,18 +90,24 @@ object ThemeHelper {
84 activity.window, 90 activity.window,
85 activity.window.decorView 91 activity.window.decorView
86 ) 92 )
87 val systemReportedThemeMode =
88 activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
89 when (themeMode) { 93 when (themeMode) {
90 AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> when (systemReportedThemeMode) { 94 AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> when (isNightMode(activity)) {
91 Configuration.UI_MODE_NIGHT_NO -> setLightModeSystemBars(windowController) 95 false -> setLightModeSystemBars(windowController)
92 Configuration.UI_MODE_NIGHT_YES -> setDarkModeSystemBars(windowController) 96 true -> setDarkModeSystemBars(windowController)
93 } 97 }
94 AppCompatDelegate.MODE_NIGHT_NO -> setLightModeSystemBars(windowController) 98 AppCompatDelegate.MODE_NIGHT_NO -> setLightModeSystemBars(windowController)
95 AppCompatDelegate.MODE_NIGHT_YES -> setDarkModeSystemBars(windowController) 99 AppCompatDelegate.MODE_NIGHT_YES -> setDarkModeSystemBars(windowController)
96 } 100 }
97 } 101 }
98 102
103 private fun isNightMode(activity: AppCompatActivity): Boolean {
104 return when (activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
105 Configuration.UI_MODE_NIGHT_NO -> false
106 Configuration.UI_MODE_NIGHT_YES -> true
107 else -> false
108 }
109 }
110
99 private fun setLightModeSystemBars(windowController: WindowInsetsControllerCompat) { 111 private fun setLightModeSystemBars(windowController: WindowInsetsControllerCompat) {
100 windowController.isAppearanceLightStatusBars = true 112 windowController.isAppearanceLightStatusBars = true
101 windowController.isAppearanceLightNavigationBars = true 113 windowController.isAppearanceLightNavigationBars = true