From 7ef8193a93776cf4e2560c581e6b3ae7f867168c Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 7 Jun 2022 17:18:18 +0100 Subject: [PATCH] fixing reset fragments not removing previous screens when moving to the next step --- .../onboarding/ftueauth/FtueAuthVariant.kt | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) 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 5f1c3d4314..80375ec6c5 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 @@ -163,35 +163,24 @@ class FtueAuthVariant( is OnboardingViewEvents.OnWebLoginError -> onWebLoginError(viewEvents) is OnboardingViewEvents.OnForgetPasswordClicked -> when { - vectorFeatures.isOnboardingCombinedLoginEnabled() -> activity.addFragmentToBackstack( - views.loginFragmentContainer, - FtueAuthResetPasswordEmailEntryFragment::class.java, - option = commonOption - ) - else -> activity.addFragmentToBackstack( - views.loginFragmentContainer, - FtueAuthResetPasswordFragment::class.java, - option = commonOption - ) + vectorFeatures.isOnboardingCombinedLoginEnabled() -> addLoginStageFragmentToBackstack(FtueAuthResetPasswordEmailEntryFragment::class.java) + else -> addLoginStageFragmentToBackstack(FtueAuthResetPasswordFragment::class.java) } is OnboardingViewEvents.OnResetPasswordSendThreePidDone -> { - supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) + supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) when { - vectorFeatures.isOnboardingCombinedLoginEnabled() -> activity.addFragmentToBackstack( - views.loginFragmentContainer, + vectorFeatures.isOnboardingCombinedLoginEnabled() -> addLoginStageFragmentToBackstack( FtueAuthResetPasswordBreakerFragment::class.java, FtueAuthResetPasswordBreakerArgument(viewEvents.email), - option = commonOption ) else -> activity.addFragmentToBackstack( views.loginFragmentContainer, FtueAuthResetPasswordMailConfirmationFragment::class.java, - option = commonOption ) } } OnboardingViewEvents.OnResetPasswordBreakerConfirmed -> { - supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) + supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) activity.addFragmentToBackstack( views.loginFragmentContainer, FtueAuthResetPasswordEntryFragment::class.java, @@ -199,16 +188,12 @@ class FtueAuthVariant( ) } is OnboardingViewEvents.OnResetPasswordMailConfirmationSuccess -> { - supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) - activity.addFragmentToBackstack( - views.loginFragmentContainer, - FtueAuthResetPasswordSuccessFragment::class.java, - option = commonOption - ) + supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) + addLoginStageFragmentToBackstack(FtueAuthResetPasswordSuccessFragment::class.java) } is OnboardingViewEvents.OnResetPasswordMailConfirmationSuccessDone -> { // Go back to the login fragment - supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) + supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) } is OnboardingViewEvents.OnSendEmailSuccess -> { openWaitForEmailVerification(viewEvents.email) @@ -519,4 +504,14 @@ class FtueAuthVariant( option = commonOption ) } + + private fun addLoginStageFragmentToBackstack(fragmentClass: Class, params: Parcelable? = null) { + activity.addFragmentToBackstack( + views.loginFragmentContainer, + fragmentClass, + params, + tag = FRAGMENT_LOGIN_TAG, + option = commonOption + ) + } }