From ae0d8353e32e9df34c698ecf62b520bf904c6122 Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Mon, 15 Jun 2020 07:21:54 +0200 Subject: [PATCH] Show auto backup requirements in the Settings Closes #492 --- .../andotp/Activities/SettingsActivity.java | 24 ++++++++++++------- app/src/main/res/values/strings_settings.xml | 2 ++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java index 6534bb79..a93100a4 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java @@ -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); diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index b4701329..be4a104a 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -90,6 +90,8 @@ Creates a new encrypted backup when new entries are added, or edited, if settings conditions are met + Set a default backup location and a + backup password to enable this option Select which backup types can be triggered by 3rd-party apps using Broadcasts