From 8c0c57d4b94c896971dc40d27f6d2746f0b09b95 Mon Sep 17 00:00:00 2001 From: Jonas Heubuch Date: Thu, 28 Mar 2024 18:08:58 +0100 Subject: [PATCH] :triangular_flag_on_post: Remove stale feature flag (#339) --- app/build.gradle | 4 ++-- .../main/kotlin/de/hbch/traewelling/shared/FeatureFlags.kt | 6 +++--- .../kotlin/de/hbch/traewelling/theme/TraewelldroidTheme.kt | 6 +++++- .../traewelling/ui/composables/ManualDateTimeSelection.kt | 6 +----- .../traewelling/ui/searchConnection/SearchConnection.kt | 4 +++- app/src/main/kotlin/de/hbch/traewelling/util/Adapters.kt | 6 ++++++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8aff591c..b39cd880 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -64,7 +64,7 @@ android { buildConfigField "String", "REPO_URL", "\"https://github.com/Traewelldroid/traewelldroid\"" buildConfigField "String", "PRIVACY_URL", "\"https://traewelldroid.de/privacy\"" buildConfigField "String", "UNLEASH_URL", "\"https://unleash.traewelldroid.de/api/frontend\"" - buildConfigField "String", "UNLEASH_KEY", "\"*:production.35c591bf9e4fd8eada44bc1d51fe5261e407779280ddf3dec0e00d68\"" + buildConfigField "String", "UNLEASH_KEY", "\"default:production.286fca3aac1497f85ed886b3339c65cdfea9d5f52450524325398461\"" buildConfigField "String", "WEBHOOK_URL", "\"https://webhook.traewelldroid.de\"" buildConfigField "String", "UP_FCM_PROXY", "\"https://push.traewelldroid.de/FCM\"" manifestPlaceholders["SENTRY_DSN"] = "https://9664595fcad94b6c90fe2021ab1ec3f0@sentry.traewelldroid.de/3" @@ -77,7 +77,7 @@ android { buildConfigField "String", "REPO_URL", "\"https://github.com/Traewelldroid/traewelldroid\"" buildConfigField "String", "PRIVACY_URL", "\"https://traewelldroid.de/privacy\"" buildConfigField "String", "UNLEASH_URL", "\"https://unleash.traewelldroid.de/api/frontend\"" - buildConfigField "String", "UNLEASH_KEY", "\"*:development.ce069ae01e960f412f694c4a3afc3bd3e4dccbb21102c8eb36e99781\"" + buildConfigField "String", "UNLEASH_KEY", "\"default:development.52c54a43ebad9b9a668a69410b57cc19e44e19ab1ee40b4dd3f49b38\"" buildConfigField "String", "WEBHOOK_URL", "\"https://webhooktest.traewelldroid.de\"" buildConfigField "String", "UP_FCM_PROXY", "\"https://push.traewelldroid.de/FCM\"" manifestPlaceholders["SENTRY_DSN"] = "https://8421286d211d475cb0343fd1aff3fc06@sentry.traewelldroid.de/2" diff --git a/app/src/main/kotlin/de/hbch/traewelling/shared/FeatureFlags.kt b/app/src/main/kotlin/de/hbch/traewelling/shared/FeatureFlags.kt index 6fc7eca4..566c3cfa 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/shared/FeatureFlags.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/shared/FeatureFlags.kt @@ -20,12 +20,12 @@ class FeatureFlags private constructor() { fun flagsUpdated() { unleashClient?.let { - allowManualTimeDeletion.postValue( - it.isEnabled("AllowManualTimeDeletion", false) + userTest.postValue( + it.isEnabled("UserTest", false) ) } } // Add feature flags as LiveData so they can be state-subscribed in Compose - val allowManualTimeDeletion = MutableLiveData(false) + val userTest = MutableLiveData(false) } diff --git a/app/src/main/kotlin/de/hbch/traewelling/theme/TraewelldroidTheme.kt b/app/src/main/kotlin/de/hbch/traewelling/theme/TraewelldroidTheme.kt index 2a0cb9bc..fdf5e12d 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/theme/TraewelldroidTheme.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/theme/TraewelldroidTheme.kt @@ -10,11 +10,14 @@ import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import com.google.accompanist.systemuicontroller.rememberSystemUiController +import de.hbch.traewelling.shared.FeatureFlags private val DarkColorScheme = darkColorScheme( primary = TraewelldroidDark, @@ -44,10 +47,11 @@ fun MainTheme( dynamicColor: Boolean = true, content: @Composable () -> Unit ) { + val userTest by FeatureFlags.getInstance().userTest.observeAsState(false) val view = LocalView.current val context = LocalContext.current val systemUiController = rememberSystemUiController() - val darkTheme = isSystemInDarkTheme() + val darkTheme = if (userTest) !isSystemInDarkTheme() else isSystemInDarkTheme() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { // Set polyline color to default primary light color diff --git a/app/src/main/kotlin/de/hbch/traewelling/ui/composables/ManualDateTimeSelection.kt b/app/src/main/kotlin/de/hbch/traewelling/ui/composables/ManualDateTimeSelection.kt index f8619835..970dc6bd 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/ui/composables/ManualDateTimeSelection.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/ui/composables/ManualDateTimeSelection.kt @@ -19,7 +19,6 @@ import androidx.compose.material3.rememberDatePickerState import androidx.compose.material3.rememberTimePickerState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -32,7 +31,6 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import de.hbch.traewelling.R -import de.hbch.traewelling.shared.FeatureFlags import de.hbch.traewelling.theme.AppTypography import de.hbch.traewelling.theme.MainTheme import de.hbch.traewelling.util.getLocalDateTimeString @@ -50,8 +48,6 @@ fun DateTimeSelection( dateSelected: (ZonedDateTime?) -> Unit = { } ) { val initDateTime = initDate ?: plannedDate ?: ZonedDateTime.now() - val allowManualTimeDeletion by - FeatureFlags.getInstance().allowManualTimeDeletion.observeAsState(false) var dateTime by remember { mutableStateOf(initDate) } val dateTimeText = dateTime?.let { getLocalDateTimeString(it) } ?: "" @@ -151,7 +147,7 @@ fun DateTimeSelection( ) }, trailingIcon = { - if (allowManualTimeDeletion && dateTime != null) { + if (dateTime != null) { IconButton(onClick = { dateTime = null dateSelected(null) diff --git a/app/src/main/kotlin/de/hbch/traewelling/ui/searchConnection/SearchConnection.kt b/app/src/main/kotlin/de/hbch/traewelling/ui/searchConnection/SearchConnection.kt index 69479ec8..6cfe41b8 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/ui/searchConnection/SearchConnection.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/ui/searchConnection/SearchConnection.kt @@ -47,6 +47,7 @@ import de.hbch.traewelling.api.models.trip.HafasTrip import de.hbch.traewelling.api.models.trip.ProductType import de.hbch.traewelling.shared.BottomSearchViewModel import de.hbch.traewelling.shared.CheckInViewModel +import de.hbch.traewelling.shared.FeatureFlags import de.hbch.traewelling.shared.LoggedInUserViewModel import de.hbch.traewelling.theme.AppTypography import de.hbch.traewelling.theme.MainTheme @@ -83,6 +84,7 @@ fun SearchConnection( var loading by remember { mutableStateOf(false) } var searchConnections by remember { mutableStateOf(true) } var selectedFilter by remember { mutableStateOf(null) } + val userTest by FeatureFlags.getInstance().userTest.observeAsState(false) LaunchedEffect(searchConnections, selectedFilter) { if (searchConnections) { @@ -95,7 +97,7 @@ fun SearchConnection( loading = false searchConnections = false trips.clear() - trips.addAll(it.data) + trips.addAll(if (userTest) it.data.shuffled() else it.data) stationName = it.meta.station.name }, { } diff --git a/app/src/main/kotlin/de/hbch/traewelling/util/Adapters.kt b/app/src/main/kotlin/de/hbch/traewelling/util/Adapters.kt index 0dbdbada..349abf43 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/util/Adapters.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/util/Adapters.kt @@ -1,6 +1,8 @@ package de.hbch.traewelling.util import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource @@ -8,6 +10,7 @@ import com.auth0.android.jwt.JWT import de.hbch.traewelling.R import de.hbch.traewelling.api.models.station.Station import de.hbch.traewelling.api.models.trip.HafasTrip +import de.hbch.traewelling.shared.FeatureFlags import java.lang.Exception import java.time.Duration import java.time.Instant @@ -124,6 +127,9 @@ fun getStationNameWithRL100(station: Station): String = @Composable fun getGreeting(): String { val time = LocalDateTime.now() + val userTest by FeatureFlags.getInstance().userTest.observeAsState(false) + + if (userTest) return "April, April! 🤡😜😏" return when (time.hour) { in 5..11 -> stringResource(id = R.string.greeting_morning)