Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix crash on check-in to manual trips #370

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ data class StatusPointCalculation(
@SerializedName("base") val base: Float,
@SerializedName("distance") val distance: Float,
@SerializedName("factor") val factor: Float,
@SerializedName("reason") val reason: PointReason
)
@SerializedName("reason") val reason: PointReason?
) {
val safeReason get() = reason ?: PointReason.UNKNOWN
}

@Suppress("unused")
enum class PointReason {
Expand All @@ -32,6 +34,13 @@ enum class PointReason {
@SerializedName("3")
FORCED {
override fun getExplanation() = R.string.point_reason_forced
},
@SerializedName("4")
MANUAL {
override fun getExplanation() = R.string.point_reason_manual
},
UNKNOWN {
override fun getExplanation() = null
};

abstract fun getExplanation(): Int?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private fun SuccessfulCheckInResult(
isOwnStatus = true,
defaultVisibility = loggedInUserViewModel.defaultStatusVisibility
)
val pointReasonText = checkInResponse.data.points.calculation.reason.getExplanation()
val pointReasonText = checkInResponse.data.points.calculation.safeReason.getExplanation()
if (pointReasonText != null) {
Text(
modifier = Modifier.fillMaxWidth(),
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@
Punkte zu erhalten.
</string>
<string name="point_reason_forced">
Weil du diesen Check-In erzwungen hast, hast du nur 0 Punkte erhalten.
Weil du diesen Check-In erzwungen hast, hast du nicht alle Punkte erhalten.
</string>
<string name="point_reason_manual">
Weil du in eine manuell erstellte Fahrt eingecheckt hast, hast du keine Punkte erhalten.
</string>
<string name="title_share">Teilen</string>
<string name="or">oder</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<string name="point_reason_forced">
Because you forced this check-in, you received 0 points.
</string>
<string name="point_reason_manual">
Because you checked into a manual trip, you received 0 points.
</string>
<string name="title_share">Share</string>
<string name="version_with_code" translatable="false">v%1$s (%2$d)</string>
<string name="or">or</string>
Expand Down
Loading