Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into kb-android-backgrounding
Browse files Browse the repository at this point in the history
  • Loading branch information
KaylaBrady committed Dec 17, 2024
2 parents bb03d77 + a8e3e16 commit 46dc1ed
Show file tree
Hide file tree
Showing 40 changed files with 487 additions and 236 deletions.
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.1012.0)
aws-sdk-core (3.213.0)
aws-partitions (1.1023.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.173.0)
aws-sdk-s3 (1.176.1)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -131,7 +131,7 @@ GEM
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.225.0)
fastlane (2.226.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -171,7 +171,7 @@ GEM
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty (~> 0.4.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
Expand Down Expand Up @@ -218,13 +218,13 @@ GEM
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.7)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
json (2.8.2)
json (2.9.0)
jwt (2.9.3)
base64
logger (1.6.1)
Expand Down Expand Up @@ -258,8 +258,8 @@ GEM
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.3.9)
rouge (2.0.7)
rexml (3.4.0)
rouge (3.28.0)
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand Down Expand Up @@ -296,8 +296,8 @@ GEM
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty (0.4.0)
rouge (~> 3.28.0)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)

Expand Down
1 change: 1 addition & 0 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ task<ConvertIosMapIconsTask>("convertIosIconsToAssets") {
}

task<ConvertIosLocalizationTask>("convertIosLocalization") {
androidEnglishStrings = layout.projectDirectory.file("src/main/res/values/strings.xml")
xcstrings = layout.projectDirectory.file("../iosApp/iosApp/Localizable.xcstrings")
resources = layout.projectDirectory.dir("src/main/res")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ContentViewTests : KoinTest {
composeTestRule.onNodeWithText("MBTA Go").assertIsDisplayed()

composeTestRule.onNodeWithText("Nearby").performClick()
composeTestRule.onNodeWithText("Nearby transit").assertIsDisplayed()
composeTestRule.onNodeWithText("Nearby Transit").assertIsDisplayed()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DirectionPickerTest {
null,
stop,
patterns,
listOf(Direction("A", null, 0), Direction("B", null, 1))
listOf(Direction("North", null, 0), Direction("South", null, 1))
)
var filter: StopDetailsFilter? = StopDetailsFilter(routeId = route.id, directionId = 0)
composeTestRule.setContent {
Expand All @@ -57,8 +57,8 @@ class DirectionPickerTest {
}
}

composeTestRule.onNodeWithText("A").assertIsDisplayed()
composeTestRule.onNodeWithText("B").performClick()
composeTestRule.onNodeWithText("Northbound").assertIsDisplayed()
composeTestRule.onNodeWithText("Southbound").performClick()
assertTrue(filter?.routeId == route.id)
assertTrue(filter?.directionId == 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class HeadsignRowViewTest {
init("Somewhere", RealtimePatterns.Format.None(secondaryAlert = null))

composeTestRule.onNodeWithText("Somewhere").assertIsDisplayed()
composeTestRule.onNodeWithText("No Predictions").assertIsDisplayed()
composeTestRule.onNodeWithText("Predictions unavailable").assertIsDisplayed()
}

@Test
Expand All @@ -107,7 +107,7 @@ class HeadsignRowViewTest {
)

composeTestRule.onNodeWithText("Somewhere").assertIsDisplayed()
composeTestRule.onNodeWithText("No Predictions").assertIsDisplayed()
composeTestRule.onNodeWithText("Predictions unavailable").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Alert").assertIsDisplayed()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PinButtonTest {
PinButton(pinned = false, color = Color.Unspecified) { wasTapped = true }
}

composeTestRule.onNodeWithContentDescription("pin route").performClick()
composeTestRule.onNodeWithContentDescription("Star route").performClick()
assertTrue(wasTapped)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.mbta.tid.mbta_app.android.component

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import com.mbta.tid.mbta_app.model.Route
import com.mbta.tid.mbta_app.model.RouteType
Expand Down Expand Up @@ -31,7 +30,6 @@ class RouteHeaderTest {
)
}
composeTestRule.onNodeWithText("Short name").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Bus").assertIsDisplayed()
}

@Test
Expand All @@ -53,7 +51,6 @@ class RouteHeaderTest {
)
}
composeTestRule.onNodeWithText("Long name").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Ferry").assertIsDisplayed()
}

@Test
Expand All @@ -75,7 +72,6 @@ class RouteHeaderTest {
)
}
composeTestRule.onNodeWithText("Long name").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Commuter Rail").assertIsDisplayed()
}

@Test
Expand All @@ -97,6 +93,5 @@ class RouteHeaderTest {
)
}
composeTestRule.onNodeWithText("Long name").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Subway").assertIsDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.rule.GrantPermissionRule
import com.mapbox.geojson.FeatureCollection
import com.mapbox.maps.MapboxExperimental
import com.mapbox.maps.extension.compose.animation.viewport.rememberMapViewportState
import com.mbta.tid.mbta_app.android.location.MockFusedLocationProviderClient
Expand All @@ -25,14 +26,18 @@ import com.mbta.tid.mbta_app.android.pages.NearbyTransit
import com.mbta.tid.mbta_app.android.pages.NearbyTransitPage
import com.mbta.tid.mbta_app.android.util.LocalActivity
import com.mbta.tid.mbta_app.android.util.LocalLocationClient
import com.mbta.tid.mbta_app.map.RouteLineData
import com.mbta.tid.mbta_app.model.Coordinate
import com.mbta.tid.mbta_app.model.GlobalMapData
import com.mbta.tid.mbta_app.model.LocationType
import com.mbta.tid.mbta_app.model.NearbyStaticData
import com.mbta.tid.mbta_app.model.ObjectCollectionBuilder
import com.mbta.tid.mbta_app.model.RouteType
import com.mbta.tid.mbta_app.model.Stop
import com.mbta.tid.mbta_app.model.response.AlertsStreamDataResponse
import com.mbta.tid.mbta_app.model.response.ApiResult
import com.mbta.tid.mbta_app.model.response.GlobalResponse
import com.mbta.tid.mbta_app.model.response.MapFriendlyRouteResponse
import com.mbta.tid.mbta_app.model.response.NearbyResponse
import com.mbta.tid.mbta_app.model.response.PredictionsByStopJoinResponse
import com.mbta.tid.mbta_app.model.response.PredictionsByStopMessageResponse
Expand Down Expand Up @@ -286,7 +291,7 @@ class NearbyTransitPageTest : KoinTest {

composeTestRule.waitUntilDoesNotExist(hasText("Loading..."))

composeTestRule.onNodeWithText("Nearby transit").assertIsDisplayed()
composeTestRule.onNodeWithText("Nearby Transit").assertIsDisplayed()

composeTestRule.onNodeWithText("Green Line Long Name").assertExists()
composeTestRule.onNodeWithText("Green Line Stop").assertExists()
Expand All @@ -306,12 +311,30 @@ class NearbyTransitPageTest : KoinTest {
open class MockMapVM : IMapViewModel {
var mutableLastErrorTimestamp = MutableStateFlow<Instant?>(null)
override var lastMapboxErrorTimestamp: Flow<Instant?> = mutableLastErrorTimestamp
override var railRouteLineData: Flow<List<RouteLineData>?> =
MutableStateFlow(value = null)
override var stopSourceData: Flow<FeatureCollection?> = MutableStateFlow(value = null)
override var globalResponse: Flow<GlobalResponse?> = MutableStateFlow(value = null)
override var railRouteShapes: Flow<MapFriendlyRouteResponse?> =
MutableStateFlow(value = null)

var loadConfigCalledCount = 0

override suspend fun loadConfig() {
loadConfigCalledCount += 1
}

override fun globalMapData(now: Instant): GlobalMapData? {
return null
}

override suspend fun refreshRouteLineData(now: Instant) {}

override suspend fun refreshStopFeatures(now: Instant, selectedStop: Stop?) {}

override suspend fun setAlertsData(alertsData: AlertsStreamDataResponse?) {}

override suspend fun setGlobalResponse(globalResponse: GlobalResponse?) {}
}

val mockMapVM = MockMapVM()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class NearbyTransitViewTest : KoinTest {
}
}

composeTestRule.onNodeWithText("Nearby transit").assertIsDisplayed()
composeTestRule.onNodeWithText("Nearby Transit").assertIsDisplayed()
composeTestRule.onNodeWithText("Sample Route").assertIsDisplayed()
composeTestRule.onNodeWithText("Sample Headsign").assertIsDisplayed()
composeTestRule.onNodeWithText("1 min").assertIsDisplayed()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mbta.tid.mbta_app.android.component

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
Expand All @@ -11,18 +12,19 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.mbta.tid.mbta_app.android.R

enum class ActionButtonKind(
val iconSize: Dp,
val accessibilityLabel: String,
@StringRes val accessibilityLabel: Int,
@DrawableRes val image: Int
) {
Back(14.dp, "Back", R.drawable.fa_chevron_left),
Close(10.dp, "Close", R.drawable.fa_xmark)
Back(14.dp, R.string.back_button_label, R.drawable.fa_chevron_left),
Close(10.dp, R.string.close_button_label, R.drawable.fa_xmark)
}

@Composable
Expand All @@ -38,7 +40,11 @@ fun ActionButton(kind: ActionButtonKind, action: () -> Unit) {
),
contentPadding = PaddingValues(5.dp)
) {
Icon(painterResource(kind.image), kind.accessibilityLabel, Modifier.size(kind.iconSize))
Icon(
painterResource(kind.image),
stringResource(kind.accessibilityLabel),
Modifier.size(kind.iconSize)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.mbta.tid.mbta_app.android.R
import com.mbta.tid.mbta_app.model.StopAlertState

Expand All @@ -21,7 +22,7 @@ fun AlertIcon(alertState: StopAlertState, color: Color?, modifier: Modifier = Mo

Icon(
painterResource(iconId),
contentDescription = alertState.name,
contentDescription = stringResource(R.string.alert),
modifier,
tint = color ?: colorResource(R.color.text)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ fun BottomNavIconButton(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Icon(
painterResource(icon),
contentDescription = "@null",
modifier = Modifier.size(24.dp)
)
Icon(painterResource(icon), contentDescription = null, modifier = Modifier.size(24.dp))
Spacer(modifier = Modifier.height(4.dp))
Text(label, style = MaterialTheme.typography.labelSmall, fontWeight = FontWeight.Bold)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mbta.tid.mbta_app.android.component

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -10,25 +11,36 @@ import androidx.compose.ui.unit.sp
import com.mbta.tid.mbta_app.android.R
import com.mbta.tid.mbta_app.model.Direction

private val reformatDirectionNames = setOf("North", "South", "East", "West")
private val localizedDirectionNames: Map<String, Int> =
mapOf(
"North" to R.string.northbound,
"South" to R.string.southbound,
"East" to R.string.eastbound,
"West" to R.string.westbound,
"Inbound" to R.string.inbound,
"Outbound" to R.string.outbound,
)

@StringRes
private fun directionNameFormatted(direction: Direction) =
if (reformatDirectionNames.contains(direction.name)) "${direction.name}bound"
else direction.name
localizedDirectionNames[direction.name] ?: R.string.heading

@Composable
fun DirectionLabel(direction: Direction, modifier: Modifier = Modifier) {
val destination = direction.destination
Column {
Column(modifier = modifier) {
if (destination != null) {
Text(
stringResource(R.string.directionTo, directionNameFormatted(direction)),
stringResource(
R.string.directionTo,
stringResource(directionNameFormatted(direction))
),
fontSize = 13.sp
)
Text(destination, fontSize = 17.sp, fontWeight = FontWeight.SemiBold)
} else {
Text(
directionNameFormatted(direction),
stringResource(directionNameFormatted(direction)),
fontSize = 17.sp,
fontWeight = FontWeight.SemiBold
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.mbta.tid.mbta_app.android.R

Expand All @@ -24,7 +25,7 @@ fun PinButton(pinned: Boolean, color: Color, action: () -> Unit) {
if (pinned) R.drawable.pinned_route_active
else R.drawable.pinned_route_inactive
),
contentDescription = "pin route",
contentDescription = stringResource(R.string.pin_route),
modifier = Modifier.size(20.dp),
tint = color
)
Expand Down
Loading

0 comments on commit 46dc1ed

Please sign in to comment.