From e795e9da52ef41d6c14306ca8af31f84e800a366 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 12:41:33 +0100 Subject: [PATCH] porting the onboarding variant selection to the config --- .../src/main/java/im/vector/app/config/Config.kt | 16 ++++++++++++++-- vector/build.gradle | 2 -- .../debug/features/DebugVectorFeatures.kt | 5 +++-- .../im/vector/app/core/di/SingletonModule.kt | 2 +- .../im/vector/app/features/VectorFeatures.kt | 10 ++-------- .../app/features/navigation/DefaultNavigator.kt | 2 +- .../onboarding/OnboardingVariantFactory.kt | 7 ++++--- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 31bb6ed1e0..412e942fd7 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -40,7 +40,12 @@ object Config { /** * The maximum length of voice messages in milliseconds. */ - const val VOICE_MESSAGE_LIMIT = 120_000L + const val VOICE_MESSAGE_LIMIT_MS = 120_000L + + /** + * The onboarding flow + */ + val ONBOARDING_VARIANT = OnboardingVariant.FTUE_AUTH /** * The analytics configuration to use for the Debug build type. @@ -70,7 +75,7 @@ object Config { } /** - * The types of analytics Element currently supports + * The types of analytics Element currently supports. */ sealed interface Analytics { @@ -99,3 +104,10 @@ sealed interface Analytics { val policyLink: String, ) : Analytics } + + +enum class OnboardingVariant { + LEGACY, + LOGIN_2, + FTUE_AUTH +} diff --git a/vector/build.gradle b/vector/build.gradle index d306b06bb3..3fd6237fc4 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -156,8 +156,6 @@ android { buildConfigField "String", "GIT_BRANCH_NAME", "\"${gitBranchName()}\"" buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\"" - buildConfigField "im.vector.app.features.VectorFeatures.OnboardingVariant", "ONBOARDING_VARIANT", "im.vector.app.features.VectorFeatures.OnboardingVariant.FTUE_AUTH" - buildConfigField "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy", "outboundSessionKeySharingStrategy", "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy.WhenTyping" // If set, MSC3086 asserted identity messages sent on VoIP calls will cause the call to appear in the room corresponding to the asserted identity. diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 23aad65653..c03a0a8663 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -24,6 +24,7 @@ import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore +import im.vector.app.config.OnboardingVariant import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.VectorFeatures import kotlinx.coroutines.flow.first @@ -39,8 +40,8 @@ class DebugVectorFeatures( private val dataStore = context.dataStore - override fun onboardingVariant(): VectorFeatures.OnboardingVariant { - return readPreferences().getEnum() ?: vectorFeatures.onboardingVariant() + override fun onboardingVariant(): OnboardingVariant { + return readPreferences().getEnum() ?: vectorFeatures.onboardingVariant() } override fun isOnboardingAlreadyHaveAccountSplashEnabled(): Boolean = read(DebugFeatureKeys.onboardingAlreadyHaveAnAccount) diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index e1d69f97d9..64ad9eda6c 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -231,7 +231,7 @@ object VectorStaticModule { @Provides fun providesVoiceMessageConfig() = VoiceMessageConfig( - lengthLimitMs = Config.VOICE_MESSAGE_LIMIT + lengthLimitMs = Config.VOICE_MESSAGE_LIMIT_MS ) @Provides diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 3a56f31b72..592f568835 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -16,8 +16,8 @@ package im.vector.app.features -import im.vector.app.BuildConfig import im.vector.app.config.Config +import im.vector.app.config.OnboardingVariant interface VectorFeatures { @@ -33,16 +33,10 @@ interface VectorFeatures { fun forceUsageOfOpusEncoder(): Boolean fun shouldStartDmOnFirstMessage(): Boolean fun isNewAppLayoutEnabled(): Boolean - - enum class OnboardingVariant { - LEGACY, - LOGIN_2, - FTUE_AUTH - } } class DefaultVectorFeatures : VectorFeatures { - override fun onboardingVariant(): VectorFeatures.OnboardingVariant = BuildConfig.ONBOARDING_VARIANT + override fun onboardingVariant() = Config.ONBOARDING_VARIANT override fun isOnboardingAlreadyHaveAccountSplashEnabled() = true override fun isOnboardingSplashCarouselEnabled() = true override fun isOnboardingUseCaseEnabled() = true diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt index d2404b5bb8..20b79d8ba3 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt @@ -32,11 +32,11 @@ import androidx.core.util.Pair import androidx.core.view.ViewCompat import com.google.android.material.dialog.MaterialAlertDialogBuilder import im.vector.app.R +import im.vector.app.config.OnboardingVariant import im.vector.app.SpaceStateHandler import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.error.fatalError import im.vector.app.features.VectorFeatures -import im.vector.app.features.VectorFeatures.OnboardingVariant import im.vector.app.features.analytics.AnalyticsTracker import im.vector.app.features.analytics.extensions.toAnalyticsViewRoom import im.vector.app.features.analytics.plan.ViewRoom diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt index 8d9f372bdd..9837db8e91 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt @@ -16,6 +16,7 @@ package im.vector.app.features.onboarding +import im.vector.app.config.OnboardingVariant import im.vector.app.core.platform.ScreenOrientationLocker import im.vector.app.databinding.ActivityLoginBinding import im.vector.app.features.VectorFeatures @@ -34,8 +35,8 @@ class OnboardingVariantFactory @Inject constructor( onboardingViewModel: Lazy, loginViewModel2: Lazy ) = when (vectorFeatures.onboardingVariant()) { - VectorFeatures.OnboardingVariant.LEGACY -> error("Legacy is not supported by the FTUE") - VectorFeatures.OnboardingVariant.FTUE_AUTH -> FtueAuthVariant( + OnboardingVariant.LEGACY -> error("Legacy is not supported by the FTUE") + OnboardingVariant.FTUE_AUTH -> FtueAuthVariant( views = views, onboardingViewModel = onboardingViewModel.value, activity = activity, @@ -43,7 +44,7 @@ class OnboardingVariantFactory @Inject constructor( vectorFeatures = vectorFeatures, orientationLocker = orientationLocker ) - VectorFeatures.OnboardingVariant.LOGIN_2 -> Login2Variant( + OnboardingVariant.LOGIN_2 -> Login2Variant( views = views, loginViewModel = loginViewModel2.value, activity = activity,