Add back protection dialog on recovery key screen.

This commit is contained in:
Alex Hart
2025-11-04 16:34:57 -04:00
committed by Michelle Tang
parent 1b5f49e94e
commit e5b8262cfe
2 changed files with 44 additions and 0 deletions

View File

@@ -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 = {},