Refactoring

This commit is contained in:
M66B 2019-08-16 12:14:20 +02:00
parent 1fbf422d66
commit 5229f4df3f
1 changed files with 7 additions and 6 deletions

View File

@ -70,17 +70,18 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!this.getClass().equals(ActivityMain.class)) {
String theme = prefs.getString("theme", null);
if ("system".equals(theme)) {
String theme = prefs.getString("theme", "light");
if ("dark".equals(theme))
setTheme(R.style.AppThemeDark);
else if ("black".equals(theme))
setTheme(R.style.AppThemeBlack);
else if ("system".equals(theme)) {
int uiMode = getResources().getConfiguration().uiMode;
Log.i("UI mode=" + uiMode);
if ((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
setTheme(R.style.AppThemeBlack);
}
if ("dark".equals(theme))
setTheme(R.style.AppThemeDark);
else if ("black".equals(theme))
setTheme(R.style.AppThemeBlack);
}
prefs.registerOnSharedPreferenceChangeListener(this);