From 2c01d486e0b85cb65a58a1e6d5daf7cfe37e4ce6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 13 Dec 2023 14:51:50 +0100 Subject: [PATCH] Feature: add a `isFinished` boolean to filter out features from developer options screen. --- .../impl/developer/DeveloperSettingsPresenter.kt | 10 ++++++---- .../android/libraries/featureflag/api/Feature.kt | 7 +++++++ .../android/libraries/featureflag/api/FeatureFlags.kt | 11 ++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt index ae6c70188b..df0ea43ce9 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenter.kt @@ -75,10 +75,12 @@ class DeveloperSettingsPresenter @Inject constructor( .collectAsState(initial = null) LaunchedEffect(Unit) { - FeatureFlags.entries.forEach { feature -> - features[feature.key] = feature - enabledFeatures[feature.key] = featureFlagService.isFeatureEnabled(feature) - } + FeatureFlags.entries + .filter { it.isFinished.not() } + .forEach { feature -> + features[feature.key] = feature + enabledFeatures[feature.key] = featureFlagService.isFeatureEnabled(feature) + } } val featureUiModels = createUiModels(features, enabledFeatures) val coroutineScope = rememberCoroutineScope() diff --git a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/Feature.kt b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/Feature.kt index 8343bca8e4..ee98091953 100644 --- a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/Feature.kt +++ b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/Feature.kt @@ -36,4 +36,11 @@ interface Feature { * The default value of the feature (enabled or disabled). */ val defaultValue: Boolean + + /** + * Whether the feature is finished or not. + * If false: the feature is still in development, it will appear in the developer options screen to be able to enable it and test it. + * If true: the feature is finished, it will not appear in the developer options screen. + */ + val isFinished: Boolean } diff --git a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt index 9bb6d2f862..2b4de2ecb9 100644 --- a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt +++ b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt @@ -25,52 +25,61 @@ enum class FeatureFlags( override val key: String, override val title: String, override val description: String? = null, - override val defaultValue: Boolean + override val defaultValue: Boolean, + override val isFinished: Boolean, ) : Feature { LocationSharing( key = "feature.locationsharing", title = "Allow user to share location", defaultValue = true, + isFinished = true, ), Polls( key = "feature.polls", title = "Polls", description = "Create poll and render poll events in the timeline", defaultValue = true, + isFinished = true, ), NotificationSettings( key = "feature.notificationsettings", title = "Show notification settings", defaultValue = true, + isFinished = true, ), VoiceMessages( key = "feature.voicemessages", title = "Voice messages", description = "Send and receive voice messages", defaultValue = true, + isFinished = true, ), PinUnlock( key = "feature.pinunlock", title = "Pin unlock", description = "Allow user to lock/unlock the app with a pin code or biometrics", defaultValue = true, + isFinished = true, ), Mentions( key = "feature.mentions", title = "Mentions", description = "Type `@` to get mention suggestions and insert them", defaultValue = false, + isFinished = false, ), SecureStorage( key = "feature.securestorage", title = "Chat backup", description = "Allow access to backup and restore chat history settings", defaultValue = false, + isFinished = false, ), ReadReceipts( key = "feature.readreceipts", title = "Show read receipts", description = null, defaultValue = false, + isFinished = false, ), }