mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-15 06:22:49 +00:00
automatically adapt to system theme
added two new theme options: SYSTEM: dynamically switches between light and dark SYSTEM_AMOLED: dynamically switches between light and amoled reversed workaround for amoled themed preferences launch screen now always follows the system theme
This commit is contained in:
parent
7ce74d378f
commit
f37d70b58e
8 changed files with 27 additions and 24 deletions
|
@ -90,7 +90,7 @@ public class Preferences {
|
|||
}
|
||||
|
||||
public Theme getCurrentTheme() {
|
||||
return Theme.fromInteger(_prefs.getInt("pref_current_theme", 0));
|
||||
return Theme.fromInteger(_prefs.getInt("pref_current_theme", Theme.SYSTEM.ordinal()));
|
||||
}
|
||||
|
||||
public void setCurrentTheme(Theme theme) {
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.beemdevelopment.aegis;
|
|||
public enum Theme {
|
||||
LIGHT,
|
||||
DARK,
|
||||
AMOLED;
|
||||
AMOLED,
|
||||
SYSTEM,
|
||||
SYSTEM_AMOLED;
|
||||
|
||||
private static Theme[] _values;
|
||||
|
||||
|
|
|
@ -89,6 +89,19 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|||
}
|
||||
|
||||
protected void setPreferredTheme(Theme theme) {
|
||||
if (theme == Theme.SYSTEM || theme == Theme.SYSTEM_AMOLED) {
|
||||
// set the theme based on the system theme
|
||||
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
switch (currentNightMode) {
|
||||
case Configuration.UI_MODE_NIGHT_NO:
|
||||
theme = Theme.LIGHT;
|
||||
break;
|
||||
case Configuration.UI_MODE_NIGHT_YES:
|
||||
theme = theme == Theme.SYSTEM_AMOLED ? Theme.AMOLED : Theme.DARK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_currentTheme = theme;
|
||||
|
||||
switch (theme) {
|
||||
|
|
|
@ -39,21 +39,4 @@ public class PreferencesActivity extends AegisActivity {
|
|||
outState.putParcelable("result", _fragment.getResult());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPreferredTheme(Theme theme) {
|
||||
switch (theme) {
|
||||
case LIGHT:
|
||||
setTheme(R.style.AppTheme);
|
||||
break;
|
||||
|
||||
case DARK:
|
||||
setTheme(R.style.AppTheme_Dark);
|
||||
break;
|
||||
|
||||
case AMOLED:
|
||||
setTheme(R.style.AppTheme_TrueBlack_Preferences);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue