From 9b266c88d284572ab62ebc799a7a158b1093cdbe Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 16 May 2022 15:52:24 +0100 Subject: [PATCH] hiding username/password fields when the homeserver doesn't support them and showing SSO options when available --- .../ftueauth/FtueAuthCombinedLoginFragment.kt | 23 +++++++++++++++++-- .../layout/fragment_ftue_combined_login.xml | 7 ++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt index 34c8c6c8b5a..973570f7508 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthCombinedLoginFragment.kt @@ -112,13 +112,24 @@ class FtueAuthCombinedLoginFragment @Inject constructor( private fun setupUi(state: OnboardingViewState) { when (state.selectedHomeserver.preferredLoginMode) { - is LoginMode.SsoAndPassword -> renderSsoProviders(state.deviceId, state.selectedHomeserver.preferredLoginMode.ssoIdentityProviders) - else -> hideSsoProviders() + is LoginMode.SsoAndPassword -> { + showUsernamePassword() + renderSsoProviders(state.deviceId, state.selectedHomeserver.preferredLoginMode.ssoIdentityProviders) + } + is LoginMode.Sso -> { + hideUsernamePassword() + renderSsoProviders(state.deviceId, state.selectedHomeserver.preferredLoginMode.ssoIdentityProviders) + } + else -> { + showUsernamePassword() + hideSsoProviders() + } } } private fun renderSsoProviders(deviceId: String?, ssoProviders: List?) { views.ssoGroup.isVisible = ssoProviders?.isNotEmpty() == true + views.ssoButtonsHeader.isVisible = views.ssoGroup.isVisible && views.loginEntryGroup.isVisible views.ssoButtons.render(ssoProviders, SocialLoginButtonsView.Mode.MODE_CONTINUE) { id -> viewModel.getSsoUrl( redirectUrl = SSORedirectRouterActivity.VECTOR_REDIRECT_URL, @@ -133,6 +144,14 @@ class FtueAuthCombinedLoginFragment @Inject constructor( views.ssoButtons.ssoIdentityProviders = null } + private fun hideUsernamePassword() { + views.loginEntryGroup.isVisible = false + } + + private fun showUsernamePassword() { + views.loginEntryGroup.isVisible = true + } + private fun setupAutoFill() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { views.loginInput.setAutofillHints(HintConstants.AUTOFILL_HINT_NEW_USERNAME) diff --git a/vector/src/main/res/layout/fragment_ftue_combined_login.xml b/vector/src/main/res/layout/fragment_ftue_combined_login.xml index 992e5c77b53..1b65056e9f4 100644 --- a/vector/src/main/res/layout/fragment_ftue_combined_login.xml +++ b/vector/src/main/res/layout/fragment_ftue_combined_login.xml @@ -128,6 +128,13 @@ app:layout_constraintStart_toStartOf="@id/loginGutterStart" app:layout_constraintTop_toTopOf="@id/serverSelectionSpacing" /> + +