wordmaker: shared hint/wheel icons, aligned corner buttons (#ux-audit)
- Commit
39ccd85a762943d83f5e7e5cbbc17fac471f6474- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-13 01:21 UTC (23 days ago)
- Parents
32fa325
Symptom: the hint button showed the old framework "?" (ic_menu_help),
which matches none of the app's other icons, and during the 30 s
cooldown it was almost invisible. The bonus-words button sat 32 dp
higher than the hint button opposite it. The wheel's backspace,
submit and shuffle buttons drew private drawables instead of the
shared icon set.
Root cause:
- WordGameCornerButtons drew painterResource(android.R.drawable
.ic_menu_help) and multiplied it by a 0.5 alpha while disabled -
on top of FilledIconButton's own disabled content colour, so the
icon was dimmed twice.
- The bonus button had .padding(16.dp).padding(bottom = 32.dp) while
the hint button had only .padding(16.dp).
- LetterChooser used raw material3 Icon(painterResource(...)) with
three app drawables, against the "icons only via Icons.kt" rule.
Fix:
- library/ui Icons.kt (appended under "// --- wordmaker ---"):
IconHelp (Material help_outline built from its path data, auto-
mirrored, so no new imports were needed in the shared file) and
contentDescription-taking overloads of IconShuffle, IconBackspace
and IconReturn so the app keeps its localized labels.
- The hint button uses IconHelp with no extra alpha; the disabled
button colours plus the cooldown ring show the state.
- Both corner buttons use the same 16 dp inset.
- LetterChooser uses the Icons.kt helpers; the now-unused
backspace_24px, keyboard_return_24px and ic_shuffle drawables are
deleted.
User-visible effect: a Material "?" consistent with the other icons,
clearly visible (standard disabled look) during the cooldown; the
bonus and hint buttons line up along the bottom edge. Content
descriptions are unchanged ("Hint", "Shuffle", "Backspace",
"Submit", localized).
Verification: new CornerButtonsTest - bonus and hint buttons share a
bottom edge, and during a cooldown the hint icon is displayed on a
disabled button. Existing tests that find these buttons by content
description still pass.Diff
games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/WordGameWheel.kt
diff --git a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/WordGameWheel.kt b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/WordGameWheel.ktindex 532f5688b0..f62f695fc3 100644--- a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/WordGameWheel.kt+++ b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/WordGameWheel.kt@@ -16,7 +16,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.onGloballyPositioned-import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.Density@@ -34,7 +33,7 @@ import com.vayunmathur.library.ui.BadgedBox import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.FilledIconButton-import com.vayunmathur.library.ui.Icon+import com.vayunmathur.library.ui.IconHelp import com.vayunmathur.library.ui.IconBook import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.ui.Text@@ -150,8 +149,9 @@ fun BoxScope.WordGameCornerButtons( androidx.compose.foundation.layout.Box( modifier = Modifier .align(Alignment.BottomStart)+ // Same 16 dp inset as the hint button opposite, so the two corner buttons line up+ // (the extra 32 dp bottom padding left the bonus button floating higher). .padding(16.dp)- .padding(bottom = 32.dp) .onGloballyPositioned { onBonusButtonPositioned(it.localToRoot(Offset.Zero)) } .graphicsLayer { translationX = bonusShake@@ -185,11 +185,9 @@ fun BoxScope.WordGameCornerButtons( onClick = onOpenHint, enabled = hintEnabled ) {- Icon(- painterResource(android.R.drawable.ic_menu_help),- contentDescription = stringResource(R.string.cd_hint),- modifier = Modifier.graphicsLayer { alpha = if (hintEnabled) 1f else 0.5f }- )+ // The button's disabled colours already dim the icon during the cooldown; a+ // second 0.5 alpha on top made it nearly invisible.+ IconHelp(contentDescription = stringResource(R.string.cd_hint)) } if (!hintEnabled) { CircularProgressIndicator(
games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/components/LetterChooser.kt
diff --git a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/components/LetterChooser.kt b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/components/LetterChooser.ktindex b57746200c..ac53316ece 100644--- a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/components/LetterChooser.kt+++ b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/components/LetterChooser.kt@@ -20,7 +20,6 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.FilledIconButton-import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text@@ -43,7 +42,6 @@ import androidx.compose.ui.input.pointer.PointerEventPass import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalDensity-import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.IntOffset@@ -52,6 +50,9 @@ import androidx.compose.ui.unit.sp import com.vayunmathur.games.wordmaker.R import com.vayunmathur.games.wordmaker.data.WheelSpacing import com.vayunmathur.games.wordmaker.ui.ChooserLetter+import com.vayunmathur.library.ui.IconBackspace+import com.vayunmathur.library.ui.IconReturn+import com.vayunmathur.library.ui.IconShuffle import com.vayunmathur.library.ui.animatedDp import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch@@ -142,11 +143,11 @@ fun LetterChooser( FilledIconButton(onClick = { selectedLettersIndices = selectedLettersIndices.dropLast(1) }) {- Icon(painterResource(R.drawable.backspace_24px), contentDescription = stringResource(R.string.cd_backspace))+ IconBackspace(contentDescription = stringResource(R.string.cd_backspace)) } Spacer(modifier = Modifier.height(8.dp)) FilledIconButton(onClick = { submitSelection() }) {- Icon(painterResource(R.drawable.keyboard_return_24px), contentDescription = stringResource(R.string.cd_submit))+ IconReturn(contentDescription = stringResource(R.string.cd_submit)) } } }@@ -290,7 +291,7 @@ fun LetterChooser( horizontalAlignment = Alignment.CenterHorizontally ) { FilledIconButton(onClick = onShuffle) {- Icon(painterResource(R.drawable.ic_shuffle), contentDescription = stringResource(R.string.cd_shuffle))+ IconShuffle(contentDescription = stringResource(R.string.cd_shuffle)) } } }
games/wordmaker/src/main/res/drawable/backspace_24px.xml
diff --git a/games/wordmaker/src/main/res/drawable/backspace_24px.xml b/games/wordmaker/src/main/res/drawable/backspace_24px.xmldeleted file mode 100644index 5c6a9a7b1d..0000000000--- a/games/wordmaker/src/main/res/drawable/backspace_24px.xml+++ /dev/null@@ -1,5 +0,0 @@-<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">- - <path android:fillColor="@android:color/white" android:pathData="M456,640L560,536L664,640L720,584L616,480L720,376L664,320L560,424L456,320L400,376L504,480L400,584L456,640ZM360,800Q341,800 324,791.5Q307,783 296,768L80,480L296,192Q307,177 324,168.5Q341,160 360,160L800,160Q833,160 856.5,183.5Q880,207 880,240L880,720Q880,753 856.5,776.5Q833,800 800,800L360,800ZM180,480L360,720Q360,720 360,720Q360,720 360,720L800,720Q800,720 800,720Q800,720 800,720L800,240Q800,240 800,240Q800,240 800,240L360,240Q360,240 360,240Q360,240 360,240L180,480ZM580,480Q580,480 580,480Q580,480 580,480L580,480Q580,480 580,480Q580,480 580,480L580,480Q580,480 580,480Q580,480 580,480L580,480L580,480Q580,480 580,480Q580,480 580,480Z"/>- -</vector>
games/wordmaker/src/main/res/drawable/ic_shuffle.xml
diff --git a/games/wordmaker/src/main/res/drawable/ic_shuffle.xml b/games/wordmaker/src/main/res/drawable/ic_shuffle.xmldeleted file mode 100644index 8d6ad74ef2..0000000000--- a/games/wordmaker/src/main/res/drawable/ic_shuffle.xml+++ /dev/null@@ -1,9 +0,0 @@-<vector xmlns:android="http://schemas.android.com/apk/res/android"- android:width="24dp"- android:height="24dp"- android:viewportWidth="24"- android:viewportHeight="24">- <path- android:fillColor="@android:color/white"- android:pathData="M10.59,9.17L5.41,4 4,5.41l5.17,5.17 1.42,-1.41zM14.5,4l2.04,2.04L4,18.59 5.41,20 17.96,7.46 20,9.5V4h-5.5zM14.83,13.41L13.41,14.83l5.17,5.17L20,18.59l-5.17,-5.18z"/>-</vector>
games/wordmaker/src/main/res/drawable/keyboard_return_24px.xml
diff --git a/games/wordmaker/src/main/res/drawable/keyboard_return_24px.xml b/games/wordmaker/src/main/res/drawable/keyboard_return_24px.xmldeleted file mode 100644index 761e2911c6..0000000000--- a/games/wordmaker/src/main/res/drawable/keyboard_return_24px.xml+++ /dev/null@@ -1,5 +0,0 @@-<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">- - <path android:fillColor="@android:color/white" android:pathData="M360,720L120,480L360,240L416,296L272,440L760,440L760,280L840,280L840,520L272,520L416,664L360,720Z"/>- -</vector>
games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/CornerButtonsTest.kt
diff --git a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/CornerButtonsTest.kt b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/CornerButtonsTest.ktnew file mode 100644index 0000000000..2dbe82858b--- /dev/null+++ b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/CornerButtonsTest.kt@@ -0,0 +1,50 @@+package com.vayunmathur.games.wordmaker.ui++import androidx.compose.ui.test.assertIsDisplayed+import androidx.compose.ui.test.assertIsNotEnabled+import androidx.compose.ui.test.junit4.createComposeRule+import androidx.compose.ui.test.onNodeWithContentDescription+import com.vayunmathur.games.wordmaker.data.CrosswordData+import com.vayunmathur.games.wordmaker.platform.WordGameActions+import com.vayunmathur.games.wordmaker.platform.WordGameUiState+import com.vayunmathur.library.ui.DynamicTheme+import org.junit.Rule+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config+import kotlin.math.abs+import kotlin.test.Test+import kotlin.test.assertTrue++/** The bonus-words and hint buttons in the bottom corners of the game screen. */+@RunWith(RobolectricTestRunner::class)+@Config(qualifiers = "w411dp-h891dp")+class CornerButtonsTest {+ @get:Rule val rule = createComposeRule()++ private fun setScreen(hintCooldownEnd: Long = 0L) {+ val state = WordGameUiState(+ crosswordData = CrosswordData.fromString("CAT\n C \n T ")!!,+ bonusWords = setOf("ACT"),+ hintCooldownEnd = hintCooldownEnd,+ )+ rule.setContent {+ DynamicTheme { WordGameScreen(state = state, actions = WordGameActions.Noop, onOpenGameCenter = {}, onOpenSettings = {}) }+ }+ }++ @Test fun bonusAndHintButtonsSitOnTheSameBaseline() {+ setScreen()+ val bonus = rule.onNodeWithContentDescription("Bonus Words").fetchSemanticsNode().boundsInRoot+ val hint = rule.onNodeWithContentDescription("Hint").fetchSemanticsNode().boundsInRoot+ // The bonus button used to float 32 dp above the hint button.+ assertTrue(abs(bonus.bottom - hint.bottom) < 1f, "bonus bottom ${bonus.bottom} vs hint bottom ${hint.bottom}")+ }++ @Test fun hintIconStaysShownDuringTheCooldown() {+ setScreen(hintCooldownEnd = System.currentTimeMillis() + 20_000)+ rule.onNodeWithContentDescription("Hint").assertIsDisplayed()+ // Merged semantics: this node is the (disabled) button carrying the icon.+ rule.onNodeWithContentDescription("Hint").assertIsNotEnabled()+ }+}
library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.ktindex 1e3c65a6c4..6be064d036 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt@@ -1911,3 +1911,60 @@ fun IconGameCenterTrophy( modifier: Modifier = Modifier, tint: Color = LocalContentColor.current, ) = AppIcon(Icons.Filled.EmojiEvents, contentDescription, modifier, tint)++// --- wordmaker ---++/**+ * Help: a "?" in a circle (Material help_outline, auto-mirrored) - e.g. a hint button.+ * [contentDescription] defaults to "Help"; pass the control's own label.+ */+@Composable+fun IconHelp(+ modifier: Modifier = Modifier,+ tint: Color = LocalContentColor.current,+ contentDescription: String? = "Help",+) = AppIcon(HelpOutlineVector, contentDescription, modifier, tint)++/** [IconShuffle] labelled with the caller's own (localized) [contentDescription]. */+@Composable+fun IconShuffle(+ contentDescription: String?,+ modifier: Modifier = Modifier,+ tint: Color = LocalContentColor.current,+) = AppIcon(Icons.Filled.Shuffle, contentDescription, modifier, tint)++/** [IconBackspace] labelled with the caller's own (localized) [contentDescription]. */+@Composable+fun IconBackspace(+ contentDescription: String?,+ modifier: Modifier = Modifier,+ tint: Color = LocalContentColor.current,+) = AppIcon(Icons.AutoMirrored.Filled.Backspace, contentDescription, modifier, tint)++/** [IconReturn] labelled with the caller's own (localized) [contentDescription], e.g. "Submit". */+@Composable+fun IconReturn(+ contentDescription: String?,+ modifier: Modifier = Modifier,+ tint: Color = LocalContentColor.current,+) = AppIcon(Icons.AutoMirrored.Filled.KeyboardReturn, contentDescription, modifier, tint)++/** Material help_outline, built from its path data (auto-mirrored, like the extended set's). */+private val HelpOutlineVector: ImageVector by lazy {+ ImageVector.Builder(+ name = "HelpOutline",+ defaultWidth = 24.dp,+ defaultHeight = 24.dp,+ viewportWidth = 24f,+ viewportHeight = 24f,+ autoMirror = true,+ ).addPath(+ pathData = addPathNodes(+ "M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2z" ++ "M12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z" ++ "M12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2" ++ "c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z"+ ),+ fill = SolidColor(Color.Black),+ ).build()+}