diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt index 227e84d4..eb41bd95 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt @@ -63,14 +63,23 @@ class SettingsFragment : PreferenceFragmentCompat() { return@OnPreferenceChangeListener false } // main key is present, so enable or disable normally - try { - backupManager.isBackupEnabled = enabled - if (enabled) viewModel.enableCallLogBackup() - return@OnPreferenceChangeListener true - } catch (e: RemoteException) { - Log.e(TAG, "Error setting backup enabled to $enabled", e) - backup.isChecked = !enabled - return@OnPreferenceChangeListener false + when (enabled) { + true -> return@OnPreferenceChangeListener trySetBackupEnabled(true) + false -> { + AlertDialog.Builder(requireContext()) + .setIcon(R.drawable.ic_warning) + .setTitle(R.string.settings_backup_dialog_title) + .setMessage(R.string.settings_backup_dialog_message) + .setPositiveButton(R.string.settings_backup_dialog_disable) { dialog, _ -> + trySetBackupEnabled(false) + dialog.dismiss() + } + .setNegativeButton(R.string.settings_backup_apk_dialog_cancel) { dialog, + _ -> dialog.dismiss() + } + .show() + return@OnPreferenceChangeListener false + } } } @@ -189,6 +198,19 @@ class SettingsFragment : PreferenceFragmentCompat() { else -> super.onOptionsItemSelected(item) } + private fun trySetBackupEnabled(enabled: Boolean): Boolean { + return try { + backupManager.isBackupEnabled = enabled + if (enabled) viewModel.enableCallLogBackup() + backup.isChecked = enabled + true + } catch (e: RemoteException) { + Log.e(TAG, "Error setting backup enabled to $enabled", e) + backup.isChecked = !enabled + false + } + } + private fun setBackupEnabledState() { try { backup.isChecked = backupManager.isBackupEnabled diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b4976db9..428a2b24 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,6 +14,9 @@ None Internal storage Never + Really turn off app backups? + When you turn backups on again, the backup process may take longer than usual, and it will use additional storage space. + Turn off anyway All backups are encrypted on your phone. To restore from backup you will need your 12-word recovery code. Automatic restore When reinstalling an app, restore backed up settings and data.