From ca4e75a1a0b24765bd3fbc6d71d6092f92bce50c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 15 Nov 2019 14:39:09 +0100 Subject: [PATCH] Login screens: Fix a few bugs --- .../im/vector/riotx/core/di/FragmentModule.kt | 30 ++++++++++++++++--- .../login/LoginResetPasswordFragment.kt | 2 +- .../LoginSignUpSignInSelectionFragment.kt | 5 ++-- .../riotx/features/login/LoginViewModel.kt | 7 ++++- vector/src/main/res/layout/fragment_login.xml | 5 +++- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt index d788f4c04c..37ce9583b8 100644 --- a/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt @@ -35,9 +35,7 @@ import im.vector.riotx.features.home.createdirect.CreateDirectRoomKnownUsersFrag import im.vector.riotx.features.home.group.GroupListFragment import im.vector.riotx.features.home.room.detail.RoomDetailFragment import im.vector.riotx.features.home.room.list.RoomListFragment -import im.vector.riotx.features.login.LoginFragment -import im.vector.riotx.features.login.LoginServerUrlFormFragment -import im.vector.riotx.features.login.LoginWebFragment +import im.vector.riotx.features.login.* import im.vector.riotx.features.reactions.EmojiSearchResultFragment import im.vector.riotx.features.roomdirectory.PublicRoomsFragment import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment @@ -116,12 +114,36 @@ interface FragmentModule { @FragmentKey(LoginFragment::class) fun bindLoginFragment(fragment: LoginFragment): Fragment - // TODO Add all other Login Fragments @Binds @IntoMap @FragmentKey(LoginServerUrlFormFragment::class) fun bindLoginServerUrlFormFragment(fragment: LoginServerUrlFormFragment): Fragment + @Binds + @IntoMap + @FragmentKey(LoginResetPasswordFragment::class) + fun bindLoginResetPasswordFragment(fragment: LoginResetPasswordFragment): Fragment + + @Binds + @IntoMap + @FragmentKey(LoginResetPasswordSuccessFragment::class) + fun bindLoginResetPasswordSuccessFragment(fragment: LoginResetPasswordSuccessFragment): Fragment + + @Binds + @IntoMap + @FragmentKey(LoginServerSelectionFragment::class) + fun bindLoginServerSelectionFragment(fragment: LoginServerSelectionFragment): Fragment + + @Binds + @IntoMap + @FragmentKey(LoginSignUpSignInSelectionFragment::class) + fun bindLoginSignUpSignInSelectionFragment(fragment: LoginSignUpSignInSelectionFragment): Fragment + + @Binds + @IntoMap + @FragmentKey(LoginSplashFragment::class) + fun bindLoginSplashFragment(fragment: LoginSplashFragment): Fragment + @Binds @IntoMap @FragmentKey(LoginWebFragment::class) diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginResetPasswordFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginResetPasswordFragment.kt index 600013c5ba..045e60e364 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginResetPasswordFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginResetPasswordFragment.kt @@ -71,7 +71,7 @@ class LoginResetPasswordFragment @Inject constructor( .subscribeBy { resetPasswordEmail.error = null passwordFieldTil.error = null - loginSubmit.isEnabled = it + resetPasswordSubmit.isEnabled = it } .disposeOnDestroy() diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginSignUpSignInSelectionFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginSignUpSignInSelectionFragment.kt index cdb9aa8b7a..ec59f95874 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginSignUpSignInSelectionFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginSignUpSignInSelectionFragment.kt @@ -48,13 +48,14 @@ class LoginSignUpSignInSelectionFragment @Inject constructor() : AbstractLoginFr ServerType.Modular -> { loginSignupSigninServerIcon.setImageResource(R.drawable.ic_logo_modular) loginSignupSigninServerIcon.isVisible = true + // TODO loginSignupSigninTitle.text = getString(R.string.login_connect_to, "TODO MODULAR NAME") - loginSignupSigninText.text = "TODO MODULAR URL" + loginSignupSigninText.text = loginViewModel.getHomeServerUrlSimple() } ServerType.Other -> { loginSignupSigninServerIcon.isVisible = false loginSignupSigninTitle.text = getString(R.string.login_server_other_title) - loginSignupSigninText.text = "TODO SERVER URL" + loginSignupSigninText.text = getString(R.string.login_connect_to, loginViewModel.getHomeServerUrlSimple()) } } } diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt index ac8362eb31..abaa00283f 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt @@ -309,7 +309,12 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi return homeServerConnectionConfig?.homeServerUri?.toString() ?: "" } + /** + * Ex: "https://matrix.org/" -> "matrix.org" + */ fun getHomeServerUrlSimple(): String { - return getHomeServerUrl().substringAfter("://") + return getHomeServerUrl() + .substringAfter("://") + .trim { it == '/' } } } diff --git a/vector/src/main/res/layout/fragment_login.xml b/vector/src/main/res/layout/fragment_login.xml index 708afd6943..7eef66272f 100644 --- a/vector/src/main/res/layout/fragment_login.xml +++ b/vector/src/main/res/layout/fragment_login.xml @@ -25,11 +25,14 @@ style="@style/LoginTopIcon" android:layout_gravity="center_horizontal" /> + +