Warn before turning off backups
Let the user know that turning off backups will require a new backup set to be created. Requires: https://github.com/seedvault-app/seedvault/pull/496 Change-Id: I22a1cebd272ac43cab6c68b99ace5919d6a7a9f5
This commit is contained in:
parent
87a800438b
commit
5d0aca1b49
2 changed files with 33 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
<string name="settings_backup_location_none">None</string>
|
||||
<string name="settings_backup_location_internal">Internal storage</string>
|
||||
<string name="settings_backup_last_backup_never">Never</string>
|
||||
<string name="settings_backup_dialog_title">Really turn off app backups?</string>
|
||||
<string name="settings_backup_dialog_message">When you turn backups on again, the backup process may take longer than usual, and it will use additional storage space.</string>
|
||||
<string name="settings_backup_dialog_disable">Turn off anyway</string>
|
||||
<string name="settings_info">All backups are encrypted on your phone. To restore from backup you will need your 12-word recovery code.</string>
|
||||
<string name="settings_auto_restore_title">Automatic restore</string>
|
||||
<string name="settings_auto_restore_summary">When reinstalling an app, restore backed up settings and data.</string>
|
||||
|
|
Loading…
Reference in a new issue