Modern Apps git

← Modern-Apps.git

health: show Today hydration in milliliters, not liters

Commit
4976dc09785e1130c0ded977d05f43473afbfeab
Author
Vayun Mathur <[email protected]>
When
2026-11-07 19:56 UTC (29 days ago)
Parents
2c8161a
Symptom: drinking 1.5 L showed as "1 ml" on Today (1000x too small).

Root cause: Hydration Record.value is liters everywhere (logHydration,
Health Connect Volume.liters, sync volume.inLiters), but TodayPage fed
the liter sum straight into TodayUiState.hydrationMl, which TodayScreen
renders with unit_ml via toInt().

Fix: convert liters to milliliters in the Today binder (x1000), the
one place that promises ml. Chart (L) and NutritionDetails (L) paths
already use liters correctly and are untouched.

Verification: code trace TodayPage -> HealthUiContract -> TodayScreen
(unit_ml); full test/compile run after all fixes.

Diff

health/src/main/java/com/vayunmathur/health/ui/TodayPage.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/TodayPage.kt b/health/src/main/java/com/vayunmathur/health/ui/TodayPage.ktindex dc34933610..3acd3e3cb2 100644--- a/health/src/main/java/com/vayunmathur/health/ui/TodayPage.kt+++ b/health/src/main/java/com/vayunmathur/health/ui/TodayPage.kt@@ -83,8 +83,9 @@ fun TodayPage(backStack: NavBackStack<Route>, viewModel: HealthViewModel) {     val floorsToday by remember(dayStart, dayEnd) {         viewModel.sumInRange(RecordType.Floors, dayStart, dayEnd)     }.collectAsState(0.0)+    // Hydration records store liters; TodayUiState.hydrationMl / unit_ml need milliliters.     val hydrationToday by remember(dayStart, dayEnd) {-        viewModel.sumInRange(RecordType.Hydration, dayStart, dayEnd)+        viewModel.sumInRange(RecordType.Hydration, dayStart, dayEnd).map { it * 1000.0 }     }.collectAsState(0.0)     val hrMax by remember(dayStart, dayEnd) {         viewModel.maxInRange(RecordType.HeartRate, dayStart, dayEnd).map { it?.toLong() ?: 0L }