Fixed bug where OK was still enabled when the passwords don't match. Renamed toShortWarning to tooShortWarning
This commit is contained in:
parent
1963cfbda5
commit
914c4c4aa5
4 changed files with 13 additions and 14 deletions
|
@ -37,7 +37,7 @@ public class PasswordEntryDialog extends AppCompatDialog
|
||||||
private final TextInputEditText passwordInput;
|
private final TextInputEditText passwordInput;
|
||||||
private final EditText passwordConfirm;
|
private final EditText passwordConfirm;
|
||||||
private final Button okButton;
|
private final Button okButton;
|
||||||
private final TextView toShortWarning;
|
private final TextView tooShortWarning;
|
||||||
|
|
||||||
public PasswordEntryDialog(Context context, Mode newMode, boolean blockAccessibility, boolean blockAutofill, PasswordEnteredCallback newCallback) {
|
public PasswordEntryDialog(Context context, Mode newMode, boolean blockAccessibility, boolean blockAutofill, PasswordEnteredCallback newCallback) {
|
||||||
super(context, Tools.getThemeResource(context, R.attr.dialogTheme));
|
super(context, Tools.getThemeResource(context, R.attr.dialogTheme));
|
||||||
|
@ -48,8 +48,8 @@ public class PasswordEntryDialog extends AppCompatDialog
|
||||||
TextInputLayout passwordLayout = findViewById(R.id.passwordInputLayout);
|
TextInputLayout passwordLayout = findViewById(R.id.passwordInputLayout);
|
||||||
passwordInput = findViewById(R.id.passwordInput);
|
passwordInput = findViewById(R.id.passwordInput);
|
||||||
passwordConfirm = findViewById(R.id.passwordConfirm);
|
passwordConfirm = findViewById(R.id.passwordConfirm);
|
||||||
toShortWarning = findViewById(R.id.toShortWarning);
|
tooShortWarning = findViewById(R.id.tooShortWarning);
|
||||||
toShortWarning.setText(getContext().getString(R.string.settings_label_short_password, Constants.AUTH_MIN_PASSWORD_LENGTH));
|
tooShortWarning.setText(getContext().getString(R.string.settings_label_short_password, Constants.AUTH_MIN_PASSWORD_LENGTH));
|
||||||
ConfirmedPasswordTransformationHelper.setup(passwordLayout, passwordInput, passwordConfirm);
|
ConfirmedPasswordTransformationHelper.setup(passwordLayout, passwordInput, passwordConfirm);
|
||||||
|
|
||||||
if (blockAccessibility) {
|
if (blockAccessibility) {
|
||||||
|
@ -87,12 +87,11 @@ public class PasswordEntryDialog extends AppCompatDialog
|
||||||
// TextWatcher
|
// TextWatcher
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
if (passwordInput.getEditableText().length() >= Constants.AUTH_MIN_PASSWORD_LENGTH) {
|
if (passwordInput.getEditableText().length() >= Constants.AUTH_MIN_PASSWORD_LENGTH) {
|
||||||
toShortWarning.setVisibility(View.GONE);
|
tooShortWarning.setVisibility(View.GONE);
|
||||||
if (TextUtils.equals(passwordInput.getEditableText(), passwordConfirm.getEditableText()))
|
okButton.setEnabled(TextUtils.equals(passwordInput.getEditableText(), passwordConfirm.getEditableText()));
|
||||||
okButton.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toShortWarning.setVisibility(View.VISIBLE);
|
tooShortWarning.setVisibility(View.VISIBLE);
|
||||||
okButton.setEnabled(false);
|
okButton.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class CredentialsPreference extends DialogPreference
|
||||||
private TextInputLayout passwordLayout;
|
private TextInputLayout passwordLayout;
|
||||||
private TextInputEditText passwordInput;
|
private TextInputEditText passwordInput;
|
||||||
private EditText passwordConfirm;
|
private EditText passwordConfirm;
|
||||||
private TextView toShortWarning;
|
private TextView tooShortWarning;
|
||||||
|
|
||||||
private Button btnSave;
|
private Button btnSave;
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ public class CredentialsPreference extends DialogPreference
|
||||||
passwordConfirm.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
|
passwordConfirm.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
toShortWarning = view.findViewById(R.id.toShortWarning);
|
tooShortWarning = view.findViewById(R.id.tooShortWarning);
|
||||||
|
|
||||||
passwordInput.addTextChangedListener(this);
|
passwordInput.addTextChangedListener(this);
|
||||||
passwordConfirm.addTextChangedListener(this);
|
passwordConfirm.addTextChangedListener(this);
|
||||||
|
@ -231,13 +231,13 @@ public class CredentialsPreference extends DialogPreference
|
||||||
String password = passwordInput.getEditableText().toString();
|
String password = passwordInput.getEditableText().toString();
|
||||||
|
|
||||||
if (password.length() >= minLength) {
|
if (password.length() >= minLength) {
|
||||||
toShortWarning.setVisibility(View.GONE);
|
tooShortWarning.setVisibility(View.GONE);
|
||||||
String confirm = passwordConfirm.getEditableText().toString();
|
String confirm = passwordConfirm.getEditableText().toString();
|
||||||
|
|
||||||
boolean canSave = !password.isEmpty() && !confirm.isEmpty() && password.equals(confirm);
|
boolean canSave = !password.isEmpty() && !confirm.isEmpty() && password.equals(confirm);
|
||||||
btnSave.setEnabled(canSave);
|
btnSave.setEnabled(canSave);
|
||||||
} else {
|
} 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;
|
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;
|
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();
|
passwordInput.requestFocus();
|
||||||
UIHelper.showKeyboard(getContext(), passwordInput);
|
UIHelper.showKeyboard(getContext(), passwordInput);
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
android:autofillHints="password" />
|
android:autofillHints="password" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/toShortWarning"
|
android:id="@+id/tooShortWarning"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="@dimen/activity_margin"
|
android:paddingBottom="@dimen/activity_margin"
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
android:inputType="textPassword" />
|
android:inputType="textPassword" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/toShortWarning"
|
android:id="@+id/tooShortWarning"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
|
Loading…
Reference in a new issue