Fix some warnings
This commit is contained in:
parent
d32d385a25
commit
cfcfca5a08
2 changed files with 89 additions and 126 deletions
|
@ -24,7 +24,6 @@ package org.shadowice.flocke.andotp.Activities;
|
||||||
|
|
||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -37,6 +36,8 @@ import android.preference.Preference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import android.provider.DocumentsContract;
|
import android.provider.DocumentsContract;
|
||||||
|
@ -112,7 +113,7 @@ public class SettingsActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
|
||||||
outState.putBoolean(Constants.EXTRA_SETTINGS_ENCRYPTION_CHANGED, encryptionChanged);
|
outState.putBoolean(Constants.EXTRA_SETTINGS_ENCRYPTION_CHANGED, encryptionChanged);
|
||||||
|
@ -282,9 +283,9 @@ public class SettingsActivity extends BaseActivity
|
||||||
getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
|
getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
|
||||||
settings.setBackupLocation(treeUri);
|
settings.setBackupLocation(treeUri);
|
||||||
}
|
}
|
||||||
} else if (fragment.pgpSigningKey.handleOnActivityResult(requestCode, resultCode, data)) {
|
} else {
|
||||||
// handled by OpenPgpKeyPreference
|
// Handled in OpenPgpKeyPreference
|
||||||
return;
|
fragment.pgpSigningKey.handleOnActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,16 +298,13 @@ public class SettingsActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SettingsFragment extends PreferenceFragment {
|
public static class SettingsFragment extends PreferenceFragment {
|
||||||
private PreferenceCategory catSecurity;
|
|
||||||
PreferenceCategory catUI;
|
PreferenceCategory catUI;
|
||||||
|
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
private ListPreference encryption;
|
private ListPreference encryption;
|
||||||
private Preference backupLocation;
|
|
||||||
private ListPreference useAutoBackup;
|
private ListPreference useAutoBackup;
|
||||||
private CheckBoxPreference useAndroidSync;
|
private CheckBoxPreference useAndroidSync;
|
||||||
|
|
||||||
private OpenPgpAppPreference pgpProvider;
|
|
||||||
private EditTextPreference pgpEncryptionKey;
|
private EditTextPreference pgpEncryptionKey;
|
||||||
private OpenPgpKeyPreference pgpSigningKey;
|
private OpenPgpKeyPreference pgpSigningKey;
|
||||||
ListPreference themeMode;
|
ListPreference themeMode;
|
||||||
|
@ -316,19 +314,13 @@ public class SettingsActivity extends BaseActivity
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setTitle(R.string.settings_dialog_title_warning)
|
builder.setTitle(R.string.settings_dialog_title_warning)
|
||||||
.setMessage(R.string.settings_dialog_msg_encryption_change)
|
.setMessage(R.string.settings_dialog_msg_encryption_change)
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
|
||||||
@Override
|
if (encryptionType == EncryptionType.PASSWORD)
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
((SettingsActivity) getActivity()).tryEncryptionChangeWithAuth(encryptionType);
|
||||||
if (encryptionType == EncryptionType.PASSWORD)
|
else if (encryptionType == EncryptionType.KEYSTORE)
|
||||||
((SettingsActivity) getActivity()).tryEncryptionChangeWithAuth(encryptionType);
|
((SettingsActivity) getActivity()).tryEncryptionChange(encryptionType, null);
|
||||||
else if (encryptionType == EncryptionType.KEYSTORE)
|
|
||||||
((SettingsActivity) getActivity()).tryEncryptionChange(encryptionType, null);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> {
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
|
@ -359,12 +351,7 @@ public class SettingsActivity extends BaseActivity
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
|
||||||
CredentialsPreference credentialsPreference = (CredentialsPreference) findPreference(getString(R.string.settings_key_auth));
|
CredentialsPreference credentialsPreference = (CredentialsPreference) findPreference(getString(R.string.settings_key_auth));
|
||||||
credentialsPreference.setEncryptionChangeCallback(new CredentialsPreference.EncryptionChangeCallback() {
|
credentialsPreference.setEncryptionChangeCallback(newKey -> ((SettingsActivity) getActivity()).tryEncryptionChange(settings.getEncryption(), newKey));
|
||||||
@Override
|
|
||||||
public boolean testEncryptionChange(byte[] newKey) {
|
|
||||||
return ((SettingsActivity) getActivity()).tryEncryptionChange(settings.getEncryption(), newKey);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
CheckBoxPreference blockAutofill = (CheckBoxPreference) findPreference(getString(R.string.settings_key_block_autofill));
|
CheckBoxPreference blockAutofill = (CheckBoxPreference) findPreference(getString(R.string.settings_key_block_autofill));
|
||||||
CheckBoxPreference autoUnlockAfterAutofill = (CheckBoxPreference) findPreference(getString(R.string.settings_key_auto_unlock_after_autofill));
|
CheckBoxPreference autoUnlockAfterAutofill = (CheckBoxPreference) findPreference(getString(R.string.settings_key_auto_unlock_after_autofill));
|
||||||
|
@ -381,44 +368,40 @@ public class SettingsActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
catSecurity = (PreferenceCategory) findPreference(getString(R.string.settings_key_cat_security));
|
|
||||||
catUI = (PreferenceCategory) findPreference(getString(R.string.settings_key_cat_ui));
|
catUI = (PreferenceCategory) findPreference(getString(R.string.settings_key_cat_ui));
|
||||||
encryption = (ListPreference) findPreference(getString(R.string.settings_key_encryption));
|
encryption = (ListPreference) findPreference(getString(R.string.settings_key_encryption));
|
||||||
themeMode = (ListPreference) findPreference(getString(R.string.settings_key_theme_mode));
|
themeMode = (ListPreference) findPreference(getString(R.string.settings_key_theme_mode));
|
||||||
theme = (ListPreference) findPreference(getString(R.string.settings_key_theme));
|
theme = (ListPreference) findPreference(getString(R.string.settings_key_theme));
|
||||||
|
|
||||||
encryption.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
encryption.setOnPreferenceChangeListener((preference, o) -> {
|
||||||
@Override
|
String newEncryption = (String) o;
|
||||||
public boolean onPreferenceChange(final Preference preference, Object o) {
|
EncryptionType encryptionType = EncryptionType.valueOf(newEncryption.toUpperCase());
|
||||||
String newEncryption = (String) o;
|
EncryptionType oldEncryptionType = settings.getEncryption();
|
||||||
EncryptionType encryptionType = EncryptionType.valueOf(newEncryption.toUpperCase());
|
AuthMethod authMethod = settings.getAuthMethod();
|
||||||
EncryptionType oldEncryptionType = settings.getEncryption();
|
|
||||||
AuthMethod authMethod = settings.getAuthMethod();
|
|
||||||
|
|
||||||
if (encryptionType != oldEncryptionType) {
|
if (encryptionType != oldEncryptionType) {
|
||||||
if (encryptionType == EncryptionType.PASSWORD) {
|
if (encryptionType == EncryptionType.PASSWORD) {
|
||||||
if (authMethod != AuthMethod.PASSWORD && authMethod != AuthMethod.PIN) {
|
if (authMethod != AuthMethod.PASSWORD && authMethod != AuthMethod.PIN) {
|
||||||
UIHelper.showGenericDialog(getActivity(), R.string.settings_dialog_title_error, R.string.settings_dialog_msg_encryption_invalid_with_auth);
|
UIHelper.showGenericDialog(getActivity(), R.string.settings_dialog_title_error, R.string.settings_dialog_msg_encryption_invalid_with_auth);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (settings.getAuthCredentials().isEmpty()) {
|
||||||
|
UIHelper.showGenericDialog(getActivity(), R.string.settings_dialog_title_error, R.string.settings_dialog_msg_encryption_invalid_without_credentials);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
if (settings.getAuthCredentials().isEmpty()) {
|
|
||||||
UIHelper.showGenericDialog(getActivity(), R.string.settings_dialog_title_error, R.string.settings_dialog_msg_encryption_invalid_without_credentials);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
encryptionChangeWithDialog(EncryptionType.PASSWORD);
|
|
||||||
} else if (encryptionType == EncryptionType.KEYSTORE) {
|
|
||||||
encryptionChangeWithDialog(EncryptionType.KEYSTORE);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
encryptionChangeWithDialog(EncryptionType.PASSWORD);
|
||||||
|
} else if (encryptionType == EncryptionType.KEYSTORE) {
|
||||||
|
encryptionChangeWithDialog(EncryptionType.KEYSTORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Backup location
|
// Backup location
|
||||||
backupLocation = findPreference(getString(R.string.settings_key_backup_location));
|
Preference backupLocation = findPreference(getString(R.string.settings_key_backup_location));
|
||||||
|
|
||||||
if (settings.isBackupLocationSet()) {
|
if (settings.isBackupLocationSet()) {
|
||||||
backupLocation.setSummary(R.string.settings_desc_backup_location_set);
|
backupLocation.setSummary(R.string.settings_desc_backup_location_set);
|
||||||
|
@ -426,40 +409,25 @@ public class SettingsActivity extends BaseActivity
|
||||||
backupLocation.setSummary(R.string.settings_desc_backup_location);
|
backupLocation.setSummary(R.string.settings_desc_backup_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
backupLocation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
backupLocation.setOnPreferenceClickListener(preference -> {
|
||||||
@Override
|
((SettingsActivity) getActivity()).requestBackupAccess();
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
return true;
|
||||||
((SettingsActivity) getActivity()).requestBackupAccess();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// OpenPGP
|
// OpenPGP
|
||||||
pgpProvider = (OpenPgpAppPreference) findPreference(getString(R.string.settings_key_openpgp_provider));
|
OpenPgpAppPreference pgpProvider = (OpenPgpAppPreference) findPreference(getString(R.string.settings_key_openpgp_provider));
|
||||||
pgpEncryptionKey = (EditTextPreference) findPreference(getString(R.string.settings_key_openpgp_key_encrypt));
|
pgpEncryptionKey = (EditTextPreference) findPreference(getString(R.string.settings_key_openpgp_key_encrypt));
|
||||||
pgpSigningKey = (OpenPgpKeyPreference) findPreference(getString(R.string.settings_key_openpgp_key_sign));
|
pgpSigningKey = (OpenPgpKeyPreference) findPreference(getString(R.string.settings_key_openpgp_key_sign));
|
||||||
|
|
||||||
pgpSigningKey.setOpenPgpProvider(pgpProvider.getValue());
|
pgpSigningKey.setOpenPgpProvider(pgpProvider.getValue());
|
||||||
|
|
||||||
if (pgpProvider.getValue() != null && ! pgpProvider.getValue().isEmpty()) {
|
pgpEncryptionKey.setEnabled(pgpProvider.getValue() != null && !pgpProvider.getValue().isEmpty());
|
||||||
pgpEncryptionKey.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
pgpEncryptionKey.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
pgpProvider.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
pgpProvider.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
@Override
|
pgpEncryptionKey.setEnabled(newValue != null && !((String) newValue).isEmpty());
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
pgpSigningKey.setOpenPgpProvider((String) newValue);
|
||||||
if (newValue != null && ! ((String) newValue).isEmpty()) {
|
|
||||||
pgpEncryptionKey.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
pgpEncryptionKey.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
pgpSigningKey.setOpenPgpProvider((String) newValue);
|
return true;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useAutoBackup = (ListPreference)findPreference(getString(R.string.settings_key_auto_backup_password_enc));
|
useAutoBackup = (ListPreference)findPreference(getString(R.string.settings_key_auto_backup_password_enc));
|
||||||
|
@ -475,48 +443,34 @@ public class SettingsActivity extends BaseActivity
|
||||||
addPreferencesFromResource(R.xml.preferences_special);
|
addPreferencesFromResource(R.xml.preferences_special);
|
||||||
|
|
||||||
Preference clearKeyStore = findPreference(getString(R.string.settings_key_clear_keystore));
|
Preference clearKeyStore = findPreference(getString(R.string.settings_key_clear_keystore));
|
||||||
clearKeyStore.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
clearKeyStore.setOnPreferenceClickListener(preference -> {
|
||||||
@Override
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
||||||
|
|
||||||
builder.setTitle(R.string.settings_dialog_title_clear_keystore);
|
builder.setTitle(R.string.settings_dialog_title_clear_keystore);
|
||||||
if (settings.getEncryption() == EncryptionType.PASSWORD)
|
if (settings.getEncryption() == EncryptionType.PASSWORD)
|
||||||
builder.setMessage(R.string.settings_dialog_msg_clear_keystore_password);
|
builder.setMessage(R.string.settings_dialog_msg_clear_keystore_password);
|
||||||
else if (settings.getEncryption() == EncryptionType.KEYSTORE)
|
else if (settings.getEncryption() == EncryptionType.KEYSTORE)
|
||||||
builder.setMessage(R.string.settings_dialog_msg_clear_keystore_keystore);
|
builder.setMessage(R.string.settings_dialog_msg_clear_keystore_keystore);
|
||||||
|
|
||||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
|
||||||
@Override
|
KeyStoreHelper.wipeKeys(getActivity());
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
if (settings.getEncryption() == EncryptionType.KEYSTORE) {
|
||||||
KeyStoreHelper.wipeKeys(getActivity());
|
DatabaseHelper.wipeDatabase(getActivity());
|
||||||
if (settings.getEncryption() == EncryptionType.KEYSTORE) {
|
((SettingsActivity) getActivity()).generateNewEncryptionKey();
|
||||||
DatabaseHelper.wipeDatabase(getActivity());
|
}
|
||||||
((SettingsActivity) getActivity()).generateNewEncryptionKey();
|
});
|
||||||
}
|
builder.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> {
|
||||||
}
|
});
|
||||||
});
|
|
||||||
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//Remove Theme Mode selection option for devices below Android 10. Disable theme selection if Theme Mode is set auto
|
// Remove Theme Mode selection option for devices below Android 10. Disable theme selection if Theme Mode is set auto
|
||||||
//TODO: 29 needs to be replaced with VERSION_CODE.Q when compileSdk and targetSdk is updated to 29
|
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
if(Build.VERSION.SDK_INT < 29) {
|
|
||||||
catUI.removePreference(themeMode);
|
catUI.removePreference(themeMode);
|
||||||
} else {
|
} else {
|
||||||
if(sharedPref.getString(getString(R.string.settings_key_theme_mode),getString(R.string.settings_default_theme_mode)).equals("auto")) {
|
theme.setEnabled(!sharedPref.getString(getString(R.string.settings_key_theme_mode), getString(R.string.settings_default_theme_mode)).equals("auto"));
|
||||||
theme.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
theme.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class Settings {
|
||||||
private static final List<String> newLangs = Arrays.asList("ar", "bg", "ca", "cs", "de", "el", "en", "es", "fa", "fr", "gl", "hi", "hu", "it", "ja", "nl", "pl", "pt_BR", "ru", "sl", "sv", "tr", "uk", "zh_CN", "zh_TW");
|
private static final List<String> newLangs = Arrays.asList("ar", "bg", "ca", "cs", "de", "el", "en", "es", "fa", "fr", "gl", "hi", "hu", "it", "ja", "nl", "pl", "pt_BR", "ru", "sl", "sv", "tr", "uk", "zh_CN", "zh_TW");
|
||||||
private static final List<String> oldLangs = Arrays.asList("ar_SA", "bg_BG", "ca_ES", "cs_CZ", "de_DE", "el_GR", "en_US", "es_ES", "fa_IR", "fr_FR", "gl_ES", "hi_IN", "hu_HU", "it_IT", "ja_JP", "nl_NL", "pl_PL", "pt_BR", "ru_RU", "sl_SI", "sv_SE", "tr_TR", "uk_UA", "zh_CN", "zh_TW");
|
private static final List<String> oldLangs = Arrays.asList("ar_SA", "bg_BG", "ca_ES", "cs_CZ", "de_DE", "el_GR", "en_US", "es_ES", "fa_IR", "fr_FR", "gl_ES", "hi_IN", "hu_HU", "it_IT", "ja_JP", "nl_NL", "pl_PL", "pt_BR", "ru_RU", "sl_SI", "sv_SE", "tr_TR", "uk_UA", "zh_CN", "zh_TW");
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private SharedPreferences settings;
|
private final SharedPreferences settings;
|
||||||
|
|
||||||
public Settings(Context context) {
|
public Settings(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -141,12 +141,14 @@ public class Settings {
|
||||||
return settings.getInt(getResString(keyId), defaultValue);
|
return settings.getInt(getResString(keyId), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
private long getLong(int keyId, long defaultValue) {
|
private long getLong(int keyId, long defaultValue) {
|
||||||
return settings.getLong(getResString(keyId), defaultValue);
|
return settings.getLong(getResString(keyId), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
private Set<String> getStringSet(int keyId, Set<String> defaultValue) {
|
private Set<String> getStringSet(int keyId, Set<String> defaultValue) {
|
||||||
return new HashSet<String>(settings.getStringSet(getResString(keyId), defaultValue));
|
return new HashSet<>(settings.getStringSet(getResString(keyId), defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBoolean(int keyId, boolean value) {
|
private void setBoolean(int keyId, boolean value) {
|
||||||
|
@ -155,6 +157,7 @@ public class Settings {
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
private void setInt(int keyId, int value) {
|
private void setInt(int keyId, int value) {
|
||||||
settings.edit()
|
settings.edit()
|
||||||
.putInt(getResString(keyId), value)
|
.putInt(getResString(keyId), value)
|
||||||
|
@ -167,6 +170,7 @@ public class Settings {
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
private void setStringSet(int keyId, Set<String> value) {
|
private void setStringSet(int keyId, Set<String> value) {
|
||||||
settings.edit()
|
settings.edit()
|
||||||
.putStringSet(getResString(keyId), value)
|
.putStringSet(getResString(keyId), value)
|
||||||
|
@ -179,6 +183,7 @@ public class Settings {
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ApplySharedPref")
|
||||||
public void clear(boolean keep_auth) {
|
public void clear(boolean keep_auth) {
|
||||||
AuthMethod authMethod = getAuthMethod();
|
AuthMethod authMethod = getAuthMethod();
|
||||||
String authCredentials = getAuthCredentials();
|
String authCredentials = getAuthCredentials();
|
||||||
|
@ -313,7 +318,7 @@ public class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPanicResponse() {
|
public Set<String> getPanicResponse() {
|
||||||
return settings.getStringSet(getResString(R.string.settings_key_panic), Collections.<String>emptySet());
|
return settings.getStringSet(getResString(R.string.settings_key_panic), Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getRelockOnScreenOff() {
|
public boolean getRelockOnScreenOff() {
|
||||||
|
@ -352,8 +357,7 @@ public class Settings {
|
||||||
int theme = R.style.AppTheme_NoActionBar;
|
int theme = R.style.AppTheme_NoActionBar;
|
||||||
String themeMode = getString(R.string.settings_key_theme_mode, R.string.settings_default_theme_mode);
|
String themeMode = getString(R.string.settings_key_theme_mode, R.string.settings_default_theme_mode);
|
||||||
|
|
||||||
//TODO: 29 needs to be replaced with VERSION_CODE.Q when compileSdk and targetSdk is updated to 29
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && themeMode.equals("auto")){
|
||||||
if(Build.VERSION.SDK_INT >= 29 && themeMode.equals("auto")){
|
|
||||||
switch (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) {
|
switch (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) {
|
||||||
//Dark Mode
|
//Dark Mode
|
||||||
case Configuration.UI_MODE_NIGHT_YES:
|
case Configuration.UI_MODE_NIGHT_YES:
|
||||||
|
@ -367,15 +371,18 @@ public class Settings {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String themeName = getString(R.string.settings_key_theme, R.string.settings_default_theme);
|
String themeName = getString(R.string.settings_key_theme, R.string.settings_default_theme);
|
||||||
|
|
||||||
if (themeName.equals("light")) {
|
switch (themeName) {
|
||||||
theme = R.style.AppTheme_NoActionBar;
|
case "light":
|
||||||
} else if (themeName.equals("dark")) {
|
theme = R.style.AppTheme_NoActionBar;
|
||||||
theme = R.style.AppTheme_Dark_NoActionBar;
|
break;
|
||||||
} else if (themeName.equals("black")) {
|
case "dark":
|
||||||
theme = R.style.AppTheme_Black_NoActionBar;
|
theme = R.style.AppTheme_Dark_NoActionBar;
|
||||||
|
break;
|
||||||
|
case "black":
|
||||||
|
theme = R.style.AppTheme_Black_NoActionBar;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +460,7 @@ public class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getBackupBroadcasts() {
|
public Set<String> getBackupBroadcasts() {
|
||||||
return settings.getStringSet(getResString(R.string.settings_key_backup_broadcasts), Collections.<String>emptySet());
|
return settings.getStringSet(getResString(R.string.settings_key_backup_broadcasts), Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlainTextBackupBroadcastEnabled() {
|
public boolean isPlainTextBackupBroadcastEnabled() {
|
||||||
|
@ -498,12 +505,12 @@ public class Settings {
|
||||||
|
|
||||||
public boolean getTagToggle(String tag) {
|
public boolean getTagToggle(String tag) {
|
||||||
//The tag toggle holds tags that are unchecked in order to default to checked.
|
//The tag toggle holds tags that are unchecked in order to default to checked.
|
||||||
Set<String> toggledTags = getStringSet(R.string.settings_key_tags_toggles, new HashSet<String>());
|
Set<String> toggledTags = getStringSet(R.string.settings_key_tags_toggles, new HashSet<>());
|
||||||
return !toggledTags.contains(tag);
|
return !toggledTags.contains(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTagToggle(String tag, Boolean value) {
|
public void setTagToggle(String tag, Boolean value) {
|
||||||
Set<String> toggledTags = getStringSet(R.string.settings_key_tags_toggles, new HashSet<String>());
|
Set<String> toggledTags = getStringSet(R.string.settings_key_tags_toggles, new HashSet<>());
|
||||||
if(value)
|
if(value)
|
||||||
toggledTags.remove(tag);
|
toggledTags.remove(tag);
|
||||||
else
|
else
|
||||||
|
@ -527,7 +534,7 @@ public class Settings {
|
||||||
|
|
||||||
public int getTokenSplitGroupSize() {
|
public int getTokenSplitGroupSize() {
|
||||||
// the setting is of type "String", because ListPreference does not support integer arrays for its entryValues
|
// the setting is of type "String", because ListPreference does not support integer arrays for its entryValues
|
||||||
return Integer.valueOf(
|
return Integer.parseInt(
|
||||||
getString(R.string.settings_key_split_group_size, R.string.settings_default_split_group_size)
|
getString(R.string.settings_key_split_group_size, R.string.settings_default_split_group_size)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -538,10 +545,12 @@ public class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
public boolean getScreenshotsEnabled() {
|
public boolean getScreenshotsEnabled() {
|
||||||
return getBoolean(R.string.settings_key_enable_screenshot, false);
|
return getBoolean(R.string.settings_key_enable_screenshot, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
public boolean getUsedTokensDialogShown() {
|
public boolean getUsedTokensDialogShown() {
|
||||||
return getBoolean(R.string.settings_key_last_used_dialog_shown, false);
|
return getBoolean(R.string.settings_key_last_used_dialog_shown, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue