Skip to content

Do not show existing password on password change #689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class AccountSettingsActivity: AppCompatActivity() {
if (showUsernameDialog)
EditTextInputDialog(
title = stringResource(R.string.settings_username),
initialValue = credentials.username ?: "",
initialValue = credentials.username,
onValueEntered = { newValue ->
onUpdateCredentials(credentials.copy(username = newValue))
},
Expand All @@ -436,7 +436,9 @@ class AccountSettingsActivity: AppCompatActivity() {
if (showPasswordDialog)
EditTextInputDialog(
title = stringResource(R.string.settings_password),
initialValue = credentials.password,
inputLabel = stringResource(R.string.settings_new_password),
initialValue = null, // Do not show the existing password
passwordField = true,
onValueEntered = { newValue ->
onUpdateCredentials(credentials.copy(password = newValue))
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ import androidx.compose.ui.window.Dialog
fun EditTextInputDialog(
title: String,
initialValue: String? = null,
keyboardType: KeyboardType = KeyboardType.Text,
inputLabel: String? = null,
passwordField: Boolean = false,
keyboardType: KeyboardType = if (passwordField) KeyboardType.Password else KeyboardType.Text,
onValueEntered: (String) -> Unit = {},
onDismiss: () -> Unit = {},
) {
Expand All @@ -62,22 +64,31 @@ fun EditTextInputDialog(
},
text = {
val focusRequester = remember { FocusRequester() }
TextField(
value = textValue,
onValueChange = { textValue = it },
singleLine = true,
keyboardOptions = KeyboardOptions(
keyboardType = keyboardType,
imeAction = ImeAction.Done
),
keyboardActions = KeyboardActions(
onDone = {
onValueEntered(textValue.text)
onDismiss()
}
),
modifier = Modifier.focusRequester(focusRequester)
)
if (passwordField)
PasswordTextField(
password = textValue.text,
labelText = inputLabel,
onPasswordChange = { textValue = TextFieldValue(it) },
modifier = Modifier.focusRequester(focusRequester)
)
else
TextField(
label = { inputLabel?.let { Text(it) } },
value = textValue,
onValueChange = { textValue = it },
singleLine = true,
keyboardOptions = KeyboardOptions(
keyboardType = keyboardType,
imeAction = ImeAction.Done
),
keyboardActions = KeyboardActions(
onDone = {
onValueEntered(textValue.text)
onDismiss()
}
),
modifier = Modifier.focusRequester(focusRequester)
)
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}
Expand Down Expand Up @@ -108,10 +119,21 @@ fun EditTextInputDialog(
fun EditTextInputDialog_Preview() {
EditTextInputDialog(
title = "Enter Some Text",
inputLabel = "Some Label",
initialValue = "initial value"
)
}

@Composable
@Preview
fun EditTextInputDialog_Preview_Password() {
EditTextInputDialog(
title = "New Password",
passwordField = true,
initialValue = "some password"
)
}


@Composable
fun MultipleChoiceInputDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import at.bitfire.davdroid.R
@Composable
fun PasswordTextField(
password: String,
labelText: String,
labelText: String?,
onPasswordChange: (String) -> Unit,
modifier: Modifier = Modifier,
leadingIcon: @Composable (() -> Unit)? = null,
Expand All @@ -44,7 +44,7 @@ fun PasswordTextField(
OutlinedTextField(
value = password,
onValueChange = onPasswordChange,
label = { Text(labelText) },
label = { if (labelText != null) Text(labelText) },
leadingIcon = leadingIcon,
isError = isError,
singleLine = true,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
<string name="settings_oauth_summary">Perform OAuth login again</string>
<string name="settings_username">User name</string>
<string name="settings_password">Password</string>
<string name="settings_new_password">New password</string>
<string name="settings_password_summary">Update the password according to your server.</string>
<string name="settings_certificate_alias">Client certificate</string>
<string name="settings_certificate_alias_empty">No certificate available or selected</string>
Expand Down