mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 19:26:17 +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 = {},
|
||||
|
||||
@@ -8513,6 +8513,12 @@
|
||||
<string name="MessageBackupsKeyRecordScreen__create_a_new_backup_key">Create a new recovery key</string>
|
||||
<!-- Bottom Sheet body for creating a new AEP key -->
|
||||
<string name="MessageBackupsKeyRecordScreen__creating_a_new_key_is_only_necessary">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.</string>
|
||||
<!-- Dialog title shown when user attempts to exit backup setup before completion -->
|
||||
<string name="MessageBackupsKeyRecordScreen__exit_backup_setup">Exit backup setup?</string>
|
||||
<!-- Dialog body warning user that backup setup is incomplete -->
|
||||
<string name="MessageBackupsKeyRecordScreen__you_have_not_finished_setting_up_backups">You have not finished setting up backups, and no backup has been created. You can enable backups in Settings.</string>
|
||||
<!-- Dialog confirmation button to exit backup setup -->
|
||||
<string name="MessageBackupsKeyRecordScreen__exit_backup_setup_confirm">Exit backup setup</string>
|
||||
|
||||
<!-- BackupKeyDisplayFragment -->
|
||||
<!-- Dialog title when exiting before confirming new key -->
|
||||
|
||||
Reference in New Issue
Block a user