From 0db67a851fa215a19a8a29871700cb23d06899f1 Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Tue, 22 Oct 2024 00:09:19 -0400 Subject: [PATCH] fix: preshared key password field closes #405 --- .../ui/screens/config/ConfigScreen.kt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigScreen.kt index 6fe28e6a..a65450d5 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/config/ConfigScreen.kt @@ -519,15 +519,27 @@ fun ConfigScreen(tunnelId: Int) { hint = stringResource(R.string.base64_key), modifier = Modifier.fillMaxWidth(), ) - ConfigurationTextBox( + OutlinedTextField( + modifier = + Modifier + .fillMaxWidth() + .clickable { showAuthPrompt = true }, value = peer.preSharedKey, + visualTransformation = + if ((tunnelId == Constants.MANUAL_TUNNEL_CONFIG_ID.toInt()) || isAuthenticated) { + VisualTransformation.None + } else { + PasswordVisualTransformation() + }, + enabled = (tunnelId == Constants.MANUAL_TUNNEL_CONFIG_ID.toInt()) || isAuthenticated || peer.preSharedKey.isEmpty(), onValueChange = { value -> viewModel.onPreSharedKeyChange(index, value) }, + label = { Text(stringResource(R.string.preshared_key)) }, + singleLine = true, + placeholder = { Text(stringResource(R.string.optional)) }, + keyboardOptions = keyboardOptions, keyboardActions = keyboardActions, - label = stringResource(R.string.preshared_key), - hint = stringResource(R.string.optional), - modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( modifier = Modifier.fillMaxWidth(),