From ff97c65d4ffbf1e38029af4f27d9a49348243f89 Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Sat, 18 Jan 2025 05:47:23 -0500 Subject: [PATCH] fix: preshared key should be hidden closes #547 --- .../tunneloptions/config/ConfigScreen.kt | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt index 6fdccaa..3496f3d 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt @@ -677,15 +677,33 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) { hint = stringResource(R.string.base64_key), modifier = Modifier.fillMaxWidth(), ) - ConfigurationTextBox( + val presharedKeyEnabled = (tunnelConfig == null) || isAuthenticated || peer.preSharedKey.isBlank() + OutlinedTextField( + textStyle = MaterialTheme.typography.labelLarge, + modifier = + Modifier + .fillMaxWidth() + .clickable { showAuthPrompt = true }, value = peer.preSharedKey, - onValueChange = { value -> - peersState[index] = peersState[index].copy(preSharedKey = value) + visualTransformation = + if (presharedKeyEnabled) { + VisualTransformation.None + } else { + PasswordVisualTransformation() }, + enabled = presharedKeyEnabled, + onValueChange = { value -> peersState[index] = peersState[index].copy(preSharedKey = value) }, + label = { Text(stringResource(R.string.preshared_key)) }, + singleLine = true, + placeholder = { + Text( + stringResource(R.string.optional), + style = MaterialTheme.typography.labelLarge, + color = MaterialTheme.colorScheme.outline, + ) + }, + keyboardOptions = keyboardOptions, keyboardActions = keyboardActions, - label = stringResource(R.string.preshared_key), - hint = stringResource(R.string.optional), - modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( textStyle = MaterialTheme.typography.labelLarge,