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