diff options
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt | 24 |
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 |