Add flag to allow QR login on all servers + split flag for showing in device manager

This commit is contained in:
Hugh Nimmo-Smith 2022-10-14 01:45:03 +01:00
parent efa70fa0ff
commit d72371906e
5 changed files with 32 additions and 1 deletions

View file

@ -95,6 +95,16 @@ class DebugFeaturesStateFactory @Inject constructor(
key = DebugFeatureKeys.qrCodeLoginEnabled,
factory = VectorFeatures::isQrCodeLoginEnabled
),
createBooleanFeature(
label = "Allow QR Code Login for all servers",
key = DebugFeatureKeys.allowQrCodeLoginForAllServers,
factory = VectorFeatures::allowQrCodeLoginForAllServers
),
createBooleanFeature(
label = "Show QR Code Login in Device Manager",
key = DebugFeatureKeys.allowReciprocateQrCodeLogin,
factory = VectorFeatures::allowReciprocateQrCodeLogin
),
createBooleanFeature(
label = "Enable Voice Broadcast",
key = DebugFeatureKeys.voiceBroadcastEnabled,

View file

@ -82,6 +82,12 @@ class DebugVectorFeatures(
override fun isQrCodeLoginEnabled() = read(DebugFeatureKeys.qrCodeLoginEnabled)
?: vectorFeatures.isQrCodeLoginEnabled()
override fun allowQrCodeLoginForAllServers() = read(DebugFeatureKeys.allowQrCodeLoginForAllServers)
?: vectorFeatures.allowQrCodeLoginForAllServers()
override fun allowReciprocateQrCodeLogin() = read(DebugFeatureKeys.allowReciprocateQrCodeLogin)
?: vectorFeatures.allowReciprocateQrCodeLogin()
override fun isVoiceBroadcastEnabled(): Boolean = read(DebugFeatureKeys.voiceBroadcastEnabled)
?: vectorFeatures.isVoiceBroadcastEnabled()
@ -147,5 +153,7 @@ object DebugFeatureKeys {
val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled")
val newDeviceManagementEnabled = booleanPreferencesKey("new-device-management-enabled")
val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled")
val allowQrCodeLoginForAllServers = booleanPreferencesKey("allow-qr-code-login-for-all-servers")
val allowReciprocateQrCodeLogin = booleanPreferencesKey("allow-reciprocate-qr-code-login")
val voiceBroadcastEnabled = booleanPreferencesKey("voice-broadcast-enabled")
}

View file

@ -42,6 +42,8 @@ interface VectorFeatures {
fun isNewAppLayoutFeatureEnabled(): Boolean
fun isNewDeviceManagementEnabled(): Boolean
fun isQrCodeLoginEnabled(): Boolean
fun allowQrCodeLoginForAllServers(): Boolean
fun allowReciprocateQrCodeLogin(): Boolean
fun isVoiceBroadcastEnabled(): Boolean
}
@ -60,5 +62,7 @@ class DefaultVectorFeatures : VectorFeatures {
override fun isNewAppLayoutFeatureEnabled(): Boolean = true
override fun isNewDeviceManagementEnabled(): Boolean = false
override fun isQrCodeLoginEnabled(): Boolean = false
override fun allowQrCodeLoginForAllServers(): Boolean = false
override fun allowReciprocateQrCodeLogin(): Boolean = false
override fun isVoiceBroadcastEnabled(): Boolean = false
}

View file

@ -124,7 +124,16 @@ class OnboardingViewModel @AssistedInject constructor(
canLoginWithQrCode = false
)
}
} else if (vectorFeatures.allowQrCodeLoginForAllServers()) {
// allow for all servers
setState {
copy(
canLoginWithQrCode = true
)
}
} else {
// check if selected server supports MSC3882 first
// FIXME: this should be checking the selected homeserver not defaultHomeserverUrl
homeServerConnectionConfigFactory.create(defaultHomeserverUrl)?.let {
val canLoginWithQrCode = authenticationService.isQrLoginSupported(it)
setState {

View file

@ -158,7 +158,7 @@ class VectorSettingsDevicesFragment :
}
private fun initQrLoginView() {
if (!vectorFeatures.isQrCodeLoginEnabled()) {
if (!vectorFeatures.allowReciprocateQrCodeLogin()) {
views.deviceListHeaderSignInWithQrCode.isVisible = false
views.deviceListHeaderScanQrCodeButton.isVisible = false
views.deviceListHeaderShowQrCodeButton.isVisible = false