From b3b1844a670eaf89ca41d572d870efa2e8113873 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 17 Sep 2026 16:18:19 +0000 Subject: [PATCH] fix: translate the call timer, and stop folding hours into its minutes field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call timer's formatDuration had a different problem from the workout one — no English words, just "%02d:%02d" — but two real ones underneath. A call past an hour rendered as "65:12": hours were folded into the minutes field rather than shown. It now switches to a three-field form at an hour and keeps the two-field form below it, so a five-minute call still reads "05:23" rather than the "00:05:23" that reusing DurationTag.formatTime would have given. The pattern moves into string resources. The separator and field order belong to the translator, and String.format without an explicit locale follows the JVM-wide default rather than the locale Compose is configured with — not the same thing in an app that ships its own language picker, where the two can disagree on digit shaping. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_019egdJyBHnrATZHjs86up8f --- .../amethyst/ui/call/CallWidgets.kt | 24 +++++++++++++++++-- .../composeResources/values/strings.xml | 5 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/call/CallWidgets.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/call/CallWidgets.kt index 8e7041e7d6..faaa4d5eb9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/call/CallWidgets.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/call/CallWidgets.kt @@ -50,6 +50,8 @@ import androidx.compose.ui.unit.sp import androidx.compose.ui.viewinterop.AndroidView import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.call_calling +import com.vitorpamplona.amethyst.commons.resources.call_duration_hours_minutes_seconds +import com.vitorpamplona.amethyst.commons.resources.call_duration_minutes_seconds import com.vitorpamplona.amethyst.ui.note.BaseUserPicture import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture import com.vitorpamplona.amethyst.ui.note.UsernameDisplay @@ -400,10 +402,28 @@ fun GroupCallNames( } } +/** + * Elapsed call time as a clock: `05:23`, and `1:05:23` once the call passes an hour. + * + * Hours are not folded into the minutes field — the previous version rendered a 65-minute call + * as "65:12". + * + * The pattern comes from a string resource rather than a literal so the separator and field + * order stay the translator's, and so the numbers are formatted with the locale Compose is + * configured with. `String.format` without an explicit locale follows the JVM-wide default, + * which is not the same thing in an app that has its own language picker. + */ +@Composable fun formatDuration(seconds: Long): String { - val mins = seconds / 60 + val hours = seconds / 3600 + val mins = (seconds % 3600) / 60 val secs = seconds % 60 - return "%02d:%02d".format(mins, secs) + + return if (hours > 0) { + stringRes(Res.string.call_duration_hours_minutes_seconds, hours, mins, secs) + } else { + stringRes(Res.string.call_duration_minutes_seconds, mins, secs) + } } @Composable diff --git a/commonsUI/src/commonMain/composeResources/values/strings.xml b/commonsUI/src/commonMain/composeResources/values/strings.xml index 053702457f..0cdb97a43e 100644 --- a/commonsUI/src/commonMain/composeResources/values/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values/strings.xml @@ -1296,6 +1296,11 @@ Calling\u2026 Connecting\u2026 Call ended + + %1$02d:%2$02d + %1$d:%2$02d:%3$02d Dismiss Switch camera Voice call