From 914c4c4aa57877e6b2173873f324a58b3435ac24 Mon Sep 17 00:00:00 2001 From: Ullas-Aithal Date: Thu, 4 Mar 2021 11:54:16 +0530 Subject: [PATCH] Fixed bug where OK was still enabled when the passwords don't match. Renamed toShortWarning to tooShortWarning --- .../flocke/andotp/Dialogs/PasswordEntryDialog.java | 13 ++++++------- .../andotp/Preferences/CredentialsPreference.java | 10 +++++----- .../main/res/layout/component_authentication.xml | 2 +- app/src/main/res/layout/dialog_password_entry.xml | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java b/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java index c6aab987..188995bf 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java @@ -37,7 +37,7 @@ public class PasswordEntryDialog extends AppCompatDialog private final TextInputEditText passwordInput; private final EditText passwordConfirm; private final Button okButton; - private final TextView toShortWarning; + private final TextView tooShortWarning; public PasswordEntryDialog(Context context, Mode newMode, boolean blockAccessibility, boolean blockAutofill, PasswordEnteredCallback newCallback) { super(context, Tools.getThemeResource(context, R.attr.dialogTheme)); @@ -48,8 +48,8 @@ public class PasswordEntryDialog extends AppCompatDialog TextInputLayout passwordLayout = findViewById(R.id.passwordInputLayout); passwordInput = findViewById(R.id.passwordInput); passwordConfirm = findViewById(R.id.passwordConfirm); - toShortWarning = findViewById(R.id.toShortWarning); - toShortWarning.setText(getContext().getString(R.string.settings_label_short_password, Constants.AUTH_MIN_PASSWORD_LENGTH)); + tooShortWarning = findViewById(R.id.tooShortWarning); + tooShortWarning.setText(getContext().getString(R.string.settings_label_short_password, Constants.AUTH_MIN_PASSWORD_LENGTH)); ConfirmedPasswordTransformationHelper.setup(passwordLayout, passwordInput, passwordConfirm); if (blockAccessibility) { @@ -87,12 +87,11 @@ public class PasswordEntryDialog extends AppCompatDialog // TextWatcher public void onTextChanged(CharSequence s, int start, int before, int count) { if (passwordInput.getEditableText().length() >= Constants.AUTH_MIN_PASSWORD_LENGTH) { - toShortWarning.setVisibility(View.GONE); - if (TextUtils.equals(passwordInput.getEditableText(), passwordConfirm.getEditableText())) - okButton.setEnabled(true); + tooShortWarning.setVisibility(View.GONE); + okButton.setEnabled(TextUtils.equals(passwordInput.getEditableText(), passwordConfirm.getEditableText())); } else { - toShortWarning.setVisibility(View.VISIBLE); + tooShortWarning.setVisibility(View.VISIBLE); okButton.setEnabled(false); } } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java index b53445de..9ef6e21f 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java @@ -86,7 +86,7 @@ public class CredentialsPreference extends DialogPreference private TextInputLayout passwordLayout; private TextInputEditText passwordInput; private EditText passwordConfirm; - private TextView toShortWarning; + private TextView tooShortWarning; private Button btnSave; @@ -141,7 +141,7 @@ public class CredentialsPreference extends DialogPreference passwordConfirm.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO); } - toShortWarning = view.findViewById(R.id.toShortWarning); + tooShortWarning = view.findViewById(R.id.tooShortWarning); passwordInput.addTextChangedListener(this); passwordConfirm.addTextChangedListener(this); @@ -231,13 +231,13 @@ public class CredentialsPreference extends DialogPreference String password = passwordInput.getEditableText().toString(); if (password.length() >= minLength) { - toShortWarning.setVisibility(View.GONE); + tooShortWarning.setVisibility(View.GONE); String confirm = passwordConfirm.getEditableText().toString(); boolean canSave = !password.isEmpty() && !confirm.isEmpty() && password.equals(confirm); btnSave.setEnabled(canSave); } else { - toShortWarning.setVisibility(View.VISIBLE); + tooShortWarning.setVisibility(View.VISIBLE); } } @@ -274,7 +274,7 @@ public class CredentialsPreference extends DialogPreference minLength = isPassword ? Constants.AUTH_MIN_PASSWORD_LENGTH : Constants.AUTH_MIN_PIN_LENGTH; int shortWarningRes = isPassword ? R.string.settings_label_short_password : R.string.settings_label_short_pin; - toShortWarning.setText(getContext().getString(shortWarningRes, minLength)); + tooShortWarning.setText(getContext().getString(shortWarningRes, minLength)); passwordInput.requestFocus(); UIHelper.showKeyboard(getContext(), passwordInput); diff --git a/app/src/main/res/layout/component_authentication.xml b/app/src/main/res/layout/component_authentication.xml index 0f20052d..2dec5fe7 100644 --- a/app/src/main/res/layout/component_authentication.xml +++ b/app/src/main/res/layout/component_authentication.xml @@ -49,7 +49,7 @@ android:autofillHints="password" />