mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
adding feature flag and entry point for the _wip_ usecase screen
This commit is contained in:
parent
7cea0352f9
commit
1ae112daae
@ -36,13 +36,18 @@ class DebugFeaturesStateFactory @Inject constructor(
|
||||
),
|
||||
createBooleanFeature(
|
||||
label = "FTUE Splash - I already have an account",
|
||||
factory = VectorFeatures::isAlreadyHaveAccountSplashEnabled,
|
||||
key = DebugFeatureKeys.alreadyHaveAnAccount
|
||||
key = DebugFeatureKeys.onboardingAlreadyHaveAnAccount,
|
||||
factory = VectorFeatures::isOnboardingAlreadyHaveAccountSplashEnabled
|
||||
),
|
||||
createBooleanFeature(
|
||||
label = "FTUE Splash - carousel",
|
||||
factory = VectorFeatures::isSplashCarouselEnabled,
|
||||
key = DebugFeatureKeys.splashCarousel
|
||||
key = DebugFeatureKeys.onboardingSplashCarousel,
|
||||
factory = VectorFeatures::isOnboardingSplashCarouselEnabled
|
||||
),
|
||||
createBooleanFeature(
|
||||
label = "FTUE Use Case",
|
||||
key = DebugFeatureKeys.onboardingUseCase,
|
||||
factory = VectorFeatures::isOnboardingUseCaseEnabled
|
||||
)
|
||||
))
|
||||
}
|
||||
|
@ -43,10 +43,12 @@ class DebugVectorFeatures(
|
||||
return readPreferences().getEnum<VectorFeatures.OnboardingVariant>() ?: vectorFeatures.onboardingVariant()
|
||||
}
|
||||
|
||||
override fun isAlreadyHaveAccountSplashEnabled(): Boolean = read(DebugFeatureKeys.alreadyHaveAnAccount)
|
||||
?: vectorFeatures.isAlreadyHaveAccountSplashEnabled()
|
||||
override fun isOnboardingAlreadyHaveAccountSplashEnabled(): Boolean = read(DebugFeatureKeys.onboardingAlreadyHaveAnAccount)
|
||||
?: vectorFeatures.isOnboardingAlreadyHaveAccountSplashEnabled()
|
||||
|
||||
override fun isSplashCarouselEnabled(): Boolean = read(DebugFeatureKeys.splashCarousel) ?: vectorFeatures.isSplashCarouselEnabled()
|
||||
override fun isOnboardingSplashCarouselEnabled(): Boolean = read(DebugFeatureKeys.onboardingSplashCarousel) ?: vectorFeatures.isOnboardingSplashCarouselEnabled()
|
||||
|
||||
override fun isOnboardingUseCaseEnabled(): Boolean = read(DebugFeatureKeys.onboardingUseCase) ?: vectorFeatures.isOnboardingUseCaseEnabled()
|
||||
|
||||
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
|
||||
if (value == null) {
|
||||
@ -96,6 +98,7 @@ private inline fun <reified T : Enum<T>> enumPreferencesKey() = enumPreferencesK
|
||||
private fun <T : Enum<T>> enumPreferencesKey(type: KClass<T>) = stringPreferencesKey("enum-${type.simpleName}")
|
||||
|
||||
object DebugFeatureKeys {
|
||||
val alreadyHaveAnAccount = booleanPreferencesKey("already-have-an-account")
|
||||
val splashCarousel = booleanPreferencesKey("splash-carousel")
|
||||
val onboardingAlreadyHaveAnAccount = booleanPreferencesKey("onboarding-already-have-an-account")
|
||||
val onboardingSplashCarousel = booleanPreferencesKey("onboarding-splash-carousel")
|
||||
val onboardingUseCase = booleanPreferencesKey("onbboarding-splash-carousel")
|
||||
}
|
||||
|
@ -21,10 +21,9 @@ import im.vector.app.BuildConfig
|
||||
interface VectorFeatures {
|
||||
|
||||
fun onboardingVariant(): OnboardingVariant
|
||||
|
||||
fun isAlreadyHaveAccountSplashEnabled(): Boolean
|
||||
|
||||
fun isSplashCarouselEnabled(): Boolean
|
||||
fun isOnboardingAlreadyHaveAccountSplashEnabled(): Boolean
|
||||
fun isOnboardingSplashCarouselEnabled(): Boolean
|
||||
fun isOnboardingUseCaseEnabled(): Boolean
|
||||
|
||||
enum class OnboardingVariant {
|
||||
LEGACY,
|
||||
@ -35,6 +34,7 @@ interface VectorFeatures {
|
||||
|
||||
class DefaultVectorFeatures : VectorFeatures {
|
||||
override fun onboardingVariant(): VectorFeatures.OnboardingVariant = BuildConfig.ONBOARDING_VARIANT
|
||||
override fun isAlreadyHaveAccountSplashEnabled() = true
|
||||
override fun isSplashCarouselEnabled() = false
|
||||
override fun isOnboardingAlreadyHaveAccountSplashEnabled() = true
|
||||
override fun isOnboardingSplashCarouselEnabled() = false
|
||||
override fun isOnboardingUseCaseEnabled() = false
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ sealed class OnboardingViewEvents : VectorViewEvents {
|
||||
|
||||
// Navigation event
|
||||
|
||||
object OpenUseCaseSelection : OnboardingViewEvents()
|
||||
object OpenServerSelection : OnboardingViewEvents()
|
||||
data class OnServerSelectionDone(val serverType: ServerType) : OnboardingViewEvents()
|
||||
object OnLoginFlowRetrieved : OnboardingViewEvents()
|
||||
|
@ -35,6 +35,7 @@ import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.utils.ensureTrailingSlash
|
||||
import im.vector.app.features.VectorFeatures
|
||||
import im.vector.app.features.login.HomeServerConnectionConfigFactory
|
||||
import im.vector.app.features.login.LoginConfig
|
||||
import im.vector.app.features.login.LoginMode
|
||||
@ -71,7 +72,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||
private val homeServerConnectionConfigFactory: HomeServerConnectionConfigFactory,
|
||||
private val reAuthHelper: ReAuthHelper,
|
||||
private val stringProvider: StringProvider,
|
||||
private val homeServerHistoryService: HomeServerHistoryService
|
||||
private val homeServerHistoryService: HomeServerHistoryService,
|
||||
private val vectorFeatures: VectorFeatures
|
||||
) : VectorViewModel<OnboardingViewState, OnboardingAction, OnboardingViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
@ -154,15 +156,24 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||
if (homeServerConnectionConfig == null) {
|
||||
// Url is invalid, in this case, just use the regular flow
|
||||
Timber.w("Url from config url was invalid: $configUrl")
|
||||
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
|
||||
continueToPageAfterSplash()
|
||||
} else {
|
||||
getLoginFlow(homeServerConnectionConfig, ServerType.Other)
|
||||
}
|
||||
} else {
|
||||
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
|
||||
continueToPageAfterSplash()
|
||||
}
|
||||
}
|
||||
|
||||
private fun continueToPageAfterSplash() {
|
||||
val nextOnboardingStep = if (vectorFeatures.isOnboardingUseCaseEnabled()) {
|
||||
OnboardingViewEvents.OpenUseCaseSelection
|
||||
} else {
|
||||
OnboardingViewEvents.OpenServerSelection
|
||||
}
|
||||
_viewEvents.post(nextOnboardingStep)
|
||||
}
|
||||
|
||||
private fun handleUserAcceptCertificate(action: OnboardingAction.UserAcceptCertificate) {
|
||||
// It happens when we get the login flow, or during direct authentication.
|
||||
// So alter the homeserver config and retrieve again the login flow
|
||||
|
@ -69,7 +69,7 @@ class FtueAuthSplashCarouselFragment @Inject constructor(
|
||||
|
||||
views.loginSplashSubmit.debouncedClicks { getStarted() }
|
||||
views.loginSplashAlreadyHaveAccount.apply {
|
||||
isVisible = vectorFeatures.isAlreadyHaveAccountSplashEnabled()
|
||||
isVisible = vectorFeatures.isOnboardingAlreadyHaveAccountSplashEnabled()
|
||||
debouncedClicks { alreadyHaveAnAccount() }
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ class FtueAuthSplashCarouselFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun getStarted() {
|
||||
val getStartedFlow = if (vectorFeatures.isAlreadyHaveAccountSplashEnabled()) OnboardingFlow.SignUp else OnboardingFlow.SignInSignUp
|
||||
val getStartedFlow = if (vectorFeatures.isOnboardingAlreadyHaveAccountSplashEnabled()) OnboardingFlow.SignUp else OnboardingFlow.SignInSignUp
|
||||
viewModel.handle(OnboardingAction.OnGetStarted(resetLoginConfig = false, onboardingFlow = getStartedFlow))
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class FtueAuthSplashFragment @Inject constructor(
|
||||
private fun setupViews() {
|
||||
views.loginSplashSubmit.debouncedClicks { getStarted() }
|
||||
views.loginSplashAlreadyHaveAccount.apply {
|
||||
isVisible = vectorFeatures.isAlreadyHaveAccountSplashEnabled()
|
||||
isVisible = vectorFeatures.isOnboardingAlreadyHaveAccountSplashEnabled()
|
||||
debouncedClicks { alreadyHaveAnAccount() }
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ class FtueAuthSplashFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun getStarted() {
|
||||
val getStartedFlow = if (vectorFeatures.isAlreadyHaveAccountSplashEnabled()) OnboardingFlow.SignUp else OnboardingFlow.SignInSignUp
|
||||
val getStartedFlow = if (vectorFeatures.isOnboardingAlreadyHaveAccountSplashEnabled()) OnboardingFlow.SignUp else OnboardingFlow.SignInSignUp
|
||||
viewModel.handle(OnboardingAction.OnGetStarted(resetLoginConfig = false, onboardingFlow = getStartedFlow))
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
package im.vector.app.features.onboarding.ftueauth
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -109,7 +110,7 @@ class FtueAuthVariant(
|
||||
}
|
||||
|
||||
private fun addFirstFragment() {
|
||||
val splashFragment = when (vectorFeatures.isSplashCarouselEnabled()) {
|
||||
val splashFragment = when (vectorFeatures.isOnboardingSplashCarouselEnabled()) {
|
||||
true -> FtueAuthSplashCarouselFragment::class.java
|
||||
else -> FtueAuthSplashFragment::class.java
|
||||
}
|
||||
@ -208,6 +209,9 @@ class FtueAuthVariant(
|
||||
is OnboardingViewEvents.Loading ->
|
||||
// This is handled by the Fragments
|
||||
Unit
|
||||
OnboardingViewEvents.OpenUseCaseSelection -> {
|
||||
TODO()
|
||||
}
|
||||
}.exhaustive
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user