@ -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