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)