From 9d97832e8c11021c29264a6c718eabd26734bb19 Mon Sep 17 00:00:00 2001 From: Joshua Soberg Date: Sat, 5 Sep 2020 12:49:53 -0400 Subject: [PATCH] #638 - Convert IntoScreenActivity to use the password confirmation method utility --- .../Activities/IntroScreenActivity.java | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/IntroScreenActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/IntroScreenActivity.java index 31724ea9..28cbf504 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/IntroScreenActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/IntroScreenActivity.java @@ -54,6 +54,7 @@ import com.heinrichreimersoftware.materialintro.slide.FragmentSlide; import com.heinrichreimersoftware.materialintro.slide.SimpleSlide; import org.shadowice.flocke.andotp.R; +import org.shadowice.flocke.andotp.Utilities.ConfirmedPasswordTransformationHelper; import org.shadowice.flocke.andotp.Utilities.Constants; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.UIHelper; @@ -380,7 +381,7 @@ public class IntroScreenActivity extends IntroActivity { passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwordConfirm.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); - setPasswordTransformationMethod(); + ConfirmedPasswordTransformationHelper.setup(passwordLayout, passwordInput, passwordConfirm); minLength = Constants.AUTH_MIN_PASSWORD_LENGTH; lengthWarning = getString(R.string.settings_label_short_password, minLength); @@ -390,33 +391,6 @@ public class IntroScreenActivity extends IntroActivity { focusOnPasswordInput(); } - private void setPasswordTransformationMethod() { - passwordLayout.setEndIconOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean wasShowingPassword = passwordInput.getTransformationMethod() instanceof PasswordTransformationMethod; - // Dispatch password visibility change to both password and confirm inputs - dispatchPasswordVisibilityChange(passwordInput, wasShowingPassword); - dispatchPasswordVisibilityChange(passwordConfirm, wasShowingPassword); - passwordLayout.refreshDrawableState(); - } - }); - passwordInput.setTransformationMethod(PasswordTransformationMethod.getInstance()); - passwordConfirm.setTransformationMethod(PasswordTransformationMethod.getInstance()); - } - - private void dispatchPasswordVisibilityChange(EditText editText, boolean wasShowingPassword) { - final int selection = editText.getSelectionEnd(); - if (wasShowingPassword) { - editText.setTransformationMethod(null); - } else { - editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); - } - if (selection >= 0) { - editText.setSelection(selection); - } - } - private void focusOnPasswordInput() { if (getIntroActivity().getCurrentSlidePosition() == slidePos) { passwordInput.requestFocus(); @@ -433,7 +407,7 @@ public class IntroScreenActivity extends IntroActivity { passwordInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); passwordConfirm.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); - setPasswordTransformationMethod(); + ConfirmedPasswordTransformationHelper.setup(passwordLayout, passwordInput, passwordConfirm); minLength = Constants.AUTH_MIN_PIN_LENGTH; lengthWarning = getString(R.string.settings_label_short_pin, minLength);