mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 09:56:00 +03:00
extracting common fragment behaviour to a function
This commit is contained in:
parent
215cac2aec
commit
4e56136993
1 changed files with 22 additions and 36 deletions
|
@ -17,6 +17,7 @@
|
||||||
package im.vector.app.features.onboarding.ftueauth
|
package im.vector.app.features.onboarding.ftueauth
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Parcelable
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
|
@ -202,20 +203,18 @@ class FtueAuthVariant(
|
||||||
is OnboardingViewEvents.OnSendEmailSuccess -> {
|
is OnboardingViewEvents.OnSendEmailSuccess -> {
|
||||||
// Pop the enter email Fragment
|
// Pop the enter email Fragment
|
||||||
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||||
activity.addFragmentToBackstack(views.loginFragmentContainer,
|
addRegistrationStageFragmentToBackstack(
|
||||||
FtueAuthWaitForEmailFragment::class.java,
|
FtueAuthWaitForEmailFragment::class.java,
|
||||||
FtueAuthWaitForEmailFragmentArgument(viewEvents.email),
|
FtueAuthWaitForEmailFragmentArgument(viewEvents.email),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
)
|
||||||
option = commonOption)
|
|
||||||
}
|
}
|
||||||
is OnboardingViewEvents.OnSendMsisdnSuccess -> {
|
is OnboardingViewEvents.OnSendMsisdnSuccess -> {
|
||||||
// Pop the enter Msisdn Fragment
|
// Pop the enter Msisdn Fragment
|
||||||
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||||
activity.addFragmentToBackstack(views.loginFragmentContainer,
|
addRegistrationStageFragmentToBackstack(
|
||||||
FtueAuthGenericTextInputFormFragment::class.java,
|
FtueAuthGenericTextInputFormFragment::class.java,
|
||||||
FtueAuthGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.ConfirmMsisdn, true, viewEvents.msisdn),
|
FtueAuthGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.ConfirmMsisdn, true, viewEvents.msisdn),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
)
|
||||||
option = commonOption)
|
|
||||||
}
|
}
|
||||||
is OnboardingViewEvents.Failure,
|
is OnboardingViewEvents.Failure,
|
||||||
is OnboardingViewEvents.Loading ->
|
is OnboardingViewEvents.Loading ->
|
||||||
|
@ -246,12 +245,7 @@ class FtueAuthVariant(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openCombinedRegister() {
|
private fun openCombinedRegister() {
|
||||||
activity.addFragmentToBackstack(
|
addRegistrationStageFragmentToBackstack(FtueAuthCombinedRegisterFragment::class.java)
|
||||||
views.loginFragmentContainer,
|
|
||||||
FtueAuthCombinedRegisterFragment::class.java,
|
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
|
||||||
option = commonOption
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registrationShouldFallback(registrationFlowResult: OnboardingViewEvents.RegistrationFlowResult) =
|
private fun registrationShouldFallback(registrationFlowResult: OnboardingViewEvents.RegistrationFlowResult) =
|
||||||
|
@ -384,19 +378,13 @@ class FtueAuthVariant(
|
||||||
|
|
||||||
when (stage) {
|
when (stage) {
|
||||||
is Stage.ReCaptcha -> onCaptcha(stage)
|
is Stage.ReCaptcha -> onCaptcha(stage)
|
||||||
is Stage.Email -> activity.addFragmentToBackstack(
|
is Stage.Email -> addRegistrationStageFragmentToBackstack(
|
||||||
views.loginFragmentContainer,
|
|
||||||
FtueAuthGenericTextInputFormFragment::class.java,
|
FtueAuthGenericTextInputFormFragment::class.java,
|
||||||
FtueAuthGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetEmail, stage.mandatory),
|
FtueAuthGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetEmail, stage.mandatory),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
|
||||||
option = commonOption
|
|
||||||
)
|
)
|
||||||
is Stage.Msisdn -> activity.addFragmentToBackstack(
|
is Stage.Msisdn -> addRegistrationStageFragmentToBackstack(
|
||||||
views.loginFragmentContainer,
|
|
||||||
FtueAuthGenericTextInputFormFragment::class.java,
|
FtueAuthGenericTextInputFormFragment::class.java,
|
||||||
FtueAuthGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetMsisdn, stage.mandatory),
|
FtueAuthGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetMsisdn, stage.mandatory),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
|
||||||
option = commonOption
|
|
||||||
)
|
)
|
||||||
is Stage.Terms -> onTerms(stage)
|
is Stage.Terms -> onTerms(stage)
|
||||||
else -> Unit // Should not happen
|
else -> Unit // Should not happen
|
||||||
|
@ -405,38 +393,26 @@ class FtueAuthVariant(
|
||||||
|
|
||||||
private fun onTerms(stage: Stage.Terms) {
|
private fun onTerms(stage: Stage.Terms) {
|
||||||
when {
|
when {
|
||||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> activity.addFragmentToBackstack(
|
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> addRegistrationStageFragmentToBackstack(
|
||||||
views.loginFragmentContainer,
|
|
||||||
FtueAuthTermsFragment::class.java,
|
FtueAuthTermsFragment::class.java,
|
||||||
FtueAuthTermsLegacyStyleFragmentArgument(stage.policies.toLocalizedLoginTerms(activity.getString(R.string.resources_language))),
|
FtueAuthTermsLegacyStyleFragmentArgument(stage.policies.toLocalizedLoginTerms(activity.getString(R.string.resources_language))),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
|
||||||
option = commonOption
|
|
||||||
)
|
)
|
||||||
else -> activity.addFragmentToBackstack(
|
else -> addRegistrationStageFragmentToBackstack(
|
||||||
views.loginFragmentContainer,
|
|
||||||
FtueAuthLegacyStyleTermsFragment::class.java,
|
FtueAuthLegacyStyleTermsFragment::class.java,
|
||||||
FtueAuthTermsLegacyStyleFragmentArgument(stage.policies.toLocalizedLoginTerms(activity.getString(R.string.resources_language))),
|
FtueAuthTermsLegacyStyleFragmentArgument(stage.policies.toLocalizedLoginTerms(activity.getString(R.string.resources_language))),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
|
||||||
option = commonOption
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onCaptcha(stage: Stage.ReCaptcha) {
|
private fun onCaptcha(stage: Stage.ReCaptcha) {
|
||||||
when {
|
when {
|
||||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> activity.addFragmentToBackstack(
|
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> addRegistrationStageFragmentToBackstack(
|
||||||
views.loginFragmentContainer,
|
|
||||||
FtueAuthCaptchaFragment::class.java,
|
FtueAuthCaptchaFragment::class.java,
|
||||||
FtueAuthCaptchaFragmentArgument(stage.publicKey),
|
FtueAuthCaptchaFragmentArgument(stage.publicKey),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
|
||||||
option = commonOption
|
|
||||||
)
|
)
|
||||||
else -> activity.addFragmentToBackstack(
|
else -> addRegistrationStageFragmentToBackstack(
|
||||||
views.loginFragmentContainer,
|
|
||||||
FtueAuthLegacyStyleCaptchaFragment::class.java,
|
FtueAuthLegacyStyleCaptchaFragment::class.java,
|
||||||
FtueAuthLegacyStyleCaptchaFragmentArgument(stage.publicKey),
|
FtueAuthLegacyStyleCaptchaFragmentArgument(stage.publicKey),
|
||||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
|
||||||
option = commonOption
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,4 +458,14 @@ class FtueAuthVariant(
|
||||||
useCustomAnimation = true
|
useCustomAnimation = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addRegistrationStageFragmentToBackstack(fragmentClass: Class<out Fragment>, params: Parcelable? = null) {
|
||||||
|
activity.addFragmentToBackstack(
|
||||||
|
views.loginFragmentContainer,
|
||||||
|
fragmentClass,
|
||||||
|
params,
|
||||||
|
tag = FRAGMENT_REGISTRATION_STAGE_TAG,
|
||||||
|
option = commonOption
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue