Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 6defa64

Browse files
jdkorenGerrit Code Review
authored andcommitted
Merge "Add remote config flag for the Feed" into main
2 parents 549a69e + 10fc003 commit 6defa64

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

shared/src/main/java/com/google/samples/apps/iosched/shared/data/config/AppConfigDataSource.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ interface AppConfigDataSource {
3434
fun isSearchUsingRoomFeatureEnabled(): Boolean
3535
fun isAssistantAppFeatureEnabled(): Boolean
3636
fun isReservationFeatureEnabled(): Boolean
37+
fun isFeedEnabled(): Boolean
3738
}

shared/src/main/java/com/google/samples/apps/iosched/shared/data/config/RemoteAppConfigDataSource.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,11 @@ class RemoteAppConfigDataSource @Inject constructor(
9999
Pair(SANDBOXES_DAY3_END_TIME, MutableLiveData())
100100
)
101101

102-
private val cacheExpirySeconds: Long
102+
// Set cache expiration to 0s when debugging to allow easy testing, otherwise
103+
// use the default value.
104+
private val cacheExpirySeconds: Long = if (BuildConfig.DEBUG) 0 else DEFAULT_CACHE_EXPIRY_S
103105

104106
init {
105-
// Set cache expiration to 0s when debugging to allow easy testing, otherwise
106-
// use the default value
107-
cacheExpirySeconds = if (BuildConfig.DEBUG) {
108-
0
109-
} else {
110-
DEFAULT_CACHE_EXPIRY_S
111-
}
112107
firebaseRemoteConfig.fetch(cacheExpirySeconds).addOnCompleteListener { task ->
113108
// Async
114109
if (task.isSuccessful) {
@@ -175,6 +170,9 @@ class RemoteAppConfigDataSource @Inject constructor(
175170
override fun isReservationFeatureEnabled(): Boolean =
176171
firebaseRemoteConfig.getBoolean(RESERVATION_FEATURE_ENABLED)
177172

173+
override fun isFeedEnabled(): Boolean =
174+
firebaseRemoteConfig.getBoolean(FEED_FEATURE_ENABLED)
175+
178176
companion object {
179177
const val WIFI_SSID_KEY = "wifi_ssid"
180178
const val WIFI_PASSWORD_KEY = "wifi_password"
@@ -244,6 +242,7 @@ class RemoteAppConfigDataSource @Inject constructor(
244242
const val SEARCH_USING_ROOM_FEATURE_ENABLED = "search_using_room_enabled"
245243
const val ASSISTANT_APP_FEATURE_ENABLED = "io_assistant_app_enabled"
246244
const val RESERVATION_FEATURE_ENABLED = "reservation_enabled"
245+
const val FEED_FEATURE_ENABLED = "feed_enabled"
247246

248247
val DEFAULT_CACHE_EXPIRY_S = TimeUnit.MINUTES.toSeconds(12)
249248
}

shared/src/main/java/com/google/samples/apps/iosched/shared/di/FeatureFlagAnnotations.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,12 @@ annotation class AssistantAppEnabledFlag
7979
)
8080
@Retention(AnnotationRetention.BINARY)
8181
annotation class ReservationEnabledFlag
82+
83+
// Whether or not the Feed feature is enabled
84+
@Qualifier
85+
@Target(
86+
AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER,
87+
AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER
88+
)
89+
@Retention(AnnotationRetention.BINARY)
90+
annotation class FeedEnabledFlag

shared/src/main/java/com/google/samples/apps/iosched/shared/di/FeatureFlagsModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,10 @@ class FeatureFlagsModule {
6969
fun provideReservationEnabledFlag(appConfig: AppConfigDataSource): Boolean {
7070
return appConfig.isReservationFeatureEnabled()
7171
}
72+
73+
@Provides
74+
@FeedEnabledFlag
75+
fun provideFeedEnabledFlag(appConfig: AppConfigDataSource): Boolean {
76+
return appConfig.isReservationFeatureEnabled()
77+
}
7278
}

shared/src/main/res/xml/remote_config_defaults.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
<key>codelabs_enabled</key>
3636
<value>true</value>
3737
</entry>
38+
<entry>
39+
<key>feed_enabled</key>
40+
<value>false</value>
41+
</entry>
3842
<entry>
3943
<key>search_schedule_enabled</key>
4044
<value>true</value>

shared/src/staging/java/com/google/samples/apps/iosched/shared/data/FakeAppConfigDataSource.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,5 @@ class FakeAppConfigDataSource : AppConfigDataSource {
130130
override fun isSearchUsingRoomFeatureEnabled(): Boolean = true
131131
override fun isAssistantAppFeatureEnabled(): Boolean = false
132132
override fun isReservationFeatureEnabled(): Boolean = false
133+
override fun isFeedEnabled(): Boolean = false
133134
}

0 commit comments

Comments
 (0)