mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-05 12:54:35 +00:00
Make a diff between FeatureFlags.defaultValue and value returned by StaticFeatureFlagProvider.isFeatureEnabled().
Iterate after Ganfra's review.
This commit is contained in:
+3
-1
@@ -18,7 +18,8 @@ package io.element.android.libraries.featureflag.api
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* To enable or disable a FeatureFlags, change the `defaultValue` value.
|
* To enable or disable a FeatureFlags, change the `defaultValue` value.
|
||||||
* It will impact all the build types.
|
* Warning: to enable a flog for the release app, you MUST update the file
|
||||||
|
* [io.element.android.libraries.featureflag.impl.StaticFeatureFlagProvider]
|
||||||
*/
|
*/
|
||||||
enum class FeatureFlags(
|
enum class FeatureFlags(
|
||||||
override val key: String,
|
override val key: String,
|
||||||
@@ -40,6 +41,7 @@ enum class FeatureFlags(
|
|||||||
NotificationSettings(
|
NotificationSettings(
|
||||||
key = "feature.notificationsettings",
|
key = "feature.notificationsettings",
|
||||||
title = "Show notification settings",
|
title = "Show notification settings",
|
||||||
|
// Do not forget to edit StaticFeatureFlagProvider when enabling the feature.
|
||||||
defaultValue = false,
|
defaultValue = false,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -22,7 +22,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This provider is used for release build.
|
* This provider is used for release build.
|
||||||
* [isFeatureEnabled] just returns the default value of the FeatureFlags.
|
* This is the place to enable or disable feature for the release build.
|
||||||
*/
|
*/
|
||||||
class StaticFeatureFlagProvider @Inject constructor() :
|
class StaticFeatureFlagProvider @Inject constructor() :
|
||||||
FeatureFlagProvider {
|
FeatureFlagProvider {
|
||||||
@@ -31,7 +31,11 @@ class StaticFeatureFlagProvider @Inject constructor() :
|
|||||||
|
|
||||||
override suspend fun isFeatureEnabled(feature: Feature): Boolean {
|
override suspend fun isFeatureEnabled(feature: Feature): Boolean {
|
||||||
return if (feature is FeatureFlags) {
|
return if (feature is FeatureFlags) {
|
||||||
feature.defaultValue
|
when(feature) {
|
||||||
|
FeatureFlags.LocationSharing -> true
|
||||||
|
FeatureFlags.Polls -> true
|
||||||
|
FeatureFlags.NotificationSettings -> false
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user