Fix light theme sometimes being wrong when switching themes

This commit is contained in:
Jays2Kings 2021-04-10 15:04:59 -04:00
parent b158bc6222
commit 3b6afd2cb6

View File

@ -236,7 +236,11 @@ fun Activity.setThemeAndNight(preferences: PreferencesHelper) {
fun Context.getPrefTheme(preferences: PreferencesHelper): ThemeUtil.Themes { fun Context.getPrefTheme(preferences: PreferencesHelper): ThemeUtil.Themes {
// Using a try catch in case I start to remove themes // Using a try catch in case I start to remove themes
return try { return try {
(if (isInNightMode() || preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) preferences.darkTheme() else preferences.lightTheme()).get() (
if ((applicationContext.isInNightMode() || preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) &&
preferences.nightMode().get() != AppCompatDelegate.MODE_NIGHT_NO
) preferences.darkTheme() else preferences.lightTheme()
).get()
} catch (e: Exception) { } catch (e: Exception) {
preferences.lightTheme().set(ThemeUtil.Themes.PURE_WHITE) preferences.lightTheme().set(ThemeUtil.Themes.PURE_WHITE)
preferences.darkTheme().set(ThemeUtil.Themes.DARK) preferences.darkTheme().set(ThemeUtil.Themes.DARK)