#638 - Convert IntoScreenActivity to use the password confirmation method utility
This commit is contained in:
parent
30bd3f61e8
commit
9d97832e8c
1 changed files with 3 additions and 29 deletions
|
@ -54,6 +54,7 @@ import com.heinrichreimersoftware.materialintro.slide.FragmentSlide;
|
||||||
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
|
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
|
||||||
|
|
||||||
import org.shadowice.flocke.andotp.R;
|
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.Constants;
|
||||||
import org.shadowice.flocke.andotp.Utilities.Settings;
|
import org.shadowice.flocke.andotp.Utilities.Settings;
|
||||||
import org.shadowice.flocke.andotp.Utilities.UIHelper;
|
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);
|
passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
passwordConfirm.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;
|
minLength = Constants.AUTH_MIN_PASSWORD_LENGTH;
|
||||||
lengthWarning = getString(R.string.settings_label_short_password, minLength);
|
lengthWarning = getString(R.string.settings_label_short_password, minLength);
|
||||||
|
@ -390,33 +391,6 @@ public class IntroScreenActivity extends IntroActivity {
|
||||||
focusOnPasswordInput();
|
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() {
|
private void focusOnPasswordInput() {
|
||||||
if (getIntroActivity().getCurrentSlidePosition() == slidePos) {
|
if (getIntroActivity().getCurrentSlidePosition() == slidePos) {
|
||||||
passwordInput.requestFocus();
|
passwordInput.requestFocus();
|
||||||
|
@ -433,7 +407,7 @@ public class IntroScreenActivity extends IntroActivity {
|
||||||
passwordInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
|
passwordInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
|
||||||
passwordConfirm.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;
|
minLength = Constants.AUTH_MIN_PIN_LENGTH;
|
||||||
lengthWarning = getString(R.string.settings_label_short_pin, minLength);
|
lengthWarning = getString(R.string.settings_label_short_pin, minLength);
|
||||||
|
|
Loading…
Reference in a new issue