diff --git a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivity.kt
index e2d3470e91..eed49c87da 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivity.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivity.kt
@@ -85,7 +85,7 @@ class RestoreLocalBackupActivity : BaseActivity() {
LaunchedEffect(state.restorePhase) {
when (state.restorePhase) {
RestorePhase.COMPLETE -> {
- if (!state.showLocalBackupsDisabledDialog) {
+ if (state.dialog == null) {
startActivity(MainActivity.clearTop(this@RestoreLocalBackupActivity))
if (finishActivity) {
finishAffinity()
@@ -108,8 +108,34 @@ class RestoreLocalBackupActivity : BaseActivity() {
RestoreLocalBackupScreen(
state = state,
onContactSupportClick = contactSupportViewModel::showContactSupport,
+ onConfirmBackupLocation = {
+ viewModel.enableLocalBackupsAndDismissDialog()
+ startActivity(MainActivity.clearTop(this@RestoreLocalBackupActivity))
+ if (finishActivity) {
+ finishAffinity()
+ }
+ },
+ onDisableBackups = {
+ viewModel.changeBackupLocation()
+ startActivity(MainActivity.clearTop(this@RestoreLocalBackupActivity))
+ if (finishActivity) {
+ finishAffinity()
+ }
+ },
+ onChangeBackupLocation = {
+ viewModel.changeBackupLocation()
+ startActivities(
+ arrayOf(
+ MainActivity.clearTop(this@RestoreLocalBackupActivity),
+ AppSettingsActivity.backups(this@RestoreLocalBackupActivity)
+ )
+ )
+ if (finishActivity) {
+ finishAffinity()
+ }
+ },
onLocalBackupsDisabledDialogConfirm = {
- viewModel.dismissLocalBackupsDisabledDialog()
+ viewModel.dismissDialog()
startActivities(
arrayOf(
MainActivity.clearTop(this@RestoreLocalBackupActivity),
@@ -121,7 +147,7 @@ class RestoreLocalBackupActivity : BaseActivity() {
}
},
onLocalBackupsDisabledDialogDeny = {
- viewModel.dismissLocalBackupsDisabledDialog()
+ viewModel.dismissDialog()
startActivity(MainActivity.clearTop(this@RestoreLocalBackupActivity))
if (finishActivity) {
finishAffinity()
@@ -148,6 +174,9 @@ class RestoreLocalBackupActivity : BaseActivity() {
private fun RestoreLocalBackupScreen(
state: RestoreLocalBackupScreenState,
onFailureDialogConfirm: () -> Unit,
+ onConfirmBackupLocation: () -> Unit,
+ onChangeBackupLocation: () -> Unit,
+ onDisableBackups: () -> Unit,
onLocalBackupsDisabledDialogConfirm: () -> Unit,
onLocalBackupsDisabledDialogDeny: () -> Unit,
onContactSupportClick: () -> Unit,
@@ -266,15 +295,30 @@ private fun RestoreLocalBackupScreen(
}
}
- if (state.showLocalBackupsDisabledDialog) {
- Dialogs.SimpleAlertDialog(
- title = stringResource(R.string.RestoreLocalBackupActivity__turn_on_on_device_backups),
- body = stringResource(R.string.RestoreLocalBackupActivity__to_continue_using_on_device_backups),
- confirm = stringResource(R.string.RestoreLocalBackupActivity__turn_on_now),
- dismiss = stringResource(R.string.RestoreLocalBackupActivity__not_now),
- onConfirm = onLocalBackupsDisabledDialogConfirm,
- onDeny = onLocalBackupsDisabledDialogDeny
- )
+ when (state.dialog) {
+ RestoreLocalBackupActivityDialog.CONFIRM_BACKUP_LOCATION -> {
+ Dialogs.AdvancedAlertDialog(
+ title = stringResource(R.string.RestoreLocalBackupActivity__restore_complete),
+ body = stringResource(R.string.RestoreLocalBackupActivity__choose_a_folder_for_backups),
+ positive = stringResource(R.string.RestoreLocalBackupActivity__use_current_folder),
+ neutral = stringResource(R.string.RestoreLocalBackupActivity__choose_new_folder),
+ negative = stringResource(R.string.RestoreLocalBackupActivity__disable_backups),
+ onPositive = onConfirmBackupLocation,
+ onNeutral = onChangeBackupLocation,
+ onNegative = onDisableBackups
+ )
+ }
+ RestoreLocalBackupActivityDialog.LOCAL_BACKUPS_DISABLED -> {
+ Dialogs.SimpleAlertDialog(
+ title = stringResource(R.string.RestoreLocalBackupActivity__turn_on_on_device_backups),
+ body = stringResource(R.string.RestoreLocalBackupActivity__to_continue_using_on_device_backups),
+ confirm = stringResource(R.string.RestoreLocalBackupActivity__turn_on_now),
+ dismiss = stringResource(R.string.RestoreLocalBackupActivity__not_now),
+ onConfirm = onLocalBackupsDisabledDialogConfirm,
+ onDeny = onLocalBackupsDisabledDialogDeny
+ )
+ }
+ null -> Unit
}
}
}
@@ -286,6 +330,9 @@ private fun RestoreLocalBackupScreenPreview() {
RestoreLocalBackupScreen(
state = RestoreLocalBackupScreenState(),
onFailureDialogConfirm = {},
+ onConfirmBackupLocation = {},
+ onChangeBackupLocation = {},
+ onDisableBackups = {},
onLocalBackupsDisabledDialogConfirm = {},
onLocalBackupsDisabledDialogDeny = {},
onContactSupportClick = {},
diff --git a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivityViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivityViewModel.kt
index 1672c2484d..e3fcff3df9 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivityViewModel.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/registration/ui/restore/local/RestoreLocalBackupActivityViewModel.kt
@@ -140,7 +140,6 @@ class RestoreLocalBackupActivityViewModel : ViewModel() {
val backupIdMatchesCurrentAccount = actualBackupId?.value?.contentEquals(expectedBackupId.value) == true
if (backupIdMatchesCurrentAccount) {
SignalStore.account.restoreAccountEntropyPool(localAepPool)
- SignalStore.backup.newLocalBackupsEnabled = true
} else {
Log.w(TAG, "Local backup does not match current account, not re-enabling local backups")
}
@@ -151,7 +150,9 @@ class RestoreLocalBackupActivityViewModel : ViewModel() {
internalState.update {
it.copy(
restorePhase = RestorePhase.COMPLETE,
- showLocalBackupsDisabledDialog = !backupIdMatchesCurrentAccount
+ backupDirectory = if (backupIdMatchesCurrentAccount) backupDirectory else null,
+ dialog = if (backupIdMatchesCurrentAccount) RestoreLocalBackupActivityDialog.CONFIRM_BACKUP_LOCATION
+ else RestoreLocalBackupActivityDialog.LOCAL_BACKUPS_DISABLED
)
}
} else {
@@ -161,8 +162,18 @@ class RestoreLocalBackupActivityViewModel : ViewModel() {
}
}
- fun dismissLocalBackupsDisabledDialog() {
- internalState.update { it.copy(showLocalBackupsDisabledDialog = false) }
+ fun enableLocalBackupsAndDismissDialog() {
+ SignalStore.backup.newLocalBackupsEnabled = true
+ internalState.update { it.copy(dialog = null) }
+ }
+
+ fun changeBackupLocation() {
+ SignalStore.backup.newLocalBackupsDirectory = null
+ internalState.update { it.copy(dialog = null) }
+ }
+
+ fun dismissDialog() {
+ internalState.update { it.copy(dialog = null) }
}
fun resetRestoreState() {
@@ -175,7 +186,8 @@ data class RestoreLocalBackupScreenState(
val bytesRead: ByteSize = 0L.bytes,
val totalBytes: ByteSize = 0L.bytes,
val progress: Float = 0f,
- val showLocalBackupsDisabledDialog: Boolean = false
+ val dialog: RestoreLocalBackupActivityDialog? = null,
+ val backupDirectory: String? = null
)
enum class RestorePhase {
@@ -184,3 +196,8 @@ enum class RestorePhase {
COMPLETE,
FAILED
}
+
+enum class RestoreLocalBackupActivityDialog {
+ LOCAL_BACKUPS_DISABLED,
+ CONFIRM_BACKUP_LOCATION
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f35126202f..b6bc86fcb5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -9264,6 +9264,18 @@
Not now
+
+ To continue using on-device backups, choose a folder on your device where new backups will be saved.
+
+
+ Use current folder
+
+
+ Choose new folder
+
+
+ Disable backups
+
Select your backup folder