add puke event

This commit is contained in:
2025-09-25 23:52:10 +02:00
parent eeebaeb7f3
commit 57504573f4
7 changed files with 82 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ class NumericUtils (val context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val measurementSystem = LocaleData.getMeasurementSystem(ULocale.getDefault())
return (measurementSystem == LocaleData. MeasurementSystem.SI)
} else {
} else {
val locale = context.resources.configuration.locale
return when (locale.country) {
// https://en.wikipedia.org/wiki/United_States_customary_units
@@ -29,7 +29,7 @@ class NumericUtils (val context: Context) {
"GB", "MM", "LR" -> false // IMPERIAL
else -> true // UnitSystem.METRIC
}
}
}
}
init {
@@ -62,11 +62,15 @@ class NumericUtils (val context: Context) {
fun formatEventQuantity(item: LunaEvent): String {
val formatted = StringBuilder()
if ((item.quantity ?: 0) > 0) {
if (item.type == LunaEvent.TYPE_TEMPERATURE)
formatted.append((item.quantity / 10.0f).toString())
else
formatted.append(item.quantity)
if (item.quantity > 0) {
formatted.append(when (item.type) {
LunaEvent.TYPE_TEMPERATURE ->
(item.quantity / 10.0f).toString()
LunaEvent.TYPE_PUKE ->
context.resources.getStringArray(R.array.AmountLabels)[item.quantity]
else ->
item.quantity
})
formatted.append(" ")
formatted.append(