Improve confirm password functionality

This commit is contained in:
Michael Schättgen 2020-03-03 23:43:33 +01:00
parent 1a7a794dc9
commit d39e3d7b90
2 changed files with 10 additions and 8 deletions

View file

@ -93,11 +93,12 @@ public class Dialogs {
switchToggleVisibility.setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener) (buttonView, isChecked) -> {
if (isChecked) {
textPassword.setTransformationMethod(null);
textPasswordConfirm.setTransformationMethod(null);
textPassword.clearFocus();
textPasswordConfirm.setEnabled(false);
textPasswordConfirm.clearFocus();
} else {
textPassword.setTransformationMethod(new PasswordTransformationMethod());
textPasswordConfirm.setEnabled(true);
textPasswordConfirm.setTransformationMethod(new PasswordTransformationMethod());
}
});
@ -116,7 +117,7 @@ public class Dialogs {
// replace the default listener
button.setOnClickListener(v -> {
if (!EditTextHelper.areEditTextsEqual(textPassword, textPasswordConfirm) && !switchToggleVisibility.isChecked()) {
if (!EditTextHelper.areEditTextsEqual(textPassword, textPasswordConfirm)) {
return;
}
@ -141,7 +142,7 @@ public class Dialogs {
TextWatcher watcher = new TextWatcher() {
public void onTextChanged(CharSequence c, int start, int before, int count) {
boolean equal = EditTextHelper.areEditTextsEqual(textPassword, textPasswordConfirm);
buttonOK.get().setEnabled(equal || switchToggleVisibility.isChecked());
buttonOK.get().setEnabled(equal);
}
public void beforeTextChanged(CharSequence c, int start, int count, int after) {

View file

@ -45,11 +45,12 @@ public class CustomAuthenticatedSlide extends Fragment implements ISlidePolicy,
_checkPasswordVisibility.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
_textPassword.setTransformationMethod(null);
_textPasswordConfirm.setTransformationMethod(null);
_textPassword.clearFocus();
_textPasswordConfirm.setEnabled(false);
_textPasswordConfirm.clearFocus();
} else {
_textPassword.setTransformationMethod(new PasswordTransformationMethod());
_textPasswordConfirm.setEnabled(true);
_textPasswordConfirm.setTransformationMethod(new PasswordTransformationMethod());
}
});
@ -113,7 +114,7 @@ public class CustomAuthenticatedSlide extends Fragment implements ISlidePolicy,
// intentional fallthrough
case CustomAuthenticationSlide.CRYPT_TYPE_PASS:
if (EditTextHelper.getEditTextChars(_textPassword).length > 0) {
return EditTextHelper.areEditTextsEqual(_textPassword, _textPasswordConfirm) || _checkPasswordVisibility.isChecked();
return EditTextHelper.areEditTextsEqual(_textPassword, _textPasswordConfirm);
}
return false;
@ -125,7 +126,7 @@ public class CustomAuthenticatedSlide extends Fragment implements ISlidePolicy,
@Override
public void onUserIllegallyRequestedNextPage() {
String message;
if (!EditTextHelper.areEditTextsEqual(_textPassword, _textPasswordConfirm) && !_checkPasswordVisibility.isChecked()) {
if (!EditTextHelper.areEditTextsEqual(_textPassword, _textPasswordConfirm)) {
message = getString(R.string.password_equality_error);
View view = getView();