Галочка сохранения пароля при включении шифрования
This commit is contained in:
@@ -114,10 +114,11 @@ fun ConfirmationCancelOkDialog(onDismiss: () -> Unit, onConfirmation: () -> Unit
|
||||
@Composable
|
||||
fun EncryptionSetupDialog(
|
||||
onDismiss: () -> Unit,
|
||||
onConfirmation: (password: String, encryptPath: Boolean) -> Unit,
|
||||
onConfirmation: (password: String, encryptPath: Boolean, rememberPassword: Boolean) -> Unit,
|
||||
) {
|
||||
var password by remember { mutableStateOf("") }
|
||||
var encryptPath by remember { mutableStateOf(false) }
|
||||
var rememberPassword by remember { mutableStateOf(true) }
|
||||
BasicAlertDialog(onDismissRequest = onDismiss) {
|
||||
Card {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
@@ -135,6 +136,10 @@ fun EncryptionSetupDialog(
|
||||
Checkbox(checked = encryptPath, onCheckedChange = { encryptPath = it })
|
||||
Text(stringResource(R.string.dialog_encrypt_paths))
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Checkbox(checked = rememberPassword, onCheckedChange = { rememberPassword = it })
|
||||
Text(stringResource(R.string.dialog_remember_password))
|
||||
}
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) {
|
||||
Button(modifier = Modifier.weight(1f), onClick = onDismiss) {
|
||||
@@ -143,7 +148,7 @@ fun EncryptionSetupDialog(
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Button(
|
||||
modifier = Modifier.weight(1f),
|
||||
onClick = { onConfirmation(password, encryptPath) },
|
||||
onClick = { onConfirmation(password, encryptPath, rememberPassword) },
|
||||
enabled = password.isNotEmpty(),
|
||||
) {
|
||||
Text(stringResource(R.string.dialog_apply))
|
||||
|
||||
@@ -61,7 +61,7 @@ fun StorageTree(
|
||||
onClick: (Tree<IStorageInfo>) -> Unit,
|
||||
onRename: (Tree<IStorageInfo>, String) -> Unit,
|
||||
onRemove: (Tree<IStorageInfo>) -> Unit,
|
||||
onEncrypt: (Tree<IStorageInfo>, String, Boolean) -> Unit,
|
||||
onEncrypt: (Tree<IStorageInfo>, String, Boolean, Boolean) -> Unit,
|
||||
onOpenEncrypted: (Tree<IStorageInfo>, String, Boolean) -> Unit,
|
||||
onCloseEncrypted: (Tree<IStorageInfo>) -> Unit,
|
||||
onDisableEncryption: (Tree<IStorageInfo>) -> Unit,
|
||||
@@ -341,9 +341,9 @@ fun StorageTree(
|
||||
if (showSetupEncryptionDialog) {
|
||||
EncryptionSetupDialog(
|
||||
onDismiss = { showSetupEncryptionDialog = false },
|
||||
onConfirmation = { password, encryptPath ->
|
||||
onConfirmation = { password, encryptPath, rememberPassword ->
|
||||
showSetupEncryptionDialog = false
|
||||
onEncrypt(tree, password, encryptPath)
|
||||
onEncrypt(tree, password, encryptPath, rememberPassword)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -217,7 +217,12 @@ abstract class AbstractVaultBrowserViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
fun enableEncryption(storage: IStorageInfo, password: String, encryptPath: Boolean) {
|
||||
fun enableEncryption(
|
||||
storage: IStorageInfo,
|
||||
password: String,
|
||||
encryptPath: Boolean,
|
||||
rememberPassword: Boolean,
|
||||
) {
|
||||
val id = storage.uuid
|
||||
if (isStorageTaskActive(id)) {
|
||||
notifyUser(R.string.vault_msg_storage_pipeline_busy)
|
||||
@@ -235,7 +240,7 @@ abstract class AbstractVaultBrowserViewModel(
|
||||
ManageStoragesEncryptionUseCase.CanEncryptResult.Allowed -> {
|
||||
ctx.log(TaskLogLevel.Info, "Encrypting…")
|
||||
manageStoragesEncryptionUseCase.enableEncryption(storage, key, encryptPath)
|
||||
manageStoragesEncryptionUseCase.openStorage(storage, key, true)
|
||||
manageStoragesEncryptionUseCase.openStorage(storage, key, rememberPassword)
|
||||
ctx.log(TaskLogLevel.Info, "Encryption enabled")
|
||||
_userNotifications.emit(UserNotification.TextRes(R.string.msg_encryption_enabled))
|
||||
}
|
||||
|
||||
@@ -142,8 +142,13 @@ fun VaultBrowserScreen(
|
||||
onClick = { onOpenStorageHome(it.value.uuid.toString()) },
|
||||
onRename = { tree, newName -> viewModel.rename(tree.value, newName) },
|
||||
onRemove = { tree -> viewModel.remove(tree.value) },
|
||||
onEncrypt = { tree, password, encryptPath ->
|
||||
viewModel.enableEncryption(tree.value, password, encryptPath)
|
||||
onEncrypt = { tree, password, encryptPath, rememberPassword ->
|
||||
viewModel.enableEncryption(
|
||||
tree.value,
|
||||
password,
|
||||
encryptPath,
|
||||
rememberPassword,
|
||||
)
|
||||
},
|
||||
onOpenEncrypted = { tree, password, remember ->
|
||||
viewModel.openEncryptedStorage(tree.value, password, remember)
|
||||
|
||||
Reference in New Issue
Block a user