Skip to content

Commit

Permalink
🚩 Remove stale feature flag (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
jheubuch authored Mar 28, 2024
1 parent ec63d57 commit 8c0c57d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]/3"
Expand All @@ -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://[email protected]/2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) } ?: ""
Expand Down Expand Up @@ -151,7 +147,7 @@ fun DateTimeSelection(
)
},
trailingIcon = {
if (allowManualTimeDeletion && dateTime != null) {
if (dateTime != null) {
IconButton(onClick = {
dateTime = null
dateSelected(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -83,6 +84,7 @@ fun SearchConnection(
var loading by remember { mutableStateOf(false) }
var searchConnections by remember { mutableStateOf(true) }
var selectedFilter by remember { mutableStateOf<FilterType?>(null) }
val userTest by FeatureFlags.getInstance().userTest.observeAsState(false)

LaunchedEffect(searchConnections, selectedFilter) {
if (searchConnections) {
Expand All @@ -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
},
{ }
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/kotlin/de/hbch/traewelling/util/Adapters.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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
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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8c0c57d

Please sign in to comment.