mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-11 17:33:46 +01:00
hiding username/password fields when the homeserver doesn't support them and showing SSO options when available
This commit is contained in:
parent
bc2a99c3cf
commit
137fe89938
@ -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<SsoIdentityProvider>?) {
|
||||
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)
|
||||
|
@ -128,6 +128,13 @@
|
||||
app:layout_constraintStart_toStartOf="@id/loginGutterStart"
|
||||
app:layout_constraintTop_toTopOf="@id/serverSelectionSpacing" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/loginEntryGroup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
app:constraint_referenced_ids="loginInput,loginPasswordInput,entrySpacing,actionSpacing,loginSubmit" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/loginInput"
|
||||
style="@style/Widget.Vector.TextInputLayout.Username"
|
||||
|
Loading…
Reference in New Issue
Block a user