|
|
@ -13,14 +13,16 @@ import com.beemdevelopment.aegis.AegisApplication;
|
|
|
|
import com.beemdevelopment.aegis.Preferences;
|
|
|
|
import com.beemdevelopment.aegis.Preferences;
|
|
|
|
import com.beemdevelopment.aegis.R;
|
|
|
|
import com.beemdevelopment.aegis.R;
|
|
|
|
import com.beemdevelopment.aegis.Theme;
|
|
|
|
import com.beemdevelopment.aegis.Theme;
|
|
|
|
|
|
|
|
import com.beemdevelopment.aegis.ThemeMap;
|
|
|
|
import com.beemdevelopment.aegis.vault.VaultManagerException;
|
|
|
|
import com.beemdevelopment.aegis.vault.VaultManagerException;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
public abstract class AegisActivity extends AppCompatActivity implements AegisApplication.LockListener {
|
|
|
|
public abstract class AegisActivity extends AppCompatActivity implements AegisApplication.LockListener {
|
|
|
|
private boolean _resumed;
|
|
|
|
private boolean _resumed;
|
|
|
|
private AegisApplication _app;
|
|
|
|
private AegisApplication _app;
|
|
|
|
private Theme _currentTheme;
|
|
|
|
private Theme _configuredTheme;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@ -28,7 +30,7 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|
|
|
|
|
|
|
|
|
|
|
// set the theme and locale before creating the activity
|
|
|
|
// set the theme and locale before creating the activity
|
|
|
|
Preferences prefs = getPreferences();
|
|
|
|
Preferences prefs = getPreferences();
|
|
|
|
setPreferredTheme(prefs.getCurrentTheme());
|
|
|
|
onSetTheme();
|
|
|
|
setLocale(prefs.getLocale());
|
|
|
|
setLocale(prefs.getLocale());
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
|
@ -84,9 +86,26 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|
|
|
return _app.getPreferences();
|
|
|
|
return _app.getPreferences();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void setPreferredTheme(Theme theme) {
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Called when the activity is expected to set its theme.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected void onSetTheme() {
|
|
|
|
|
|
|
|
setTheme(ThemeMap.DEFAULT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Sets the theme of the activity. The actual style that is set is picked from the
|
|
|
|
|
|
|
|
* given map, based on the theme configured by the user.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected void setTheme(Map<Theme, Integer> themeMap) {
|
|
|
|
|
|
|
|
int theme = themeMap.get(getConfiguredTheme());
|
|
|
|
|
|
|
|
setTheme(theme);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Theme getConfiguredTheme() {
|
|
|
|
|
|
|
|
Theme theme = getPreferences().getCurrentTheme();
|
|
|
|
|
|
|
|
|
|
|
|
if (theme == Theme.SYSTEM || theme == Theme.SYSTEM_AMOLED) {
|
|
|
|
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;
|
|
|
|
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
|
|
|
switch (currentNightMode) {
|
|
|
|
switch (currentNightMode) {
|
|
|
|
case Configuration.UI_MODE_NIGHT_NO:
|
|
|
|
case Configuration.UI_MODE_NIGHT_NO:
|
|
|
@ -98,19 +117,7 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_currentTheme = theme;
|
|
|
|
return 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);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void setLocale(Locale locale) {
|
|
|
|
protected void setLocale(Locale locale) {
|
|
|
@ -146,8 +153,4 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|
|
|
private boolean isOrphan() {
|
|
|
|
private boolean isOrphan() {
|
|
|
|
return !(this instanceof MainActivity) && !(this instanceof AuthActivity) && _app.isVaultLocked();
|
|
|
|
return !(this instanceof MainActivity) && !(this instanceof AuthActivity) && _app.isVaultLocked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected Theme getCurrentTheme() {
|
|
|
|
|
|
|
|
return _currentTheme;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|