launching the edit selection from the ftue variant entry point

This commit is contained in:
Adam Brown 2022-03-31 16:33:09 +01:00
parent 985dbfe97d
commit 51c294a6fc
5 changed files with 24 additions and 20 deletions

View file

@ -37,6 +37,7 @@ sealed class OnboardingViewEvents : VectorViewEvents {
object OpenUseCaseSelection : OnboardingViewEvents() object OpenUseCaseSelection : OnboardingViewEvents()
object OpenServerSelection : OnboardingViewEvents() object OpenServerSelection : OnboardingViewEvents()
object OpenCombinedRegister : OnboardingViewEvents() object OpenCombinedRegister : OnboardingViewEvents()
object EditServerSelection : OnboardingViewEvents()
data class OnServerSelectionDone(val serverType: ServerType) : OnboardingViewEvents() data class OnServerSelectionDone(val serverType: ServerType) : OnboardingViewEvents()
object OnLoginFlowRetrieved : OnboardingViewEvents() object OnLoginFlowRetrieved : OnboardingViewEvents()
data class OnSignModeSelected(val signMode: SignMode) : OnboardingViewEvents() data class OnSignModeSelected(val signMode: SignMode) : OnboardingViewEvents()

View file

@ -646,19 +646,17 @@ class OnboardingViewModel @AssistedInject constructor(
else -> LoginMode.Unsupported else -> LoginMode.Unsupported
} }
val serverSelection = ServerSelectionState(
description = when (data.homeServerUrl) {
matrixOrgUrl -> stringProvider.getString(R.string.ftue_auth_create_account_matrix_dot_org_server_description)
else -> null
},
userUrlInput = homeServerConnectionConfig.homeServerUri.toString(),
hostedUrl = data.homeServerUrl
)
setState { setState {
copy( copy(
serverSelectionState = serverSelectionState.copy(
description = when (data.homeServerUrl) {
matrixOrgUrl -> stringProvider.getString(R.string.ftue_auth_create_account_matrix_dot_org_server_description)
else -> null
},
userUrlInput = homeServerConnectionConfig.homeServerUri.toString(),
hostedUrl = data.homeServerUrl
),
isLoading = false, isLoading = false,
serverSelectionState = serverSelection,
loginMode = loginMode, loginMode = loginMode,
loginModeSupportedTypes = data.supportedLoginTypes.toList() loginModeSupportedTypes = data.supportedLoginTypes.toList()
) )

View file

@ -22,7 +22,6 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import androidx.appcompat.app.AppCompatActivity
import androidx.autofill.HintConstants import androidx.autofill.HintConstants
import androidx.core.text.isDigitsOnly import androidx.core.text.isDigitsOnly
import androidx.core.view.isVisible import androidx.core.view.isVisible
@ -30,8 +29,6 @@ import androidx.lifecycle.lifecycleScope
import com.airbnb.mvrx.withState import com.airbnb.mvrx.withState
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.extensions.addFragment
import im.vector.app.core.extensions.commitTransaction
import im.vector.app.core.extensions.content import im.vector.app.core.extensions.content
import im.vector.app.core.extensions.editText import im.vector.app.core.extensions.editText
import im.vector.app.core.extensions.hasContentFlow import im.vector.app.core.extensions.hasContentFlow
@ -39,7 +36,6 @@ import im.vector.app.core.extensions.hasSurroundingSpaces
import im.vector.app.core.extensions.hideKeyboard import im.vector.app.core.extensions.hideKeyboard
import im.vector.app.core.extensions.hidePassword import im.vector.app.core.extensions.hidePassword
import im.vector.app.core.extensions.realignPercentagesToParent import im.vector.app.core.extensions.realignPercentagesToParent
import im.vector.app.core.extensions.toMvRxBundle
import im.vector.app.core.extensions.toReducedUrl import im.vector.app.core.extensions.toReducedUrl
import im.vector.app.databinding.FragmentFtueSignUpCombinedBinding import im.vector.app.databinding.FragmentFtueSignUpCombinedBinding
import im.vector.app.features.login.LoginMode import im.vector.app.features.login.LoginMode
@ -47,6 +43,7 @@ import im.vector.app.features.login.SSORedirectRouterActivity
import im.vector.app.features.login.ServerType import im.vector.app.features.login.ServerType
import im.vector.app.features.login.SocialLoginButtonsView import im.vector.app.features.login.SocialLoginButtonsView
import im.vector.app.features.onboarding.OnboardingAction import im.vector.app.features.onboarding.OnboardingAction
import im.vector.app.features.onboarding.OnboardingViewEvents
import im.vector.app.features.onboarding.OnboardingViewState import im.vector.app.features.onboarding.OnboardingViewState
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
@ -69,13 +66,9 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setupSubmitButton() setupSubmitButton()
views.createAccountRoot.realignPercentagesToParent() views.createAccountRoot.realignPercentagesToParent()
views.editServerButton.debouncedClicks { views.editServerButton.debouncedClicks {
requireActivity().supportFragmentManager.commitTransaction(true) { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection))
add(R.id.loginFragmentContainer, FtueAuthCombinedServerSelectionFragment(), null)
}
} }
views.createAccountPasswordInput.editText().setOnEditorActionListener { _, actionId, _ -> views.createAccountPasswordInput.editText().setOnEditorActionListener { _, actionId, _ ->

View file

@ -20,6 +20,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import im.vector.app.core.extensions.content
import im.vector.app.core.extensions.editText import im.vector.app.core.extensions.editText
import im.vector.app.core.extensions.realignPercentagesToParent import im.vector.app.core.extensions.realignPercentagesToParent
import im.vector.app.core.extensions.toReducedUrl import im.vector.app.core.extensions.toReducedUrl
@ -29,7 +30,7 @@ import im.vector.app.features.onboarding.OnboardingViewEvents
import im.vector.app.features.onboarding.OnboardingViewState import im.vector.app.features.onboarding.OnboardingViewState
import javax.inject.Inject import javax.inject.Inject
class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractSSOFtueAuthFragment<FragmentFtueServerSelectionCombinedBinding>() { class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueServerSelectionCombinedBinding>() {
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueServerSelectionCombinedBinding { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueServerSelectionCombinedBinding {
return FragmentFtueServerSelectionCombinedBinding.inflate(inflater, container, false) return FragmentFtueServerSelectionCombinedBinding.inflate(inflater, container, false)
@ -42,6 +43,10 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractSS
views.chooseServerToolbar.setNavigationOnClickListener { views.chooseServerToolbar.setNavigationOnClickListener {
viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnBack)) viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnBack))
} }
views.chooseServerSubmit.debouncedClicks {
viewModel.handle(OnboardingAction.UpdateHomeServer(views.chooseServerInput.content()))
}
} }
override fun resetViewModel() { override fun resetViewModel() {

View file

@ -233,6 +233,13 @@ class FtueAuthVariant(
OnboardingViewEvents.OnChooseProfilePicture -> onChooseProfilePicture() OnboardingViewEvents.OnChooseProfilePicture -> onChooseProfilePicture()
OnboardingViewEvents.OnPersonalizationComplete -> onPersonalizationComplete() OnboardingViewEvents.OnPersonalizationComplete -> onPersonalizationComplete()
OnboardingViewEvents.OnBack -> activity.popBackstack() OnboardingViewEvents.OnBack -> activity.popBackstack()
OnboardingViewEvents.EditServerSelection -> {
activity.addFragmentToBackstack(
views.loginFragmentContainer,
FtueAuthCombinedServerSelectionFragment::class.java,
option = commonOption
)
}
} }
} }