mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-17 07:22:50 +00:00
Show a warning when a separate export/backup password is configured
This commit is contained in:
parent
031a11250a
commit
7993142cc5
8 changed files with 56 additions and 30 deletions
|
@ -26,6 +26,7 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
|
|||
private Preference _backupsLocationPreference;
|
||||
private Preference _backupsTriggerPreference;
|
||||
private Preference _backupsVersionsPreference;
|
||||
private Preference _backupsPasswordWarningPreference;
|
||||
|
||||
private Preference _builtinBackupStatusPreference;
|
||||
private Preference _androidBackupStatusPreference;
|
||||
|
@ -41,6 +42,7 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
|
|||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
addPreferencesFromResource(R.xml.preferences_backups);
|
||||
|
||||
_backupsPasswordWarningPreference = requirePreference("pref_backups_warning_password");
|
||||
_builtinBackupStatusPreference = requirePreference("pref_status_backup_builtin");
|
||||
_builtinBackupStatusPreference.setOnPreferenceClickListener(preference -> {
|
||||
Preferences.BackupResult backupRes = _prefs.getBuiltInBackupResult();
|
||||
|
@ -138,6 +140,7 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
|
|||
boolean encrypted = _vaultManager.getVault().isEncryptionEnabled();
|
||||
boolean androidBackupEnabled = _prefs.isAndroidBackupsEnabled() && encrypted;
|
||||
boolean backupEnabled = _prefs.isBackupsEnabled() && encrypted;
|
||||
_backupsPasswordWarningPreference.setVisible(_vaultManager.getVault().isBackupPasswordSet());
|
||||
_androidBackupsPreference.setChecked(androidBackupEnabled);
|
||||
_androidBackupsPreference.setEnabled(encrypted);
|
||||
_backupsPreference.setChecked(backupEnabled);
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.view.View;
|
|||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -147,10 +148,13 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
}
|
||||
|
||||
private void startExport() {
|
||||
boolean isBackupPasswordSet = _vaultManager.getVault().isBackupPasswordSet();
|
||||
View view = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_export, null);
|
||||
TextView warningText = view.findViewById(R.id.text_export_warning);
|
||||
CheckBox checkBoxEncrypt = view.findViewById(R.id.checkbox_export_encrypt);
|
||||
CheckBox checkBoxAccept = view.findViewById(R.id.checkbox_accept);
|
||||
TextView passwordInfoText = view.findViewById(R.id.text_separate_password);
|
||||
passwordInfoText.setVisibility(checkBoxEncrypt.isChecked() && isBackupPasswordSet ? View.VISIBLE : View.GONE);
|
||||
AutoCompleteTextView dropdown = view.findViewById(R.id.dropdown_export_format);
|
||||
DropdownHelper.fillDropdown(requireContext(), dropdown, R.array.export_formats);
|
||||
dropdown.setText(getString(R.string.export_format_aegis), false);
|
||||
|
@ -158,6 +162,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
checkBoxEncrypt.setChecked(position == 0);
|
||||
checkBoxEncrypt.setEnabled(position == 0);
|
||||
warningText.setVisibility(checkBoxEncrypt.isChecked() ? View.GONE : View.VISIBLE);
|
||||
passwordInfoText.setVisibility(checkBoxEncrypt.isChecked() && isBackupPasswordSet ? View.VISIBLE : View.GONE);
|
||||
});
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(requireContext())
|
||||
|
@ -174,6 +179,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
|
|||
|
||||
checkBoxEncrypt.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
warningText.setVisibility(isChecked ? View.GONE : View.VISIBLE);
|
||||
passwordInfoText.setVisibility(isChecked && isBackupPasswordSet ? View.VISIBLE : View.GONE);
|
||||
checkBoxAccept.setVisibility(isChecked ? View.GONE : View.VISIBLE);
|
||||
checkBoxAccept.setChecked(false);
|
||||
btnPos.setEnabled(isChecked);
|
||||
|
|
|
@ -238,7 +238,7 @@ public class SecurityPreferencesFragment extends PreferencesFragment {
|
|||
|
||||
_backupPasswordPreference = requirePreference("pref_backup_password");
|
||||
_backupPasswordPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if (!isBackupPasswordSet()) {
|
||||
if (!_vaultManager.getVault().isBackupPasswordSet()) {
|
||||
Dialogs.showSetPasswordDialog(requireActivity(), new SetBackupPasswordListener());
|
||||
} else {
|
||||
VaultFileCredentials creds = _vaultManager.getVault().getCredentials();
|
||||
|
@ -264,7 +264,7 @@ public class SecurityPreferencesFragment extends PreferencesFragment {
|
|||
|
||||
private void updateEncryptionPreferences() {
|
||||
boolean encrypted = _vaultManager.getVault().isEncryptionEnabled();
|
||||
boolean backupPasswordSet = isBackupPasswordSet();
|
||||
boolean backupPasswordSet = _vaultManager.getVault().isBackupPasswordSet();
|
||||
_encryptionPreference.setChecked(encrypted, true);
|
||||
_setPasswordPreference.setVisible(encrypted);
|
||||
_biometricsPreference.setVisible(encrypted);
|
||||
|
@ -294,15 +294,6 @@ public class SecurityPreferencesFragment extends PreferencesFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isBackupPasswordSet() {
|
||||
VaultRepository vault = _vaultManager.getVault();
|
||||
if (!vault.isEncryptionEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return vault.getCredentials().getSlots().findBackupPasswordSlots().size() > 0;
|
||||
}
|
||||
|
||||
private String getPasswordReminderSummary() {
|
||||
PassReminderFreq freq = _prefs.getPasswordReminderFrequency();
|
||||
if (freq == PassReminderFreq.NEVER) {
|
||||
|
|
|
@ -230,4 +230,12 @@ public class VaultRepository {
|
|||
public boolean isEncryptionEnabled() {
|
||||
return _creds != null;
|
||||
}
|
||||
|
||||
public boolean isBackupPasswordSet() {
|
||||
if (!isEncryptionEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getCredentials().getSlots().findBackupPasswordSlots().size() > 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue