From 845b3a1d7687ba5ff0c4beb280ef7e7399281ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=8B=D1=82=D0=BA=D0=BE=D0=B2=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD?= Date: Sun, 17 May 2026 18:06:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=B0=D0=BB=D0=BE=D1=87=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=88?= =?UTF-8?q?=D0=B8=D1=84=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/nullptroma/wallenc/ui/elements/Dialogs.kt | 9 +++++++-- .../github/nullptroma/wallenc/ui/elements/StorageTree.kt | 6 +++--- .../main/screens/vault/AbstractVaultBrowserViewModel.kt | 9 +++++++-- .../ui/screens/main/screens/vault/VaultBrowserScreen.kt | 9 +++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/Dialogs.kt b/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/Dialogs.kt index 712bdae..bc2902b 100644 --- a/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/Dialogs.kt +++ b/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/Dialogs.kt @@ -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)) diff --git a/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/StorageTree.kt b/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/StorageTree.kt index 4c7cf2f..6458c67 100644 --- a/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/StorageTree.kt +++ b/ui/src/main/java/com/github/nullptroma/wallenc/ui/elements/StorageTree.kt @@ -61,7 +61,7 @@ fun StorageTree( onClick: (Tree) -> Unit, onRename: (Tree, String) -> Unit, onRemove: (Tree) -> Unit, - onEncrypt: (Tree, String, Boolean) -> Unit, + onEncrypt: (Tree, String, Boolean, Boolean) -> Unit, onOpenEncrypted: (Tree, String, Boolean) -> Unit, onCloseEncrypted: (Tree) -> Unit, onDisableEncryption: (Tree) -> 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) }, ) } diff --git a/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/AbstractVaultBrowserViewModel.kt b/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/AbstractVaultBrowserViewModel.kt index 82bf41e..1a4e1a7 100644 --- a/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/AbstractVaultBrowserViewModel.kt +++ b/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/AbstractVaultBrowserViewModel.kt @@ -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)) } diff --git a/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/VaultBrowserScreen.kt b/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/VaultBrowserScreen.kt index 1575aa6..3754699 100644 --- a/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/VaultBrowserScreen.kt +++ b/ui/src/main/java/com/github/nullptroma/wallenc/ui/screens/main/screens/vault/VaultBrowserScreen.kt @@ -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)