summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-04-24 01:57:24 +0200
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:54 +0200
commitf2cadc4ce17cbe80eae3c8fce9d2454bebdf0309 (patch)
tree4261f8780b2b40cb4155a0081543c572cf6a20bb /src
parentandroid: Use navigation bar shade view for settings activity (diff)
downloadyuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar.gz
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar.bz2
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar.lz
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar.xz
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.tar.zst
yuzu-f2cadc4ce17cbe80eae3c8fce9d2454bebdf0309.zip
Diffstat (limited to 'src')
-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 {
DEFAULT -> activity.setTheme(R.style.Theme_Yuzu_Main)
MATERIAL_YOU -> activity.setTheme(R.style.Theme_Yuzu_Main_MaterialYou)
}
- if (preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false)) {
+
+ // Using a specific night mode check because this could apply incorrectly when using the
+ // light app mode, dark system mode, and black backgrounds. Launching the settings activity
+ // will then show light mode colors/navigation bars but with black backgrounds.
+ if (preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false)
+ && isNightMode(activity)
+ ) {
activity.setTheme(R.style.ThemeOverlay_Yuzu_Dark)
}
}
@@ -84,18 +90,24 @@ object ThemeHelper {
activity.window,
activity.window.decorView
)
- val systemReportedThemeMode =
- activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
when (themeMode) {
- AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> when (systemReportedThemeMode) {
- Configuration.UI_MODE_NIGHT_NO -> setLightModeSystemBars(windowController)
- Configuration.UI_MODE_NIGHT_YES -> setDarkModeSystemBars(windowController)
+ AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> when (isNightMode(activity)) {
+ false -> setLightModeSystemBars(windowController)
+ true -> setDarkModeSystemBars(windowController)
}
AppCompatDelegate.MODE_NIGHT_NO -> setLightModeSystemBars(windowController)
AppCompatDelegate.MODE_NIGHT_YES -> setDarkModeSystemBars(windowController)
}
}
+ private fun isNightMode(activity: AppCompatActivity): Boolean {
+ return when (activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
+ Configuration.UI_MODE_NIGHT_NO -> false
+ Configuration.UI_MODE_NIGHT_YES -> true
+ else -> false
+ }
+ }
+
private fun setLightModeSystemBars(windowController: WindowInsetsControllerCompat) {
windowController.isAppearanceLightStatusBars = true
windowController.isAppearanceLightNavigationBars = true