setting login version via typed build config field instead of resources
This commit is contained in:
parent
54c45d3e71
commit
8007654e2a
@ -140,10 +140,7 @@ android {
|
|||||||
buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\""
|
buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\""
|
||||||
resValue "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
|
buildConfigField "im.vector.app.features.VectorFeatures.LoginVersion", "LOGIN_VERSION", "im.vector.app.features.VectorFeatures.LoginVersion.V1"
|
||||||
// LoginFlowV2 is disabled to be merged on develop (changelog: Improve login/register flow (#1410, #2585, #3172))
|
|
||||||
resValue "bool", "useLoginV1", "true"
|
|
||||||
resValue "bool", "useLoginV2", "false"
|
|
||||||
|
|
||||||
// NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web
|
// NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web
|
||||||
def useNotificationSettingsV2 = true
|
def useNotificationSettingsV2 = true
|
||||||
|
@ -133,13 +133,11 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".features.login.LoginActivity"
|
android:name=".features.login.LoginActivity"
|
||||||
android:enabled="@bool/useLoginV1"
|
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".features.login2.LoginActivity2"
|
android:name=".features.login2.LoginActivity2"
|
||||||
android:enabled="@bool/useLoginV2"
|
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ object VectorStaticModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
fun providesFeatures(context: Context): VectorFeatures {
|
fun providesFeatures(): VectorFeatures {
|
||||||
return DefaultVectorFeatures(context)
|
return DefaultVectorFeatures()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,27 +16,18 @@
|
|||||||
|
|
||||||
package im.vector.app.features
|
package im.vector.app.features
|
||||||
|
|
||||||
import android.content.Context
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.R
|
|
||||||
import im.vector.app.features.VectorFeatures.LoginType
|
|
||||||
|
|
||||||
interface VectorFeatures {
|
interface VectorFeatures {
|
||||||
|
|
||||||
fun loginType(): LoginType
|
fun loginVersion(): LoginVersion
|
||||||
|
|
||||||
enum class LoginType {
|
enum class LoginVersion {
|
||||||
V1,
|
V1,
|
||||||
V2
|
V2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DefaultVectorFeatures(private val context: Context) : VectorFeatures {
|
class DefaultVectorFeatures : VectorFeatures {
|
||||||
override fun loginType(): LoginType {
|
override fun loginVersion(): VectorFeatures.LoginVersion = BuildConfig.LOGIN_VERSION
|
||||||
val v2LoginIsEnabled = context.resources.getBoolean(R.bool.useLoginV2)
|
|
||||||
return if (v2LoginIsEnabled) {
|
|
||||||
LoginType.V2
|
|
||||||
} else {
|
|
||||||
LoginType.V1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -111,26 +111,26 @@ class DefaultNavigator @Inject constructor(
|
|||||||
) : Navigator {
|
) : Navigator {
|
||||||
|
|
||||||
override fun openLogin(context: Context, loginConfig: LoginConfig?, flags: Int) {
|
override fun openLogin(context: Context, loginConfig: LoginConfig?, flags: Int) {
|
||||||
val intent = when (features.loginType()) {
|
val intent = when (features.loginVersion()) {
|
||||||
VectorFeatures.LoginType.V1 -> LoginActivity.newIntent(context, loginConfig)
|
VectorFeatures.LoginVersion.V1 -> LoginActivity.newIntent(context, loginConfig)
|
||||||
VectorFeatures.LoginType.V2 -> LoginActivity2.newIntent(context, loginConfig)
|
VectorFeatures.LoginVersion.V2 -> LoginActivity2.newIntent(context, loginConfig)
|
||||||
}
|
}
|
||||||
intent.addFlags(flags)
|
intent.addFlags(flags)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loginSSORedirect(context: Context, data: Uri?) {
|
override fun loginSSORedirect(context: Context, data: Uri?) {
|
||||||
val intent = when (features.loginType()) {
|
val intent = when (features.loginVersion()) {
|
||||||
VectorFeatures.LoginType.V1 -> LoginActivity.redirectIntent(context, data)
|
VectorFeatures.LoginVersion.V1 -> LoginActivity.redirectIntent(context, data)
|
||||||
VectorFeatures.LoginType.V2 -> LoginActivity2.redirectIntent(context, data)
|
VectorFeatures.LoginVersion.V2 -> LoginActivity2.redirectIntent(context, data)
|
||||||
}
|
}
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun softLogout(context: Context) {
|
override fun softLogout(context: Context) {
|
||||||
val intent = when (features.loginType()) {
|
val intent = when (features.loginVersion()) {
|
||||||
VectorFeatures.LoginType.V1 -> SoftLogoutActivity.newIntent(context)
|
VectorFeatures.LoginVersion.V1 -> SoftLogoutActivity.newIntent(context)
|
||||||
VectorFeatures.LoginType.V2 -> SoftLogoutActivity2.newIntent(context)
|
VectorFeatures.LoginVersion.V2 -> SoftLogoutActivity2.newIntent(context)
|
||||||
}
|
}
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user