Skip to content

Commit

Permalink
🚑 Fix crashes in Wrapped (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jheubuch authored Dec 8, 2024
1 parent eec61e9 commit 7b18a55
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ data class YearInReviewSumStats(
)

data class TopByDistance(
val operator: String,
val operator: String?,
val distance: Long,
val line: String?
)
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/kotlin/de/hbch/traewelling/ui/wrapped/Wrapped.kt
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fun WrappedOperatorDistance(
val annotatedString = buildAnnotatedString {
appendLine(stringResource(R.string.wrapped_farest_travels))
appendLine()
val distanceOperator = yearInReviewData.operators.topByDistance.operator
val distanceOperator = yearInReviewData.operators.topByDistance.operator ?: stringResource(R.string.unknown)
withStyle(primarySpanStyle.merge(largeSpanStyle).merge(SpanStyle(fontFamily = getBTModern(distanceOperator)))) {
withStyle(centerAlignedStyle) {
appendLine(distanceOperator)
Expand Down Expand Up @@ -481,7 +481,7 @@ fun WrappedMostLikedTrip(
yearInReviewData: YearInReviewData,
modifier: Modifier = Modifier
) {
val status = yearInReviewData.mostLikedStatuses.first().status
val status = yearInReviewData.mostLikedStatuses.firstOrNull()?.status
WrappedScaffold(
graphicsLayer = graphicsLayer,
modifier = modifier,
Expand All @@ -494,9 +494,13 @@ fun WrappedMostLikedTrip(
)
}
) {
val text = if (status == null)
stringResource(id = R.string.wrapped_no_likes)
else
stringResource(id = R.string.wrapped_your_most_liked_trip, status.likes ?: 0, getLocalDateString(status.journey.origin.departurePlanned))
Text(
modifier = it,
text = stringResource(id = R.string.wrapped_your_most_liked_trip, status.likes ?: 0, getLocalDateString(status.journey.origin.departurePlanned)),
text = text,
style = AppTypography.titleLarge,
textAlign = TextAlign.Center
)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@
<string name="wrapped_your_unpunctual_trip">Deine bei Ankunft unpünktlichste Fahrt war am %1$s</string>
<string name="wrapped_most_liked">Herzensbrecher! 💘</string>
<string name="wrapped_your_most_liked_trip">Du hast deine meisten Gefällt-mir-Angaben (%1$d) am %2$s erhalten.</string>
<string name="wrapped_no_likes">Du hast dieses Jahr keine Gefällt-mir-Angaben erhalten.</string>
<string name="wrapped_top_destinations">Gewohnheitstier 🦥</string>
<string name="wrapped_your_top_destinations">Du hast diese Orte besonders oft besucht…</string>
<string name="wrapped_lonely_destinations">Entdecker! 🧑🏼‍🔬</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nb-rNO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
<string name="and">og</string>
<string name="wrapped_line_distance">Den linjen du reiste lengst med var</string>
<string name="wrapped_your_most_liked_trip">Du fikk flest \"Liker det\"-meldinger (%1$d) den %2$s</string>
<string name="wrapped_no_likes">Du fikk ingen \"Liker det\"-meldinger i året.</string>
<string name="wrapped_top_destinations">Vanemenneske 🦥</string>
<string name="wrapped_your_top_destinations">Disse stedene har du besøkt oftest…</string>
<string name="wrapped_favorite_lines">Dine favorittlinjer! 🤗</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
<string name="wrapped_your_unpunctual_trip">Your most unpunctual trip on arrival was at %1$s</string>
<string name="wrapped_most_liked">Heartbreaker! 💘</string>
<string name="wrapped_your_most_liked_trip">You received the most likes (%1$d) at %2$s</string>
<string name="wrapped_no_likes">You received no likes this year.</string>
<string name="wrapped_top_destinations">Creature of habit 🦥</string>
<string name="wrapped_your_top_destinations">You visited those places a lot…</string>
<string name="wrapped_lonely_destinations">Explorer! 🧑🏼‍🔬</string>
Expand Down

0 comments on commit 7b18a55

Please sign in to comment.