Modern Apps git

← Modern-Apps.git

library: pluralise the moves box TalkBack description (#ux-audit)

Commit
881108f8cf17e4a97620c69585971a87bbec38ed
Author
Vayun Mathur <[email protected]>
When
2026-11-13 08:37 UTC (23 days ago)
Parents
5076f1f
Follow-up to "label best and par moves in the moves box" (64f9e37a7).
Lint (PluralsCandidate) flagged game_moves_best_par_description: as a
plain string it read "Best 1 moves, par 10" for a best of one move,
and languages with more plural forms could not translate it correctly.

Fix: it is now a plurals resource keyed on the best move count
("Best 1 move, par 10" / "Best 12 moves, par 10"), read with
pluralStringResource. The visible "Best 12 · Par 10" line has no
counted noun and stays a plain string.

Verification: Slice2GameComposeTest's TalkBack case now also checks
"Best 1 move, par 10"; :library:ui:lint no longer reports
PluralsCandidate for this string.

Diff

library/ui/src/main/java/com/vayunmathur/library/ui/game/GameInfoBoxes.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameInfoBoxes.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameInfoBoxes.ktindex 60ece2b819..974d767e53 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameInfoBoxes.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameInfoBoxes.kt@@ -8,6 +8,7 @@ import androidx.compose.foundation.text.TextAutoSize import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics@@ -90,7 +91,7 @@ fun MovesBox(             val spoken = if (bestScore == null) {                 stringResource(R.string.game_moves_no_best_par_description, optimalMoves)             } else {-                stringResource(R.string.game_moves_best_par_description, bestScore, optimalMoves)+                pluralStringResource(R.plurals.game_moves_best_par_description, bestScore, bestScore, optimalMoves)             }             // Material's Text directly, for autoSize: the box is a fixed 150 dp and a translated             // "Best 120 · Par 98" must shrink to fit rather than wrap or clip.
library/ui/src/main/res/values/strings.xml
diff --git a/library/ui/src/main/res/values/strings.xml b/library/ui/src/main/res/values/strings.xmlindex 04139e65df..cf13df30f4 100644--- a/library/ui/src/main/res/values/strings.xml+++ b/library/ui/src/main/res/values/strings.xml@@ -226,8 +226,11 @@     <string name="game_moves">Moves</string>     <!-- Shared library: UI - MovesBox: the player's fewest moves on this level against the level's par (optimal move count), e.g. Best 12 · Par 10. %1$s = best move count, or a dash when the level has not been finished yet; %2$d = par. Keep short: shown in a small fixed-width box -->     <string name="game_moves_best_par">Best <xliff:g id="best" example="12">%1$s</xliff:g> · Par <xliff:g id="par" example="10">%2$d</xliff:g></string>-    <!-- Shared library: UI - MovesBox: what TalkBack reads for the best/par line. %1$d = best move count, %2$d = par (optimal move count) -->-    <string name="game_moves_best_par_description">Best <xliff:g id="best" example="12">%1$d</xliff:g> moves, par <xliff:g id="par" example="10">%2$d</xliff:g></string>+    <!-- Shared library: UI - MovesBox: what TalkBack reads for the best/par line; the quantity follows the best move count. %1$d = best move count, %2$d = par (optimal move count) -->+    <plurals name="game_moves_best_par_description">+        <item quantity="one">Best <xliff:g id="best" example="1">%1$d</xliff:g> move, par <xliff:g id="par" example="10">%2$d</xliff:g></item>+        <item quantity="other">Best <xliff:g id="best" example="12">%1$d</xliff:g> moves, par <xliff:g id="par" example="10">%2$d</xliff:g></item>+    </plurals>     <!-- Shared library: UI - MovesBox: what TalkBack reads for the best/par line before the level has ever been finished. %1$d = par (optimal move count) -->     <string name="game_moves_no_best_par_description">No best yet, par <xliff:g id="par" example="10">%1$d</xliff:g></string>     <!-- Shared library: UI - LevelPickerBox: shown under the level number once that level has been finished. Verb past participle -->
library/ui/src/test/java/com/vayunmathur/library/ui/game/Slice2GameComposeTest.kt
diff --git a/library/ui/src/test/java/com/vayunmathur/library/ui/game/Slice2GameComposeTest.kt b/library/ui/src/test/java/com/vayunmathur/library/ui/game/Slice2GameComposeTest.ktindex 7cb23f2c12..1b5a7de99d 100644--- a/library/ui/src/test/java/com/vayunmathur/library/ui/game/Slice2GameComposeTest.kt+++ b/library/ui/src/test/java/com/vayunmathur/library/ui/game/Slice2GameComposeTest.kt@@ -116,6 +116,9 @@ class Slice2GameComposeTest {         rule.waitForIdle()         rule.onNodeWithText("Best 12 · Par 10").assertIsDisplayed()         rule.onNode(hasContentDescription("Best 12 moves, par 10")).assertExists()+        bestScore = 1+        rule.waitForIdle()+        rule.onNode(hasContentDescription("Best 1 move, par 10")).assertExists()     }      // --- GameModeChooser ---------------------------------------------------------