mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 20:01:55 +00:00
To avoid mistake, FeatureFlags does not have defaultValue set to true, and StaticFeatureFlagProvider return the default value.
This fixes #1241.
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
Enable polls in release build.
|
||||||
+7
-2
@@ -16,21 +16,26 @@
|
|||||||
|
|
||||||
package io.element.android.libraries.featureflag.api
|
package io.element.android.libraries.featureflag.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To enable or disable a FeatureFlags, change the `defaultValue` value.
|
||||||
|
* It will impact all the build types.
|
||||||
|
*/
|
||||||
enum class FeatureFlags(
|
enum class FeatureFlags(
|
||||||
override val key: String,
|
override val key: String,
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val description: String? = null,
|
override val description: String? = null,
|
||||||
override val defaultValue: Boolean = true
|
override val defaultValue: Boolean
|
||||||
) : Feature {
|
) : Feature {
|
||||||
LocationSharing(
|
LocationSharing(
|
||||||
key = "feature.locationsharing",
|
key = "feature.locationsharing",
|
||||||
title = "Allow user to share location",
|
title = "Allow user to share location",
|
||||||
|
defaultValue = true,
|
||||||
),
|
),
|
||||||
Polls(
|
Polls(
|
||||||
key = "feature.polls",
|
key = "feature.polls",
|
||||||
title = "Polls",
|
title = "Polls",
|
||||||
description = "Create poll and render poll events in the timeline",
|
description = "Create poll and render poll events in the timeline",
|
||||||
defaultValue = false,
|
defaultValue = true,
|
||||||
),
|
),
|
||||||
NotificationSettings(
|
NotificationSettings(
|
||||||
key = "feature.notificationsettings",
|
key = "feature.notificationsettings",
|
||||||
|
|||||||
+2
-6
@@ -22,7 +22,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This provider is used for release build.
|
* This provider is used for release build.
|
||||||
* Change the value return by [isFeatureEnabled] to enable/disable features.
|
* [isFeatureEnabled] just returns the default value of the FeatureFlags.
|
||||||
*/
|
*/
|
||||||
class StaticFeatureFlagProvider @Inject constructor() :
|
class StaticFeatureFlagProvider @Inject constructor() :
|
||||||
FeatureFlagProvider {
|
FeatureFlagProvider {
|
||||||
@@ -31,11 +31,7 @@ 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) {
|
||||||
when (feature) {
|
feature.defaultValue
|
||||||
FeatureFlags.LocationSharing -> true
|
|
||||||
FeatureFlags.Polls -> false
|
|
||||||
FeatureFlags.NotificationSettings -> false
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user