From 02b6916487627f21eb287ab977e0a621f0687177 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 27 Apr 2022 16:28:13 +0100 Subject: [PATCH] adding UI for updated email verification waiting screen --- .../im/vector/app/core/di/FragmentModule.kt | 6 + .../FtueAuthLegacyWaitForEmailFragment.kt | 63 ++++++++ .../onboarding/ftueauth/FtueAuthVariant.kt | 21 ++- .../ftueauth/FtueAuthWaitForEmailFragment.kt | 13 +- ...gment_ftue_wait_for_email_verification.xml | 134 ++++++++++++++++++ vector/src/main/res/values/donottranslate.xml | 5 + 6 files changed, 228 insertions(+), 14 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthLegacyWaitForEmailFragment.kt create mode 100644 vector/src/main/res/layout/fragment_ftue_wait_for_email_verification.xml diff --git a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt index a9dcdc3700..3dba8b797b 100644 --- a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt @@ -104,6 +104,7 @@ import im.vector.app.features.onboarding.ftueauth.FtueAuthChooseProfilePictureFr import im.vector.app.features.onboarding.ftueauth.FtueAuthEmailEntryFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthGenericTextInputFormFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthLegacyStyleCaptchaFragment +import im.vector.app.features.onboarding.ftueauth.FtueAuthLegacyWaitForEmailFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthLoginFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthPersonalizationCompleteFragment import im.vector.app.features.onboarding.ftueauth.FtueAuthResetPasswordFragment @@ -475,6 +476,11 @@ interface FragmentModule { @FragmentKey(FtueAuthWaitForEmailFragment::class) fun bindFtueAuthWaitForEmailFragment(fragment: FtueAuthWaitForEmailFragment): Fragment + @Binds + @IntoMap + @FragmentKey(FtueAuthLegacyWaitForEmailFragment::class) + fun bindFtueAuthLegacyWaitForEmailFragment(fragment: FtueAuthLegacyWaitForEmailFragment): Fragment + @Binds @IntoMap @FragmentKey(FtueAuthWebFragment::class) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthLegacyWaitForEmailFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthLegacyWaitForEmailFragment.kt new file mode 100644 index 0000000000..04726edcd0 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthLegacyWaitForEmailFragment.kt @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.onboarding.ftueauth + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.airbnb.mvrx.args +import im.vector.app.R +import im.vector.app.databinding.FragmentLoginWaitForEmailBinding +import im.vector.app.features.onboarding.OnboardingAction +import im.vector.app.features.onboarding.RegisterAction +import javax.inject.Inject + +/** + * In this screen, the user is asked to check his emails + */ +class FtueAuthLegacyWaitForEmailFragment @Inject constructor() : AbstractFtueAuthFragment() { + + private val params: FtueAuthWaitForEmailFragmentArgument by args() + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginWaitForEmailBinding { + return FragmentLoginWaitForEmailBinding.inflate(inflater, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + setupUi() + } + + override fun onResume() { + super.onResume() + viewModel.handle(OnboardingAction.PostRegisterAction(RegisterAction.CheckIfEmailHasBeenValidated(0))) + } + + override fun onPause() { + super.onPause() + viewModel.handle(OnboardingAction.StopEmailValidationCheck) + } + + private fun setupUi() { + views.loginWaitForEmailNotice.text = getString(R.string.login_wait_for_email_notice, params.email) + } + + override fun resetViewModel() { + viewModel.handle(OnboardingAction.ResetAuthenticationAttempt) + } +} diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt index a232a6ddba..036f8eb9a2 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt @@ -192,12 +192,7 @@ class FtueAuthVariant( supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) } is OnboardingViewEvents.OnSendEmailSuccess -> { - // Pop the enter email Fragment - supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) - addRegistrationStageFragmentToBackstack( - FtueAuthWaitForEmailFragment::class.java, - FtueAuthWaitForEmailFragmentArgument(viewEvents.email), - ) + openWaitForEmailVerification(viewEvents.email) } is OnboardingViewEvents.OnSendMsisdnSuccess -> { // Pop the enter Msisdn Fragment @@ -415,6 +410,20 @@ class FtueAuthVariant( } } + private fun openWaitForEmailVerification(email: String) { + supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) + when { + vectorFeatures.isOnboardingCombinedRegisterEnabled() -> addRegistrationStageFragmentToBackstack( + FtueAuthWaitForEmailFragment::class.java, + FtueAuthWaitForEmailFragmentArgument(email), + ) + else -> addRegistrationStageFragmentToBackstack( + FtueAuthLegacyWaitForEmailFragment::class.java, + FtueAuthWaitForEmailFragmentArgument(email), + ) + } + } + private fun onTerms(stage: Stage.Terms) { when { vectorFeatures.isOnboardingCombinedRegisterEnabled() -> addRegistrationStageFragmentToBackstack( diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt index 80107c5b90..7dc18ab283 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt @@ -23,11 +23,11 @@ import android.view.View import android.view.ViewGroup import com.airbnb.mvrx.args import im.vector.app.R +import im.vector.app.databinding.FragmentFtueWaitForEmailVerificationBinding import im.vector.app.databinding.FragmentLoginWaitForEmailBinding import im.vector.app.features.onboarding.OnboardingAction import im.vector.app.features.onboarding.RegisterAction import kotlinx.parcelize.Parcelize -import org.matrix.android.sdk.api.failure.is401 import javax.inject.Inject @Parcelize @@ -38,34 +38,31 @@ data class FtueAuthWaitForEmailFragmentArgument( /** * In this screen, the user is asked to check their emails. */ -class FtueAuthWaitForEmailFragment @Inject constructor() : AbstractFtueAuthFragment() { +class FtueAuthWaitForEmailFragment @Inject constructor() : AbstractFtueAuthFragment() { private val params: FtueAuthWaitForEmailFragmentArgument by args() - override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginWaitForEmailBinding { - return FragmentLoginWaitForEmailBinding.inflate(inflater, container, false) + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueWaitForEmailVerificationBinding { + return FragmentFtueWaitForEmailVerificationBinding.inflate(inflater, container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - setupUi() } override fun onResume() { super.onResume() - viewModel.handle(OnboardingAction.PostRegisterAction(RegisterAction.CheckIfEmailHasBeenValidated(0))) } override fun onPause() { super.onPause() - viewModel.handle(OnboardingAction.StopEmailValidationCheck) } private fun setupUi() { - views.loginWaitForEmailNotice.text = getString(R.string.login_wait_for_email_notice, params.email) + views.accountCreatedSubtitle.text = getString(R.string.ftue_auth_email_verification_subtitle, params.email) } override fun resetViewModel() { diff --git a/vector/src/main/res/layout/fragment_ftue_wait_for_email_verification.xml b/vector/src/main/res/layout/fragment_ftue_wait_for_email_verification.xml new file mode 100644 index 0000000000..0d10feaed3 --- /dev/null +++ b/vector/src/main/res/layout/fragment_ftue_wait_for_email_verification.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + +