mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-27 09:16:08 +00:00
Merge pull request #519 from alexbakker/theme-fixes
Fix two minor issues in themes
This commit is contained in:
commit
3cdf31f940
7 changed files with 59 additions and 65 deletions
23
app/src/main/java/com/beemdevelopment/aegis/ThemeMap.java
Normal file
23
app/src/main/java/com/beemdevelopment/aegis/ThemeMap.java
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package com.beemdevelopment.aegis;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ThemeMap {
|
||||||
|
private ThemeMap() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Map<Theme, Integer> DEFAULT = ImmutableMap.of(
|
||||||
|
Theme.LIGHT, R.style.AppTheme,
|
||||||
|
Theme.DARK, R.style.AppTheme_Dark,
|
||||||
|
Theme.AMOLED, R.style.AppTheme_TrueBlack
|
||||||
|
);
|
||||||
|
|
||||||
|
public static final Map<Theme, Integer> NO_ACTION_BAR = ImmutableMap.of(
|
||||||
|
Theme.LIGHT, R.style.AppTheme_Light_NoActionBar,
|
||||||
|
Theme.DARK, R.style.AppTheme_Dark_NoActionBar,
|
||||||
|
Theme.AMOLED, R.style.AppTheme_TrueBlack_NoActionBar
|
||||||
|
);
|
||||||
|
}
|
|
@ -12,8 +12,6 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.AttrRes;
|
import androidx.annotation.AttrRes;
|
||||||
import androidx.annotation.ColorInt;
|
|
||||||
import androidx.annotation.ColorRes;
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.core.view.LayoutInflaterCompat;
|
import androidx.core.view.LayoutInflaterCompat;
|
||||||
|
|
||||||
|
@ -80,7 +78,7 @@ public class AboutActivity extends AegisActivity {
|
||||||
|
|
||||||
View btnChangelog = findViewById(R.id.btn_changelog);
|
View btnChangelog = findViewById(R.id.btn_changelog);
|
||||||
btnChangelog.setOnClickListener(v -> {
|
btnChangelog.setOnClickListener(v -> {
|
||||||
ChangelogDialog.create().setTheme(getCurrentTheme()).show(getSupportFragmentManager(), "CHANGELOG_DIALOG");
|
ChangelogDialog.create().setTheme(getConfiguredTheme()).show(getSupportFragmentManager(), "CHANGELOG_DIALOG");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +116,7 @@ public class AboutActivity extends AegisActivity {
|
||||||
|
|
||||||
private void showLicenseDialog() {
|
private void showLicenseDialog() {
|
||||||
String stylesheet = getString(R.string.custom_notices_format_style);
|
String stylesheet = getString(R.string.custom_notices_format_style);
|
||||||
int backgroundColorResource = getCurrentTheme() == Theme.AMOLED ? R.attr.cardBackgroundFocused : R.attr.cardBackground;
|
int backgroundColorResource = getConfiguredTheme() == Theme.AMOLED ? R.attr.cardBackgroundFocused : R.attr.cardBackground;
|
||||||
String backgroundColor = getThemeColorAsHex(backgroundColorResource);
|
String backgroundColor = getThemeColorAsHex(backgroundColorResource);
|
||||||
String textColor = getThemeColorAsHex(R.attr.primaryText);
|
String textColor = getThemeColorAsHex(R.attr.primaryText);
|
||||||
String licenseColor = getThemeColorAsHex(R.attr.cardBackgroundFocused);
|
String licenseColor = getThemeColorAsHex(R.attr.cardBackgroundFocused);
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.beemdevelopment.aegis.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
@ -27,7 +26,7 @@ import com.beemdevelopment.aegis.AegisApplication;
|
||||||
import com.beemdevelopment.aegis.CancelAction;
|
import com.beemdevelopment.aegis.CancelAction;
|
||||||
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.ThemeMap;
|
||||||
import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
|
import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
|
||||||
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
|
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
|
||||||
import com.beemdevelopment.aegis.crypto.MasterKey;
|
import com.beemdevelopment.aegis.crypto.MasterKey;
|
||||||
|
@ -166,31 +165,8 @@ public class AuthActivity extends AegisActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setPreferredTheme(Theme theme) {
|
protected void onSetTheme() {
|
||||||
if (theme == Theme.SYSTEM || theme == Theme.SYSTEM_AMOLED) {
|
setTheme(ThemeMap.NO_ACTION_BAR);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (theme) {
|
|
||||||
case LIGHT:
|
|
||||||
setTheme(R.style.AppTheme_Light_NoActionBar);
|
|
||||||
break;
|
|
||||||
case DARK:
|
|
||||||
setTheme(R.style.AppTheme_Dark_NoActionBar);
|
|
||||||
break;
|
|
||||||
case AMOLED:
|
|
||||||
setTheme(R.style.AppTheme_TrueBlack_NoActionBar);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectPassword() {
|
private void selectPassword() {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import androidx.camera.view.PreviewView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
import com.beemdevelopment.aegis.Theme;
|
|
||||||
import com.beemdevelopment.aegis.helpers.QrCodeAnalyzer;
|
import com.beemdevelopment.aegis.helpers.QrCodeAnalyzer;
|
||||||
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
||||||
import com.beemdevelopment.aegis.otp.GoogleAuthInfoException;
|
import com.beemdevelopment.aegis.otp.GoogleAuthInfoException;
|
||||||
|
@ -77,7 +76,7 @@ public class ScannerActivity extends AegisActivity implements QrCodeAnalyzer.Lis
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setPreferredTheme(Theme theme) {
|
protected void onSetTheme() {
|
||||||
setTheme(R.style.AppTheme_Fullscreen);
|
setTheme(R.style.AppTheme_Fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
android:fontFamily="sans-serif-light"
|
android:fontFamily="sans-serif-light"
|
||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
android:text="@string/authentication_multiline"
|
android:text="@string/authentication_multiline"
|
||||||
android:textColor="?attr/authText"
|
android:textStyle="bold"
|
||||||
android:textFontWeight="500"
|
android:textSize="46sp"
|
||||||
android:textSize="46sp" />
|
android:textColor="?attr/authText" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -54,10 +54,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/password"
|
android:hint="@string/password"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword" />
|
||||||
android:textColor="?attr/primaryText"
|
|
||||||
android:textColorHint="?attr/authText"
|
|
||||||
app:backgroundTint="?attr/authText" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -85,7 +82,6 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:minWidth="125dp"
|
android:minWidth="125dp"
|
||||||
android:text="@string/auth_use_biometrics"
|
android:text="@string/auth_use_biometrics"
|
||||||
android:textColor="?attr/authText"
|
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -111,7 +107,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
|
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.Dark.NoActionBar" parent="AppTheme">
|
<style name="AppTheme.Dark.NoActionBar" parent="AppTheme.Dark">
|
||||||
<item name="android:statusBarColor">@color/background_dark_statusbar</item>
|
<item name="android:statusBarColor">@color/background_dark_statusbar</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
|
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.TrueBlack.NoActionBar" parent="AppTheme">
|
<style name="AppTheme.TrueBlack.NoActionBar" parent="AppTheme.TrueBlack">
|
||||||
<item name="android:statusBarColor">@color/background_true_dark</item>
|
<item name="android:statusBarColor">@color/background_true_dark</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
|
|
Loading…
Add table
Reference in a new issue