setting login version via typed build config field instead of resources

This commit is contained in:
Adam Brown 2021-12-03 15:02:09 +00:00
parent 54c45d3e71
commit 8007654e2a
5 changed files with 17 additions and 31 deletions

View File

@ -140,10 +140,7 @@ android {
buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\""
resValue "string", "build_number", "\"${buildNumber}\""
// The two booleans must not have the same value. We need two values for the manifest
// LoginFlowV2 is disabled to be merged on develop (changelog: Improve login/register flow (#1410, #2585, #3172))
resValue "bool", "useLoginV1", "true"
resValue "bool", "useLoginV2", "false"
buildConfigField "im.vector.app.features.VectorFeatures.LoginVersion", "LOGIN_VERSION", "im.vector.app.features.VectorFeatures.LoginVersion.V1"
// NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web
def useNotificationSettingsV2 = true

View File

@ -133,13 +133,11 @@
<activity
android:name=".features.login.LoginActivity"
android:enabled="@bool/useLoginV1"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".features.login2.LoginActivity2"
android:enabled="@bool/useLoginV2"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize" />

View File

@ -137,7 +137,7 @@ object VectorStaticModule {
}
@Provides
fun providesFeatures(context: Context): VectorFeatures {
return DefaultVectorFeatures(context)
fun providesFeatures(): VectorFeatures {
return DefaultVectorFeatures()
}
}

View File

@ -16,27 +16,18 @@
package im.vector.app.features
import android.content.Context
import im.vector.app.R
import im.vector.app.features.VectorFeatures.LoginType
import im.vector.app.BuildConfig
interface VectorFeatures {
fun loginType(): LoginType
fun loginVersion(): LoginVersion
enum class LoginType {
enum class LoginVersion {
V1,
V2
}
}
class DefaultVectorFeatures(private val context: Context) : VectorFeatures {
override fun loginType(): LoginType {
val v2LoginIsEnabled = context.resources.getBoolean(R.bool.useLoginV2)
return if (v2LoginIsEnabled) {
LoginType.V2
} else {
LoginType.V1
}
}
class DefaultVectorFeatures : VectorFeatures {
override fun loginVersion(): VectorFeatures.LoginVersion = BuildConfig.LOGIN_VERSION
}

View File

@ -111,26 +111,26 @@ class DefaultNavigator @Inject constructor(
) : Navigator {
override fun openLogin(context: Context, loginConfig: LoginConfig?, flags: Int) {
val intent = when (features.loginType()) {
VectorFeatures.LoginType.V1 -> LoginActivity.newIntent(context, loginConfig)
VectorFeatures.LoginType.V2 -> LoginActivity2.newIntent(context, loginConfig)
val intent = when (features.loginVersion()) {
VectorFeatures.LoginVersion.V1 -> LoginActivity.newIntent(context, loginConfig)
VectorFeatures.LoginVersion.V2 -> LoginActivity2.newIntent(context, loginConfig)
}
intent.addFlags(flags)
context.startActivity(intent)
}
override fun loginSSORedirect(context: Context, data: Uri?) {
val intent = when (features.loginType()) {
VectorFeatures.LoginType.V1 -> LoginActivity.redirectIntent(context, data)
VectorFeatures.LoginType.V2 -> LoginActivity2.redirectIntent(context, data)
val intent = when (features.loginVersion()) {
VectorFeatures.LoginVersion.V1 -> LoginActivity.redirectIntent(context, data)
VectorFeatures.LoginVersion.V2 -> LoginActivity2.redirectIntent(context, data)
}
context.startActivity(intent)
}
override fun softLogout(context: Context) {
val intent = when (features.loginType()) {
VectorFeatures.LoginType.V1 -> SoftLogoutActivity.newIntent(context)
VectorFeatures.LoginType.V2 -> SoftLogoutActivity2.newIntent(context)
val intent = when (features.loginVersion()) {
VectorFeatures.LoginVersion.V1 -> SoftLogoutActivity.newIntent(context)
VectorFeatures.LoginVersion.V2 -> SoftLogoutActivity2.newIntent(context)
}
context.startActivity(intent)
}