fixed isDarkMode implementation

This commit is contained in:
Daniel 2018-09-24 18:42:44 +02:00
parent 4f823cb6bd
commit 602efbc930

View file

@ -67,15 +67,21 @@ public class ThemeChooser {
} }
public boolean isDarkTheme(Context context) { public boolean isDarkTheme(Context context) {
if(AppCompatDelegate.MODE_NIGHT_YES == AppCompatDelegate.getDefaultNightMode()) { switch(AppCompatDelegate.getDefaultNightMode()) {
return true; case AppCompatDelegate.MODE_NIGHT_YES:
} return true;
int nightModeFlags = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; case AppCompatDelegate.MODE_NIGHT_AUTO:
if(Configuration.UI_MODE_NIGHT_YES == nightModeFlags) { int nightModeFlags = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
return true; if(Configuration.UI_MODE_NIGHT_YES == nightModeFlags) {
return true;
}
// fallthrough is deliberate
case AppCompatDelegate.MODE_NIGHT_NO:
// fallthrough is deliberate
default:
return false;
} }
return false;
} }
public Integer getSelectedTheme(Context context, boolean forceReloadCache) { public Integer getSelectedTheme(Context context, boolean forceReloadCache) {