mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 10:17:56 +00:00
Add back protection dialog on recovery key screen.
This commit is contained in:
@@ -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 = {},
|
||||
|
||||
Reference in New Issue
Block a user