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