diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupPassword2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupPassword2.kt index 0da00ee624..c67579e98d 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupPassword2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupPassword2.kt @@ -28,7 +28,6 @@ import im.vector.app.R import im.vector.app.core.extensions.hideKeyboard import im.vector.app.core.extensions.showPassword import im.vector.app.databinding.FragmentLoginSignupPassword2Binding -import io.reactivex.rxkotlin.Observables import io.reactivex.rxkotlin.subscribeBy import javax.inject.Inject @@ -38,7 +37,7 @@ import javax.inject.Inject */ class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment2() { - private var passwordsShown = false + private var passwordShown = false override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginSignupPassword2Binding { return FragmentLoginSignupPassword2Binding.inflate(inflater, container, false) @@ -51,7 +50,7 @@ class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment setupAutoFill() setupPasswordReveal() - views.passwordFieldRepeat.setOnEditorActionListener { _, actionId, _ -> + views.passwordField.setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_DONE) { submit() return@setOnEditorActionListener true @@ -63,7 +62,6 @@ class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment private fun setupAutoFill() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { views.passwordField.setAutofillHints(HintConstants.AUTOFILL_HINT_NEW_PASSWORD) - views.passwordFieldRepeat.setAutofillHints(HintConstants.AUTOFILL_HINT_NEW_PASSWORD) } } @@ -79,13 +77,6 @@ class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment error++ } - val passwordRepeat = views.passwordFieldRepeat.text.toString() - - if (password != passwordRepeat) { - views.passwordFieldTilRepeat.error = getString(R.string.auth_password_dont_match) - error++ - } - if (error == 0) { loginViewModel.handle(LoginAction2.SetUserPassword(password)) } @@ -98,23 +89,19 @@ class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment private fun setupSubmitButton() { views.loginSubmit.setOnClickListener { submit() } - Observables.combineLatest( - views.passwordField.textChanges(), - views.passwordFieldRepeat.textChanges() - ) - .subscribeBy { (password, passwordRepeat) -> + views.passwordField.textChanges() + .subscribeBy { password -> views.passwordFieldTil.error = null - views.passwordFieldTilRepeat.error = null - views.loginSubmit.isEnabled = password.isNotEmpty() && passwordRepeat.isNotEmpty() + views.loginSubmit.isEnabled = password.isNotEmpty() } .disposeOnDestroyView() } private fun setupPasswordReveal() { - passwordsShown = false + passwordShown = false views.passwordReveal.setOnClickListener { - passwordsShown = !passwordsShown + passwordShown = !passwordShown renderPasswordField() } @@ -123,9 +110,8 @@ class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment } private fun renderPasswordField() { - views.passwordReveal.render(passwordsShown) - views.passwordField.showPassword(passwordsShown) - views.passwordFieldRepeat.showPassword(passwordsShown) + views.passwordReveal.render(passwordShown) + views.passwordField.showPassword(passwordShown) } override fun resetViewModel() { @@ -140,8 +126,8 @@ class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment views.loginMatrixIdentifier.text = state.userIdentifier() if (state.isLoading) { - // Ensure passwords are hidden - passwordsShown = false + // Ensure password is hidden + passwordShown = false renderPasswordField() } } diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginResetPasswordFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginResetPasswordFragment2.kt index 62cfd416bb..c37c5ee44f 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginResetPasswordFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginResetPasswordFragment2.kt @@ -42,7 +42,7 @@ import javax.inject.Inject */ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2() { - private var passwordsShown = false + private var passwordShown = false // Show warning only once private var showWarning = true @@ -58,9 +58,9 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 setupPasswordReveal() setupAutoFill() - autoResetTextInputLayoutErrors(listOf(views.resetPasswordEmailTil, views.passwordFieldTil, views.passwordFieldTilRepeat)) + autoResetTextInputLayoutErrors(listOf(views.resetPasswordEmailTil, views.passwordFieldTil)) - views.passwordFieldRepeat.setOnEditorActionListener { _, actionId, _ -> + views.passwordField.setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_DONE) { submit() return@setOnEditorActionListener true @@ -73,7 +73,6 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { views.resetPasswordEmail.setAutofillHints(HintConstants.AUTOFILL_HINT_EMAIL_ADDRESS) views.passwordField.setAutofillHints(HintConstants.AUTOFILL_HINT_NEW_PASSWORD) - views.passwordFieldRepeat.setAutofillHints(HintConstants.AUTOFILL_HINT_NEW_PASSWORD) } } @@ -105,7 +104,6 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 val email = views.resetPasswordEmail.text.toString() val password = views.passwordField.text.toString() - val passwordRepeat = views.passwordFieldRepeat.text.toString() if (email.isEmpty()) { views.resetPasswordEmailTil.error = getString(R.string.auth_reset_password_missing_email) @@ -115,9 +113,6 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 if (password.isEmpty()) { views.passwordFieldTil.error = getString(R.string.login_please_choose_a_new_password) error++ - } else if (password != passwordRepeat) { - views.passwordFieldTilRepeat.error = getString(R.string.auth_password_dont_match) - error++ } if (error > 0) { @@ -151,14 +146,13 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 views.resetPasswordSubmit.hideKeyboard() views.resetPasswordEmailTil.error = null views.passwordFieldTil.error = null - views.passwordFieldTilRepeat.error = null } private fun setupPasswordReveal() { - passwordsShown = false + passwordShown = false views.passwordReveal.setOnClickListener { - passwordsShown = !passwordsShown + passwordShown = !passwordShown renderPasswordField() } @@ -167,9 +161,8 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 } private fun renderPasswordField() { - views.passwordField.showPassword(passwordsShown) - views.passwordFieldRepeat.showPassword(passwordsShown) - views.passwordReveal.render(passwordsShown) + views.passwordField.showPassword(passwordShown) + views.passwordReveal.render(passwordShown) } override fun resetViewModel() { @@ -184,8 +177,8 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 setupUi(state) if (state.isLoading) { - // Ensure new passwords are hidden - passwordsShown = false + // Ensure new password is hidden + passwordShown = false renderPasswordField() } } diff --git a/vector/src/main/res/layout/fragment_login_reset_password_2.xml b/vector/src/main/res/layout/fragment_login_reset_password_2.xml index 61f3e52279..a103f9a5b7 100644 --- a/vector/src/main/res/layout/fragment_login_reset_password_2.xml +++ b/vector/src/main/res/layout/fragment_login_reset_password_2.xml @@ -57,73 +57,54 @@ android:text="@string/login_reset_password_notice" android:textAppearance="@style/TextAppearance.Vector.Login.Text.Small" /> + + + android:layout_marginTop="8dp"> - + android:hint="@string/login_reset_password_password_hint" + app:errorEnabled="true" + app:errorIconDrawable="@null"> + + + + - - - - - - - - - - - - + + + android:layout_marginTop="8dp"> - + android:hint="@string/login_signup_password_hint" + app:errorEnabled="true" + app:errorIconDrawable="@null"> + + + + - - - - - - - - - - - - - - Type it again Welcome back %s! Please enter your password Please enter your Matrix identifier