Show auto backup requirements in the Settings

Closes #492
This commit is contained in:
Jakob Nixdorf 2020-06-15 07:21:54 +02:00
parent 8dc46efaf9
commit ae0d8353e3
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
2 changed files with 18 additions and 8 deletions

View file

@ -168,11 +168,7 @@ public class SettingsActivity extends BaseActivity
}
}
if (fragment.useAutoBackup != null) {
fragment.useAutoBackup.setEnabled(BackupHelper.autoBackupType(this) == Constants.BackupType.ENCRYPTED);
if (!fragment.useAutoBackup.isEnabled())
fragment.useAutoBackup.setValue(Constants.AutoBackup.OFF.toString().toLowerCase(Locale.ENGLISH));
}
fragment.updateAutoBackup();
}
private void generateNewEncryptionKey() {
@ -316,6 +312,20 @@ public class SettingsActivity extends BaseActivity
.show();
}
public void updateAutoBackup() {
if (useAutoBackup != null) {
useAutoBackup.setEnabled(BackupHelper.autoBackupType(getActivity()) == Constants.BackupType.ENCRYPTED);
if (!useAutoBackup.isEnabled())
useAutoBackup.setValue(Constants.AutoBackup.OFF.toString().toLowerCase(Locale.ENGLISH));
if (useAutoBackup.isEnabled()) {
useAutoBackup.setSummary(R.string.settings_desc_auto_backup_password_enc);
} else {
useAutoBackup.setSummary(R.string.settings_desc_auto_backup_requirements);
}
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -414,9 +424,7 @@ public class SettingsActivity extends BaseActivity
});
useAutoBackup = (ListPreference)findPreference(getString(R.string.settings_key_auto_backup_password_enc));
useAutoBackup.setEnabled(BackupHelper.autoBackupType(getActivity()) == Constants.BackupType.ENCRYPTED);
if(!useAutoBackup.isEnabled())
useAutoBackup.setValue(Constants.AutoBackup.OFF.toString().toLowerCase(Locale.ENGLISH));
updateAutoBackup();
useAndroidSync = (CheckBoxPreference) findPreference(getString(R.string.settings_key_enable_android_backup_service));
useAndroidSync.setEnabled(settings.getEncryption() == EncryptionType.PASSWORD);

View file

@ -90,6 +90,8 @@
<string name="settings_desc_auto_backup_password_enc">Creates a new encrypted backup when new
entries are added, or edited, if settings conditions are met</string>
<string name="settings_desc_auto_backup_requirements">Set a default backup location and a
backup password to enable this option</string>
<string name="settings_desc_backup_broadcasts">Select which backup types can be triggered by
3rd-party apps using Broadcasts</string>