diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ui/subscription/MessageBackupsKeyRecordScreen.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ui/subscription/MessageBackupsKeyRecordScreen.kt
index 752060f3ff..e34125bd28 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ui/subscription/MessageBackupsKeyRecordScreen.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ui/subscription/MessageBackupsKeyRecordScreen.kt
@@ -6,6 +6,8 @@
package org.thoughtcrime.securesms.backup.v2.ui.subscription
import android.content.Context
+import androidx.activity.compose.BackHandler
+import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.annotation.UiContext
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@@ -94,6 +96,10 @@ fun MessageBackupsKeyRecordScreen(
backupKey.chunked(4).joinToString(" ")
}
+ if (mode is MessageBackupsKeyRecordMode.Next) {
+ RecordScreenBackHandler()
+ }
+
Scaffolds.Settings(
title = "",
navigationIcon = ImageVector.vectorResource(R.drawable.symbol_arrow_start_24),
@@ -338,6 +344,38 @@ private fun BackupKeySaveErrorDialog(
}
}
+@Composable
+private fun RecordScreenBackHandler() {
+ var displayWarningDialog by remember { mutableStateOf(false) }
+ var didConfirmDialog by remember { mutableStateOf(false) }
+ val backPressedDispatcher = LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher
+
+ BackHandler(enabled = !didConfirmDialog) {
+ displayWarningDialog = true
+ }
+
+ LaunchedEffect(didConfirmDialog, backPressedDispatcher) {
+ if (didConfirmDialog) {
+ backPressedDispatcher?.onBackPressed()
+ }
+ }
+
+ if (displayWarningDialog) {
+ Dialogs.SimpleAlertDialog(
+ title = stringResource(R.string.MessageBackupsKeyRecordScreen__exit_backup_setup),
+ body = stringResource(R.string.MessageBackupsKeyRecordScreen__you_have_not_finished_setting_up_backups),
+ confirm = stringResource(R.string.MessageBackupsKeyRecordScreen__exit_backup_setup_confirm),
+ dismiss = stringResource(android.R.string.cancel),
+ onConfirm = {
+ didConfirmDialog = true
+ },
+ onDismiss = {
+ displayWarningDialog = false
+ }
+ )
+ }
+}
+
@Composable
private fun ColumnScope.CreateNewBackupKeySheetContent(
onContinueClick: () -> Unit = {},
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cfeaea6b05..e917e872e4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -8513,6 +8513,12 @@
Create a new recovery key
Creating a new key is only necessary if someone else knows your key. You will have to re-upload your backup, including media. If you are using \"Optimize storage\" you will have to download offloaded media first.
+
+ Exit backup setup?
+
+ You have not finished setting up backups, and no backup has been created. You can enable backups in Settings.
+
+ Exit backup setup