mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
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:
parent
c66b1885ad
commit
f6070ee9ca
@ -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 -> {
|
||||
|
@ -101,6 +101,7 @@ data class SelectedAuthenticationState(
|
||||
|
||||
@Parcelize
|
||||
data class RegistrationState(
|
||||
val email: String? = null,
|
||||
val isUserNameAvailable: Boolean = false,
|
||||
val selectedMatrixId: String? = null,
|
||||
) : Parcelable
|
||||
|
@ -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) {
|
||||
|
@ -414,16 +414,18 @@ 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(
|
||||
FtueAuthLegacyWaitForEmailFragment::class.java,
|
||||
FtueAuthWaitForEmailFragmentArgument(email, isRestoredSession),
|
||||
)
|
||||
else -> {
|
||||
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||
addRegistrationStageFragmentToBackstack(
|
||||
FtueAuthLegacyWaitForEmailFragment::class.java,
|
||||
FtueAuthWaitForEmailFragmentArgument(email, isRestoredSession),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user