From d235d1be154eac5f7141b5333a27578d0e0bb3ac Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 16 Apr 2021 12:48:10 +0200 Subject: [PATCH] More improvements --- .../login2/LoginFragmentSignupPassword2.kt | 2 +- .../login2/LoginFragmentSignupUsername2.kt | 6 +- .../features/login2/LoginFragmentToAny2.kt | 4 ++ .../login2/LoginResetPasswordFragment2.kt | 26 ++++++- .../login2/LoginServerSelectionFragment2.kt | 21 ++++-- .../login2/terms/LoginTermsFragment2.kt | 8 +-- .../fragment_login_server_selection_2.xml | 8 +-- .../res/layout/fragment_login_terms_2.xml | 68 +++++++++++++++++++ .../src/main/res/values/strings_login_v2.xml | 3 + 9 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 vector/src/main/res/layout/fragment_login_terms_2.xml 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 49f4a4efc0..0da00ee624 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 @@ -36,7 +36,7 @@ import javax.inject.Inject * In this screen: * - the user is asked to choose a password to sign up to a homeserver. */ -class LoginFragmentSignupPassword2 @Inject constructor() : AbstractSSOLoginFragment2() { +class LoginFragmentSignupPassword2 @Inject constructor() : AbstractLoginFragment2() { private var passwordsShown = false diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupUsername2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupUsername2.kt index 9726d8b163..9a4f0780c5 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupUsername2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginFragmentSignupUsername2.kt @@ -55,6 +55,7 @@ class LoginFragmentSignupUsername2 @Inject constructor() : AbstractSSOLoginFragm setupSubmitButton() setupAutoFill() + setupSocialLoginButtons() } private fun setupAutoFill() { @@ -63,6 +64,10 @@ class LoginFragmentSignupUsername2 @Inject constructor() : AbstractSSOLoginFragm } } + private fun setupSocialLoginButtons() { + views.loginSocialLoginButtons.mode = SocialLoginButtonsView.Mode.MODE_SIGN_UP + } + private fun submit() { cleanupUi() @@ -111,7 +116,6 @@ class LoginFragmentSignupUsername2 @Inject constructor() : AbstractSSOLoginFragm } } - @SuppressLint("SetTextI18n") private fun setupSubmitButton() { views.loginSubmit.setOnClickListener { submit() } views.loginField.textChanges() diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginFragmentToAny2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginFragmentToAny2.kt index ab5e3f15b8..0f62b96d0f 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginFragmentToAny2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginFragmentToAny2.kt @@ -66,6 +66,7 @@ class LoginFragmentToAny2 @Inject constructor() : AbstractSSOLoginFragment2 if (actionId == EditorInfo.IME_ACTION_DONE) { @@ -85,6 +86,9 @@ class LoginFragmentToAny2 @Inject constructor() : AbstractSSOLoginFragment2 + if (actionId == EditorInfo.IME_ACTION_DONE) { + submit() + return@setOnEditorActionListener true + } + return@setOnEditorActionListener false + } } private fun setupAutoFill() { @@ -81,8 +93,6 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 } ) .subscribeBy { - views.resetPasswordEmailTil.error = null - views.passwordFieldTil.error = null views.resetPasswordSubmit.isEnabled = it } .disposeOnDestroyView() @@ -92,10 +102,20 @@ class LoginResetPasswordFragment2 @Inject constructor() : AbstractLoginFragment2 cleanupUi() var error = 0 + + val email = views.resetPasswordEmail.text.toString() val password = views.passwordField.text.toString() val passwordRepeat = views.passwordFieldRepeat.text.toString() - if (password != passwordRepeat) { + if (email.isEmpty()) { + views.resetPasswordEmailTil.error = getString(R.string.auth_reset_password_missing_email) + error++ + } + + 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++ } diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt index b7a5d64cd4..3343abbdde 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginServerSelectionFragment2.kt @@ -16,11 +16,11 @@ package im.vector.app.features.login2 -import android.annotation.SuppressLint import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import im.vector.app.R import im.vector.app.databinding.FragmentLoginServerSelection2Binding import javax.inject.Inject @@ -44,27 +44,34 @@ class LoginServerSelectionFragment2 @Inject constructor() : AbstractLoginFragmen views.loginServerChoiceOther.setOnClickListener { selectOther() } } - @SuppressLint("SetTextI18n") private fun updateUi(state: LoginViewState2) { when (state.signMode) { - SignMode2.Unknown -> Unit - SignMode2.SignUp -> { - views.loginServerTitle.text = "Please choose a server" + SignMode2.Unknown -> Unit + SignMode2.SignUp -> { + views.loginServerTitle.setText(R.string.login_please_choose_a_server) } - SignMode2.SignIn -> { - views.loginServerTitle.text = "Please choose your server" + SignMode2.SignIn -> { + views.loginServerTitle.setText(R.string.login_please_select_your_server) } } } private fun selectMatrixOrg() { + views.loginServerChoiceMatrixOrg.isChecked = true loginViewModel.handle(LoginAction2.ChooseDefaultHomeServer) } private fun selectOther() { + views.loginServerChoiceOther.isChecked = true loginViewModel.handle(LoginAction2.EnterServerUrl) } + override fun onResume() { + super.onResume() + views.loginServerChoiceMatrixOrg.isChecked = false + views.loginServerChoiceOther.isChecked = false + } + override fun resetViewModel() { loginViewModel.handle(LoginAction2.ResetHomeServerUrl) } diff --git a/vector/src/main/java/im/vector/app/features/login2/terms/LoginTermsFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/terms/LoginTermsFragment2.kt index fcd3268983..0be696e1c8 100755 --- a/vector/src/main/java/im/vector/app/features/login2/terms/LoginTermsFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/terms/LoginTermsFragment2.kt @@ -25,7 +25,7 @@ import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.extensions.toReducedUrl import im.vector.app.core.utils.openUrlInChromeCustomTab -import im.vector.app.databinding.FragmentLoginTermsBinding +import im.vector.app.databinding.FragmentLoginTerms2Binding import im.vector.app.features.login.terms.LocalizedFlowDataLoginTermsChecked import im.vector.app.features.login.terms.LoginTermsFragmentArgument import im.vector.app.features.login.terms.LoginTermsViewState @@ -41,13 +41,13 @@ import javax.inject.Inject */ class LoginTermsFragment2 @Inject constructor( private val policyController: PolicyController -) : AbstractLoginFragment2(), +) : AbstractLoginFragment2(), PolicyController.PolicyControllerListener { private val params: LoginTermsFragmentArgument by args() - override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginTermsBinding { - return FragmentLoginTermsBinding.inflate(inflater, container, false) + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginTerms2Binding { + return FragmentLoginTerms2Binding.inflate(inflater, container, false) } private var loginTermsViewState: LoginTermsViewState = LoginTermsViewState(emptyList()) diff --git a/vector/src/main/res/layout/fragment_login_server_selection_2.xml b/vector/src/main/res/layout/fragment_login_server_selection_2.xml index 245459ef9d..1a7d5a14c5 100644 --- a/vector/src/main/res/layout/fragment_login_server_selection_2.xml +++ b/vector/src/main/res/layout/fragment_login_server_selection_2.xml @@ -19,9 +19,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/layout_vertical_margin" + android:text="@string/login_please_choose_a_server" android:textAppearance="@style/TextAppearance.Vector.Login.Title" - tools:ignore="UnknownId" - tools:text="Please choose a server" /> + tools:ignore="UnknownId" /> - - + diff --git a/vector/src/main/res/layout/fragment_login_terms_2.xml b/vector/src/main/res/layout/fragment_login_terms_2.xml new file mode 100644 index 0000000000..d6ccfbba87 --- /dev/null +++ b/vector/src/main/res/layout/fragment_login_terms_2.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + diff --git a/vector/src/main/res/values/strings_login_v2.xml b/vector/src/main/res/values/strings_login_v2.xml index 23cc578ebd..aa4d2e1192 100644 --- a/vector/src/main/res/values/strings_login_v2.xml +++ b/vector/src/main/res/values/strings_login_v2.xml @@ -10,7 +10,10 @@ Matrix identifiers start with @, for instance @alice:server.org If you do not know your Matrix identifier, or if your account has been created using Single Sign On (for instance using a Google account), or if you want to connect using your simple name, or an email associated to your account, you have to select your server first. Choose a server + Please choose a server + Please select your server Please choose a password + Please choose a new password Your Matrix identifier Press back to change Choose a password