From 63c02c6fef0faa5277273ad5280e8ecd75b43f43 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Tue, 18 Oct 2022 21:02:58 +0200 Subject: [PATCH] Voice Broadcast - Restore feature flag and enable it by default --- .../app/features/debug/features/DebugFeaturesStateFactory.kt | 5 +++++ .../app/features/debug/features/DebugVectorFeatures.kt | 4 ++++ .../src/main/java/im/vector/app/features/VectorFeatures.kt | 2 ++ .../im/vector/app/features/settings/VectorPreferences.kt | 3 ++- .../app/features/settings/labs/VectorSettingsLabsFragment.kt | 4 ++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt index 0ce4416add..16e26ff3b5 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -100,6 +100,11 @@ class DebugFeaturesStateFactory @Inject constructor( key = DebugFeatureKeys.reciprocateQrCodeLogin, factory = VectorFeatures::isReciprocateQrCodeLogin ), + createBooleanFeature( + label = "Enable Voice Broadcast", + key = DebugFeatureKeys.voiceBroadcastEnabled, + factory = VectorFeatures::isVoiceBroadcastEnabled + ), ) ) } diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 487094b238..5c497c24ec 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -85,6 +85,9 @@ class DebugVectorFeatures( override fun isReciprocateQrCodeLogin() = read(DebugFeatureKeys.reciprocateQrCodeLogin) ?: vectorFeatures.isReciprocateQrCodeLogin() + override fun isVoiceBroadcastEnabled(): Boolean = read(DebugFeatureKeys.voiceBroadcastEnabled) + ?: vectorFeatures.isVoiceBroadcastEnabled() + fun override(value: T?, key: Preferences.Key) = updatePreferences { if (value == null) { it.remove(key) @@ -147,4 +150,5 @@ object DebugFeatureKeys { val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled") val qrCodeLoginForAllServers = booleanPreferencesKey("qr-code-login-for-all-servers") val reciprocateQrCodeLogin = booleanPreferencesKey("reciprocate-qr-code-login") + val voiceBroadcastEnabled = booleanPreferencesKey("voice-broadcast-enabled") } 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 59bccc25fc..95cf272abd 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -43,6 +43,7 @@ interface VectorFeatures { fun isQrCodeLoginEnabled(): Boolean fun isQrCodeLoginForAllServers(): Boolean fun isReciprocateQrCodeLogin(): Boolean + fun isVoiceBroadcastEnabled(): Boolean } class DefaultVectorFeatures : VectorFeatures { @@ -61,4 +62,5 @@ class DefaultVectorFeatures : VectorFeatures { override fun isQrCodeLoginEnabled(): Boolean = true override fun isQrCodeLoginForAllServers(): Boolean = false override fun isReciprocateQrCodeLogin(): Boolean = false + override fun isVoiceBroadcastEnabled(): Boolean = true } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 5d0f981314..2dc8b12160 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -1206,6 +1206,7 @@ class VectorPreferences @Inject constructor( } fun isVoiceBroadcastEnabled(): Boolean { - return defaultPrefs.getBoolean(SETTINGS_LABS_VOICE_BROADCAST_KEY, getDefault(R.bool.settings_labs_enable_voice_broadcast_default)) + return vectorFeatures.isVoiceBroadcastEnabled() && + defaultPrefs.getBoolean(SETTINGS_LABS_VOICE_BROADCAST_KEY, getDefault(R.bool.settings_labs_enable_voice_broadcast_default)) } } diff --git a/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt index 6c31e32567..f9a5a5f9cc 100644 --- a/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt @@ -90,6 +90,10 @@ class VectorSettingsLabsFragment : } } + findPreference(VectorPreferences.SETTINGS_LABS_VOICE_BROADCAST_KEY)?.let { pref -> + pref.isVisible = vectorFeatures.isVoiceBroadcastEnabled() + } + configureUnreadNotificationsAsTabPreference() configureEnableClientInfoRecordingPreference() }