allowing the user to edit their email address after starting the verfication process

- the email verification screen is no longer a hard exit during the standard account creation flow, however if a authentication session is restored eg the app is killed and reopened whilst waiting for email verifcation, then pressing back will cause the flow to be restarted
This commit is contained in:
Adam Brown 2022-07-26 11:57:03 +01:00
parent c66b1885ad
commit f6070ee9ca
5 changed files with 26 additions and 9 deletions

View File

@ -348,9 +348,10 @@ class OnboardingViewModel @AssistedInject constructor(
overrideNextStage?.invoke() ?: _viewEvents.post(OnboardingViewEvents.DisplayStartRegistration)
}
RegistrationActionHandler.Result.UnsupportedStage -> _viewEvents.post(OnboardingViewEvents.DisplayRegistrationFallback)
is RegistrationActionHandler.Result.SendEmailSuccess -> _viewEvents.post(
OnboardingViewEvents.OnSendEmailSuccess(it.email, isRestoredSession = false)
)
is RegistrationActionHandler.Result.SendEmailSuccess -> {
_viewEvents.post(OnboardingViewEvents.OnSendEmailSuccess(it.email, isRestoredSession = false))
setState { copy(registrationState = registrationState.copy(email = it.email)) }
}
is RegistrationActionHandler.Result.SendMsisdnSuccess -> _viewEvents.post(OnboardingViewEvents.OnSendMsisdnSuccess(it.msisdn.msisdn))
is RegistrationActionHandler.Result.Error -> _viewEvents.post(OnboardingViewEvents.Failure(it.cause))
RegistrationActionHandler.Result.MissingNextStage -> {

View File

@ -101,6 +101,7 @@ data class SelectedAuthenticationState(
@Parcelize
data class RegistrationState(
val email: String? = null,
val isUserNameAvailable: Boolean = false,
val selectedMatrixId: String? = null,
) : Parcelable

View File

@ -25,6 +25,8 @@ import im.vector.app.core.extensions.associateContentStateWith
import im.vector.app.core.extensions.autofillEmail
import im.vector.app.core.extensions.clearErrorOnChange
import im.vector.app.core.extensions.content
import im.vector.app.core.extensions.editText
import im.vector.app.core.extensions.hasContent
import im.vector.app.core.extensions.isEmail
import im.vector.app.core.extensions.setOnImeDoneListener
import im.vector.app.core.extensions.toReducedUrl
@ -61,6 +63,10 @@ class FtueAuthEmailEntryFragment @Inject constructor() : AbstractFtueAuthFragmen
override fun updateWithState(state: OnboardingViewState) {
views.emailEntryHeaderSubtitle.text = getString(R.string.ftue_auth_email_subtitle, state.selectedHomeserver.userFacingUrl.toReducedUrl())
if (!views.emailEntryInput.hasContent()) {
views.emailEntryInput.editText().setText(state.registrationState.email)
}
}
override fun onError(throwable: Throwable) {

View File

@ -414,18 +414,20 @@ class FtueAuthVariant(
}
private fun openWaitForEmailVerification(email: String, isRestoredSession: Boolean) {
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
when {
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> addRegistrationStageFragmentToBackstack(
FtueAuthWaitForEmailFragment::class.java,
FtueAuthWaitForEmailFragmentArgument(email, isRestoredSession),
)
else -> addRegistrationStageFragmentToBackstack(
else -> {
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
addRegistrationStageFragmentToBackstack(
FtueAuthLegacyWaitForEmailFragment::class.java,
FtueAuthWaitForEmailFragmentArgument(email, isRestoredSession),
)
}
}
}
private fun openMsisdnConfirmation(msisdn: String) {
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)

View File

@ -49,6 +49,8 @@ class FtueAuthWaitForEmailFragment @Inject constructor(
private val params: FtueAuthWaitForEmailFragmentArgument by args()
private var inferHasLeftAndReturnedToScreen = false
override fun backIsHardExit() = params.isRestoredSession
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueWaitForEmailVerificationBinding {
return FragmentFtueWaitForEmailVerificationBinding.inflate(inflater, container, false)
}
@ -89,6 +91,11 @@ class FtueAuthWaitForEmailFragment @Inject constructor(
}
override fun resetViewModel() {
viewModel.handle(OnboardingAction.ResetAuthenticationAttempt)
when {
backIsHardExit() -> viewModel.handle(OnboardingAction.ResetAuthenticationAttempt)
else -> {
// delegate to the previous step
}
}
}
}