Simplification

This commit is contained in:
M66B 2019-12-28 16:58:46 +01:00
parent 04f827bbb7
commit 88e5bfbe0a
1 changed files with 10 additions and 17 deletions

View File

@ -84,7 +84,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
if (!this.getClass().equals(ActivityMain.class)) {
String theme = prefs.getString("theme", "light");
int uiMode = getResources().getConfiguration().uiMode;
Log.i("UI mode=" + uiMode);
boolean night = (uiMode & Configuration.UI_MODE_NIGHT_YES) != 0;
Log.i("theme=" + theme + " UI mode=" + uiMode + " night=" + night);
switch (theme) {
case "light":
@ -143,28 +144,20 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
case "system":
case "blue_orange_system":
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeBlueOrangeDark);
else
setTheme(R.style.AppThemeBlueOrangeLight);
setTheme(night
? R.style.AppThemeBlueOrangeDark : R.style.AppThemeBlueOrangeLight);
break;
case "yellow_purple_system":
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeYellowPurpleDark);
else
setTheme(R.style.AppThemeYellowPurpleLight);
setTheme(night
? R.style.AppThemeYellowPurpleDark : R.style.AppThemeYellowPurpleLight);
break;
case "red_green_system":
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeRedGreenDark);
else
setTheme(R.style.AppThemeRedGreenLight);
setTheme(night
? R.style.AppThemeRedGreenDark : R.style.AppThemeRedGreenLight);
break;
case "grey_system":
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeGreySteelBlueDark);
else
setTheme(R.style.AppThemeGreySteelBlueLight);
setTheme(night
? R.style.AppThemeGreySteelBlueDark : R.style.AppThemeGreySteelBlueLight);
break;
}