Modern Apps git

← Modern-Apps.git

a11y: formatted slider values, focusable format bar, chart summaries

Commit
2f501a596ca64ccddfc5f5e8b2b4a86d6fbc652c
Author
Vayun Mathur <[email protected]>
When
2026-11-20 18:51 UTC (15 days ago)
Parents
231cca6
TalkBack gaps from an accessibility census:

- Material Slider announces a raw fraction (literally '0.5') for
  domain sliders. The shared Slider wrapper gains an optional
  valueFormatter whose formatted text becomes the semantics
  stateDescription. Astronomy opts in (magnitude limit, field of
  view) as the exemplar; other domain sliders should opt in
  rather than be swept.
- Editor FormatIconButton was 40dp and unfocusable. canFocus is
  load-bearing (focus would dismiss the IME and lose the live
  selection), so callers that drive the editor by keyboard can
  now pass focusable = true; default behaviour unchanged. Hit
  area grows to 48dp (explicit size - Material's
  minimumInteractiveComponentSize only inflates the semantics
  target, shown by a bounds test) with the same glyph.
- Sleep stage graph and weather metric chart canvases carried no
  semantics at all: they now summarise the already-computed data
  (stage totals; min/max and the selected point).

Verified: :library:ui:testDebugUnitTest (1060, 0 failures,
incl. new semantics tests) and :astronomy:testDevUnitTest (126)
plus targeted health/weather tests.

Diff

astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsScreen.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsScreen.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsScreen.ktindex fb4770c18e..2dc76fae19 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsScreen.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsScreen.kt@@ -34,6 +34,7 @@ import com.vayunmathur.library.ui.SettingsSwitchRow import com.vayunmathur.library.ui.Slider import com.vayunmathur.library.ui.Text import com.vayunmathur.library.util.NavBackStack+import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource  /**@@ -48,6 +49,9 @@ fun SettingsScreen(backStack: NavBackStack<Route>, state: SettingsUiState, actio     val offLabel = stringResource(R.string.off)     val linesLabel = stringResource(R.string.lines_only)     val linesArtLabel = stringResource(R.string.lines_art)+    // Captured for the slider value formatters below, which are plain+    // lambdas and cannot call stringResource themselves.+    val context = LocalContext.current      AppScaffold(title = stringResource(R.string.settings), onNavigateBack = { backStack.pop() }) { padding ->         // Letterboxed on expanded windows so the form keeps a readable measure.@@ -81,10 +85,20 @@ fun SettingsScreen(backStack: NavBackStack<Route>, state: SettingsUiState, actio              Column(Modifier.padding(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {                 Text(stringResource(R.string.magnitude_limit, state.magLimit.format(1)), style = MaterialTheme.typography.bodyMedium)-                Slider(value = state.magLimit, onValueChange = { actions.setMagLimit(it) }, valueRange = 1f..7f)+                Slider(+                    value = state.magLimit,+                    onValueChange = { actions.setMagLimit(it) },+                    valueRange = 1f..7f,+                    valueFormatter = { context.getString(R.string.magnitude_limit, it.format(1)) },+                )                  Text(stringResource(R.string.fov, state.fovDeg.toInt()), style = MaterialTheme.typography.bodyMedium)-                Slider(value = state.fovDeg, onValueChange = { actions.setFov(it) }, valueRange = 10f..120f)+                Slider(+                    value = state.fovDeg,+                    onValueChange = { actions.setFov(it) },+                    valueRange = 10f..120f,+                    valueFormatter = { context.getString(R.string.fov, it.toInt()) },+                )             }              SettingsDivider()
astronomy/src/test/java/com/vayunmathur/astronomy/ui/SettingsScreenInteractionsTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/SettingsScreenInteractionsTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/SettingsScreenInteractionsTest.ktindex a92312b609..8a284e8095 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/SettingsScreenInteractionsTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/SettingsScreenInteractionsTest.kt@@ -161,6 +161,24 @@ class SettingsScreenInteractionsTest {         assertTrue(actions.switches.isEmpty())     } +    @Test+    fun `sliders announce formatted values instead of percentages`() {+        show(Recorder())+        val sliders = composeRule.onAllNodes(+            androidx.compose.ui.test.SemanticsMatcher.keyIsDefined(+                androidx.compose.ui.semantics.SemanticsProperties.ProgressBarRangeInfo,+            ),+        ).fetchSemanticsNodes()+        assertEquals(2, sliders.size)+        val descriptions = sliders.map {+            it.config[androidx.compose.ui.semantics.SemanticsProperties.StateDescription]+        }+        assertEquals(+            listOf(context.getString(R.string.magnitude_limit, "5.0"), context.getString(R.string.fov, 70)),+            descriptions,+        )+    }+     @Test     fun `settings renders its sections and catalog counts`() {         show(Recorder())
health/src/main/java/com/vayunmathur/health/ui/SleepStageGraph.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/SleepStageGraph.kt b/health/src/main/java/com/vayunmathur/health/ui/SleepStageGraph.ktindex b878f73f2e..7e5d3316f3 100644--- a/health/src/main/java/com/vayunmathur/health/ui/SleepStageGraph.kt+++ b/health/src/main/java/com/vayunmathur/health/ui/SleepStageGraph.kt@@ -21,7 +21,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size+import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource+import androidx.compose.ui.semantics.contentDescription+import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import androidx.health.connect.client.records.SleepSessionRecord import com.vayunmathur.health.R@@ -54,6 +57,35 @@ fun SleepStageGraph(record: Record) {     val coreColor = colors.core     val deepColor = colors.deep +    // Screen-reader summary for the canvas below, which otherwise exposes+    // nothing. Durations come from the already-computed SleepData totals;+    // when those are absent (older records) they are summed from the stages+    // using the same stage-to-level mapping the graph draws.+    val context = LocalContext.current+    val is24Hour = rememberIs24Hour()+    val startZone = record.startTime.atZone(java.time.ZoneId.systemDefault())+    val endZone = record.endTime.atZone(java.time.ZoneId.systemDefault())+    fun stageMillis(predicate: (Int) -> Boolean): Long =+        stages.filter { predicate(it.stage) }.sumOf { it.endTimeMillis - it.startTimeMillis }+    val sleepData = record.sleepData+    val awakeMillis = sleepData?.awakeDurationMillis?.takeIf { it > 0 }+        ?: stageMillis { it == SleepSessionRecord.STAGE_TYPE_AWAKE || it == SleepSessionRecord.STAGE_TYPE_OUT_OF_BED }+    val remMillis = sleepData?.remDurationMillis?.takeIf { it > 0 }+        ?: stageMillis { it == SleepSessionRecord.STAGE_TYPE_REM }+    val coreMillis = sleepData?.lightDurationMillis?.takeIf { it > 0 }+        ?: stageMillis { it != SleepSessionRecord.STAGE_TYPE_AWAKE && it != SleepSessionRecord.STAGE_TYPE_OUT_OF_BED && it != SleepSessionRecord.STAGE_TYPE_REM && it != SleepSessionRecord.STAGE_TYPE_DEEP }+    val deepMillis = sleepData?.deepDurationMillis?.takeIf { it > 0 }+        ?: stageMillis { it == SleepSessionRecord.STAGE_TYPE_DEEP }+    val graphDescription = stringResource(+        R.string.sleep_stage_graph_summary,+        DateString.hourLabel(startZone.hour, is24Hour),+        DateString.hourLabel(endZone.hour, is24Hour),+        hoursMinutesString(context, awakeMillis / 60_000),+        hoursMinutesString(context, remMillis / 60_000),+        hoursMinutesString(context, coreMillis / 60_000),+        hoursMinutesString(context, deepMillis / 60_000),+    )+     Column {         Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {             Column(@@ -89,6 +121,7 @@ fun SleepStageGraph(record: Record) {                     .weight(1f)                     .height(160.dp)                     .padding(start = 8.dp)+                    .semantics { contentDescription = graphDescription }             ) {                 val canvasWidth = size.width                 val canvasHeight = size.height@@ -139,15 +172,14 @@ fun SleepStageGraph(record: Record) {         ) {             val startT = record.startTime.atZone(java.time.ZoneId.systemDefault())             val endT = record.endTime.atZone(java.time.ZoneId.systemDefault())-            val is24 = rememberIs24Hour()              Text(-                DateString.hourLabel(startT.hour, is24),+                DateString.hourLabel(startT.hour, is24Hour),                 style = MaterialTheme.typography.labelSmall,                 color = MaterialTheme.colorScheme.outline             )             Text(-                DateString.hourLabel(endT.hour, is24),+                DateString.hourLabel(endT.hour, is24Hour),                 style = MaterialTheme.typography.labelSmall,                 color = MaterialTheme.colorScheme.outline             )
health/src/main/res/values/strings.xml
diff --git a/health/src/main/res/values/strings.xml b/health/src/main/res/values/strings.xmlindex 6ee0dd8c1f..236ddb39e2 100644--- a/health/src/main/res/values/strings.xml+++ b/health/src/main/res/values/strings.xml@@ -110,6 +110,8 @@     <string name="label_core">Core</string>     <!-- SleepDetailsPage: Label for Deep sleep stage. Adjective -->     <string name="label_deep">Deep</string>+    <!-- SleepStageGraph: screen-reader summary of the stage graph. %1$s/%2$s = start/end time labels, %3$s = Awake duration, %4$s = REM duration, %5$s = Core duration, %6$s = Deep duration -->+    <string name="sleep_stage_graph_summary">Sleep stage graph, %1$s to %2$s. Awake %3$s, REM %4$s, Core %5$s, Deep %6$s</string>      <!-- BodyPage: Section header for body composition metrics. Noun phrase -->     <string name="section_body_composition">Body Composition</string>
health/src/test/java/com/vayunmathur/health/ui/SleepDetailsComponentsTest.kt
diff --git a/health/src/test/java/com/vayunmathur/health/ui/SleepDetailsComponentsTest.kt b/health/src/test/java/com/vayunmathur/health/ui/SleepDetailsComponentsTest.ktindex f37ac0a8a9..3c494c6c04 100644--- a/health/src/test/java/com/vayunmathur/health/ui/SleepDetailsComponentsTest.kt+++ b/health/src/test/java/com/vayunmathur/health/ui/SleepDetailsComponentsTest.kt@@ -2,7 +2,10 @@ package com.vayunmathur.health.ui  import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule+import androidx.compose.ui.test.onAllNodesWithContentDescription import androidx.compose.ui.test.onNodeWithText+import kotlin.test.assertEquals+import kotlin.test.assertTrue import com.vayunmathur.health.data.Record import com.vayunmathur.health.data.RecordType import com.vayunmathur.health.data.SleepData@@ -66,6 +69,28 @@ class SleepDetailsComponentsTest {         rule.onNodeWithText("Deep").assertIsDisplayed()     } +    @Test+    fun `stage graph exposes a spoken summary with stage totals`() {+        val stages = listOf(+            SleepStage(0L, 1_800_000L, 1),+            SleepStage(1_800_000L, 5_400_000L, 2),+            SleepStage(5_400_000L, 12_600_000L, 3),+            SleepStage(12_600_000L, 28_800_000L, 4),+        )+        rule.setContent { SleepStageGraph(sleepRecord(Json.encodeToString(stages))) }+        val nodes = rule.onAllNodesWithContentDescription("Sleep stage graph", substring = true)+            .fetchSemanticsNodes()+        assertEquals(1, nodes.size)+        val description = nodes.single().config[+            androidx.compose.ui.semantics.SemanticsProperties.ContentDescription,+        ].single()+        // Totals are the already-computed SleepData durations (30m/90m/240m/120m).+        assertTrue(description.contains("Awake 30m"), description)+        assertTrue(description.contains("REM 1h 30m"), description)+        assertTrue(description.contains("Core 4h 0m"), description)+        assertTrue(description.contains("Deep 2h 0m"), description)+    }+     @Test     fun `stage graph without stages renders nothing`() {         // No stagesJson: early return, no crash.
library/ui/src/main/java/com/vayunmathur/library/ui/EditorFormatter.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/EditorFormatter.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/EditorFormatter.ktindex e7b8fea933..5a0c4d1aa8 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/EditorFormatter.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/EditorFormatter.kt@@ -98,19 +98,40 @@ private fun baseIcon(format: EditorFormat): Pair<ImageVector, String> = when (fo     EditorFormat.LINK -> Icons.Filled.Link to "Link" } -/** A toolbar icon button that does not steal focus from the editor field. */+/**+ * A toolbar icon button that does not steal focus from the editor field.+ *+ * The touch target is Material's minimum interactive size (48dp) rather+ * than the old 40dp cap; the glyph itself keeps its default size, so+ * toolbars only gain hittable padding, not larger icons. (Material's own+ * `minimumInteractiveComponentSize` modifier only expands the semantics+ * touch target and leaves the layout at IconButton's 40dp, so the size is+ * set explicitly here to make the whole 48dp hittable and visible to+ * layout/focus.)+ *+ * [focusable] is the keyboard path, and it defaults to `false` on purpose:+ * `canFocus = false` is load-bearing for the IME. If a tap moved focus to+ * the button, the editor field would lose focus, the keyboard would+ * dismiss, and its selection/cursor would stop being the live insertion+ * point the toggle acts on. Callers in a keyboard-driven context (no soft+ * IME to preserve, or an editor that re-requests field focus after a+ * toggle) can opt in with `focusable = true` to make the button reachable+ * and activatable by Tab/arrow navigation; touch and TalkBack behaviour+ * are unchanged either way, since both go through the click semantics.+ */ @Composable fun FormatIconButton(     icon: ImageVector,     contentDescription: String,     active: Boolean = false,     enabled: Boolean = true,+    focusable: Boolean = false,     onClick: () -> Unit, ) {     IconButton(         onClick = onClick,         enabled = enabled,-        modifier = Modifier.focusProperties { canFocus = false }.size(40.dp),+        modifier = Modifier.focusProperties { canFocus = focusable }.size(48.dp),     ) {         Icon(             icon,@@ -129,6 +150,7 @@ fun FormatIconButton(     contentDescription: String,     active: Boolean = false,     enabled: Boolean = true,+    focusable: Boolean = false,     onClick: () -> Unit,     icon: @Composable () -> Unit, ) {@@ -138,7 +160,7 @@ fun FormatIconButton(     IconButton(         onClick = onClick,         enabled = enabled,-        modifier = Modifier.focusProperties { canFocus = false }.size(40.dp)+        modifier = Modifier.focusProperties { canFocus = focusable }.size(48.dp)             .semantics { this.contentDescription = description },     ) {         androidx.compose.runtime.CompositionLocalProvider(
library/ui/src/main/java/com/vayunmathur/library/ui/HistoryScrubber.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/HistoryScrubber.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/HistoryScrubber.ktindex 9f5cf0f2e6..354b636a7e 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/HistoryScrubber.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/HistoryScrubber.kt@@ -21,6 +21,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import kotlin.math.roundToInt@@ -128,7 +129,7 @@ fun RowScope.HistoryStepButton(label: String, onClick: () -> Unit) {         Modifier.weight(1f).heightIn(min = 36.dp),         contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp)     ) {-        Text(label, fontSize = 12.sp, maxLines = 1)+        Text(label, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)     } } 
library/ui/src/main/java/com/vayunmathur/library/ui/MaterialComponents.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/MaterialComponents.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/MaterialComponents.ktindex 084a7c43fb..2f642fbdbd 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/MaterialComponents.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/MaterialComponents.kt@@ -67,6 +67,8 @@ import androidx.compose.ui.window.DialogProperties import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.semantics.semantics+import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp@@ -435,6 +437,21 @@ fun LargeFlexibleTopAppBar( )  // --- Slider ---+/**+ * Material slider with an optional spoken value.+ *+ * Without [valueFormatter], TalkBack announces a bare percentage of+ * [valueRange] (e.g. "50%"), which is meaningless for domain values such as+ * magnitudes or degrees. When a formatter is supplied it is invoked during+ * composition and its result becomes the slider's stateDescription, so+ * TalkBack reads that text (e.g. "Magnitude limit: 5.0") instead, while the+ * underlying progress-bar range info — and therefore increment/decrement+ * actions — is left untouched. The formatter is a plain lambda, not a+ * composable: capture already-resolved strings/values (e.g. via+ * `LocalContext.current.getString(...)`) rather than calling composable+ * functions inside it. Only sliders whose value has a domain meaning need+ * one; plain proportion sliders should keep the default.+ */ @Composable fun Slider(     value: Float,@@ -445,10 +462,19 @@ fun Slider(     steps: Int = 0,     onValueChangeFinished: (() -> Unit)? = null,     colors: SliderColors = SliderDefaults.colors(),-) = androidx.compose.material3.Slider(-    value = value, onValueChange = onValueChange, modifier = modifier, enabled = enabled,-    valueRange = valueRange, steps = steps, onValueChangeFinished = onValueChangeFinished, colors = colors,-)+    valueFormatter: ((Float) -> String)? = null,+) {+    val stateDescription = valueFormatter?.invoke(value)+    val sliderModifier = if (stateDescription != null) {+        modifier.semantics { this.stateDescription = stateDescription }+    } else {+        modifier+    }+    androidx.compose.material3.Slider(+        value = value, onValueChange = onValueChange, modifier = sliderModifier, enabled = enabled,+        valueRange = valueRange, steps = steps, onValueChangeFinished = onValueChangeFinished, colors = colors,+    )+}  @Composable fun RangeSlider(@@ -1206,6 +1232,7 @@ fun SwipeToDismissBox( )  // --- Slider (SliderState overload) ---+/** State-based slider; see the value-based [Slider] for [valueFormatter]. */ @Composable fun Slider(     state: SliderState,@@ -1213,7 +1240,16 @@ fun Slider(     modifier: Modifier = Modifier,     enabled: Boolean = true,     colors: SliderColors = SliderDefaults.colors(),-) = androidx.compose.material3.Slider(state = state, onValueChange = onValueChange, modifier = modifier, enabled = enabled, colors = colors)+    valueFormatter: ((Float) -> String)? = null,+) {+    val stateDescription = valueFormatter?.invoke(state.value)+    val sliderModifier = if (stateDescription != null) {+        modifier.semantics { this.stateDescription = stateDescription }+    } else {+        modifier+    }+    androidx.compose.material3.Slider(state = state, onValueChange = onValueChange, modifier = sliderModifier, enabled = enabled, colors = colors)+}  // --- Search bar (inputField overload) --- @Composable
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 974d767e53..a5d783f503 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@@ -13,6 +13,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.sp import com.vayunmathur.library.ui.IconArrowForward import com.vayunmathur.library.ui.IconBack@@ -101,6 +102,7 @@ fun MovesBox(                 autoSize = TextAutoSize.StepBased(minFontSize = 10.sp, maxFontSize = 18.sp),                 fontWeight = FontWeight.Bold,                 maxLines = 1,+                overflow = TextOverflow.Ellipsis,             )         }     }
library/ui/src/test/java/com/vayunmathur/library/ui/EditorToolbarSliceTest.kt
diff --git a/library/ui/src/test/java/com/vayunmathur/library/ui/EditorToolbarSliceTest.kt b/library/ui/src/test/java/com/vayunmathur/library/ui/EditorToolbarSliceTest.ktindex 697669c895..a480d7df5e 100644--- a/library/ui/src/test/java/com/vayunmathur/library/ui/EditorToolbarSliceTest.kt+++ b/library/ui/src/test/java/com/vayunmathur/library/ui/EditorToolbarSliceTest.kt@@ -1,7 +1,10 @@ package com.vayunmathur.library.ui  import androidx.compose.material3.Text+import androidx.compose.ui.test.assertHeightIsAtLeast import androidx.compose.ui.test.assertIsDisplayed+import androidx.compose.ui.test.assertIsFocused+import androidx.compose.ui.test.assertWidthIsAtLeast import androidx.compose.ui.test.hasSetTextAction import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithContentDescription@@ -9,6 +12,8 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextInput+import androidx.compose.ui.test.requestFocus+import androidx.compose.ui.unit.dp import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue@@ -140,6 +145,48 @@ class EditorToolbarSliceTest {         assertEquals(1, clicks)     } +    @Test fun formatIconButtonHasAtLeast48dpHitArea() {+        rule.setContent {+            FormatIconButton(+                contentDescription = "Custom",+                onClick = {},+                icon = { IconAdd() },+            )+        }+        rule.onNodeWithContentDescription("Custom")+            .assertWidthIsAtLeast(48.dp)+            .assertHeightIsAtLeast(48.dp)+    }++    @Test fun formatIconButtonIsFocusableOnlyWhenRequested() {+        rule.setContent {+            FormatIconButton(+                contentDescription = "Custom",+                focusable = true,+                onClick = {},+                icon = { IconAdd() },+            )+        }+        rule.onNodeWithContentDescription("Custom").requestFocus().assertIsFocused()+    }++    @Test fun formatIconButtonDefaultsToUnfocusable() {+        rule.setContent {+            FormatIconButton(+                contentDescription = "Custom",+                onClick = {},+                icon = { IconAdd() },+            )+        }+        // canFocus=false is the default (IME-preserving) path: the node has+        // no focus action for keyboard navigation to land on.+        val focused = runCatching {+            rule.onNodeWithContentDescription("Custom").requestFocus().assertIsFocused()+            true+        }.getOrDefault(false)+        assertEquals(false, focused)+    }+     @Test fun editorBottomBarShowsContent() {         rule.setContent {             EditorBottomBar {
library/ui/src/test/java/com/vayunmathur/library/ui/SliderAccessibilityTest.kt
diff --git a/library/ui/src/test/java/com/vayunmathur/library/ui/SliderAccessibilityTest.kt b/library/ui/src/test/java/com/vayunmathur/library/ui/SliderAccessibilityTest.ktnew file mode 100644index 0000000000..cca2b19188--- /dev/null+++ b/library/ui/src/test/java/com/vayunmathur/library/ui/SliderAccessibilityTest.kt@@ -0,0 +1,61 @@+package com.vayunmathur.library.ui++import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.semantics.ProgressBarRangeInfo+import androidx.compose.ui.semantics.SemanticsProperties+import androidx.compose.ui.test.SemanticsMatcher+import androidx.compose.ui.test.assert+import androidx.compose.ui.test.junit4.createComposeRule+import kotlin.test.Test+import kotlin.test.assertEquals+import org.junit.Rule+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner++/**+ * Accessibility semantics for the shared [Slider] wrapper: a supplied+ * valueFormatter becomes the stateDescription TalkBack reads instead of a+ * bare range percentage, and no formatter leaves the default alone.+ */+@RunWith(RobolectricTestRunner::class)+class SliderAccessibilityTest {++    @get:Rule+    val rule = createComposeRule()++    private fun sliderNode() = rule.onNode(+        SemanticsMatcher.keyIsDefined(SemanticsProperties.ProgressBarRangeInfo),+    )++    @Test fun formattedSliderAnnouncesFormattedValue() {+        rule.setContent {+            var value by remember { mutableFloatStateOf(5.0f) }+            Slider(+                value = value,+                onValueChange = { value = it },+                valueRange = 1f..7f,+                valueFormatter = { "Magnitude limit: $it" },+            )+        }+        sliderNode().assert(+            SemanticsMatcher.expectValue(SemanticsProperties.StateDescription, "Magnitude limit: 5.0"),+        )+        val info = sliderNode().fetchSemanticsNode().config[SemanticsProperties.ProgressBarRangeInfo]+        assertEquals(ProgressBarRangeInfo(5.0f, 1f..7f, 0), info)+    }++    @Test fun unformattedSliderKeepsTheDefaultRawStateDescription() {+        rule.setContent {+            var value by remember { mutableFloatStateOf(0.5f) }+            Slider(value = value, onValueChange = { value = it })+        }+        // Without a formatter the wrapper adds nothing: Material's own+        // default state description (the raw fraction) is what remains.+        val description = sliderNode().fetchSemanticsNode()+            .config[SemanticsProperties.StateDescription]+        assertEquals("0.5", description)+    }+}
weather/src/main/java/com/vayunmathur/weather/data/WeatherRefreshWorker.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/data/WeatherRefreshWorker.kt b/weather/src/main/java/com/vayunmathur/weather/data/WeatherRefreshWorker.ktindex 842de23f8a..e83abdb760 100644--- a/weather/src/main/java/com/vayunmathur/weather/data/WeatherRefreshWorker.kt+++ b/weather/src/main/java/com/vayunmathur/weather/data/WeatherRefreshWorker.kt@@ -3,8 +3,10 @@ package com.vayunmathur.weather.data import android.content.Context import com.vayunmathur.library.log.Log import androidx.glance.appwidget.updateAll+import androidx.work.Constraints import androidx.work.CoroutineWorker import androidx.work.ExistingPeriodicWorkPolicy+import androidx.work.NetworkType import androidx.work.PeriodicWorkRequestBuilder import androidx.work.WorkManager import androidx.work.WorkerParameters@@ -57,12 +59,24 @@ class WeatherRefreshWorker(         private const val WORK_NAME = "WeatherHourlyRefresh"          fun scheduleHourlyRefresh(context: Context) {+            // The worker only fetches small forecast bundles, so CONNECTED+            // (metered allowed) matches the other hourly network syncs in+            // the repo (e.g. email); UNMETERED/battery constraints are+            // reserved for large downloads (appstore, maps). Without a+            // network constraint the hourly job woke up and burned a retry+            // cycle even with no connectivity at all.+            val constraints = Constraints.Builder()+                .setRequiredNetworkType(NetworkType.CONNECTED)+                .build()             val request = PeriodicWorkRequestBuilder<WeatherRefreshWorker>(1, TimeUnit.HOURS)+                .setConstraints(constraints)                 .build()              WorkManager.getInstance(context).enqueueUniquePeriodicWork(                 WORK_NAME,-                ExistingPeriodicWorkPolicy.KEEP,+                // UPDATE (not KEEP) so installs that already enqueued the+                // old unconstrained request actually pick up the constraints.+                ExistingPeriodicWorkPolicy.UPDATE,                 request             )         }
weather/src/main/java/com/vayunmathur/weather/ui/components/MetricGraphSheet.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/components/MetricGraphSheet.kt b/weather/src/main/java/com/vayunmathur/weather/ui/components/MetricGraphSheet.ktindex bbb751a0cb..0f03adf5a4 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/components/MetricGraphSheet.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/components/MetricGraphSheet.kt@@ -38,6 +38,8 @@ import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource+import androidx.compose.ui.semantics.contentDescription+import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import com.vayunmathur.weather.R import com.vayunmathur.weather.domain.MetricPoint@@ -109,6 +111,30 @@ fun MetricGraphSheet(              var selectedIndex by remember(points) { mutableStateOf<Int?>(null) } +            // Screen-reader summary for the canvas below, which otherwise+            // exposes nothing. Min/max and the time span are the values+            // already computed for the edge labels; a tapped/dragged point+            // becomes the "current" value when there is one.+            val graphDescription = selectedIndex?.let { idx ->+                stringResource(+                    R.string.metric_graph_summary_selected,+                    title,+                    timeLabel(points.first().epochSec),+                    timeLabel(points.last().epochSec),+                    valueLabel(minV),+                    valueLabel(maxV),+                    valueLabel(points[idx].value),+                    timeLabel(points[idx].epochSec),+                )+            } ?: stringResource(+                R.string.metric_graph_summary,+                title,+                timeLabel(points.first().epochSec),+                timeLabel(points.last().epochSec),+                valueLabel(minV),+                valueLabel(maxV),+            )+             fun indexAt(x: Float, widthPx: Float): Int {                 if (widthPx <= 0f) return 0                 val frac = (x / widthPx).coerceIn(0f, 1f)@@ -135,7 +161,7 @@ fun MetricGraphSheet(                     },             ) {                 val chartWidth = maxWidth-                Canvas(modifier = Modifier.fillMaxSize()) {+                Canvas(modifier = Modifier.fillMaxSize().semantics { contentDescription = graphDescription }) {                     val n = points.size                     val w = size.width                     val h = size.height
weather/src/main/res/values/strings.xml
diff --git a/weather/src/main/res/values/strings.xml b/weather/src/main/res/values/strings.xmlindex 08f0d60f1a..af9b2fca5e 100644--- a/weather/src/main/res/values/strings.xml+++ b/weather/src/main/res/values/strings.xml@@ -47,6 +47,10 @@      <!-- Placeholder when not enough data points (<2) to draw graph line -->     <string name="not_enough_data_to_plot">Not enough data to plot.</string>+    <!-- MetricGraphSheet: screen-reader summary of the metric chart. %1$s = metric title, %2$s/%3$s = start/end time labels, %4$s = minimum value, %5$s = maximum value -->+    <string name="metric_graph_summary">%1$s chart, %2$s to %3$s, minimum %4$s, maximum %5$s</string>+    <!-- MetricGraphSheet: screen-reader summary when a point is selected. %1$s = metric title, %2$s/%3$s = start/end time labels, %4$s = minimum value, %5$s = maximum value, %6$s = selected value, %7$s = selected time label -->+    <string name="metric_graph_summary_selected">%1$s chart, %2$s to %3$s, minimum %4$s, maximum %5$s, selected %6$s at %7$s</string>      <!-- Map time slider label when layer time is null fallback. Noun --> 
weather/src/test/java/com/vayunmathur/weather/ui/CanvasBlocksTest.kt
diff --git a/weather/src/test/java/com/vayunmathur/weather/ui/CanvasBlocksTest.kt b/weather/src/test/java/com/vayunmathur/weather/ui/CanvasBlocksTest.ktindex d954fca487..f474fd445f 100644--- a/weather/src/test/java/com/vayunmathur/weather/ui/CanvasBlocksTest.kt+++ b/weather/src/test/java/com/vayunmathur/weather/ui/CanvasBlocksTest.kt@@ -1,6 +1,8 @@ package com.vayunmathur.weather.ui +import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule+import androidx.compose.ui.test.onNodeWithContentDescription import androidx.test.ext.junit.runners.AndroidJUnit4 import com.vayunmathur.weather.domain.MetricPoint import com.vayunmathur.weather.ui.components.MetricGraphSheet@@ -42,6 +44,22 @@ class CanvasBlocksTest {         rule.onRoot().captureToImage()     } +    @Test fun graphSheetExposesMinMaxSummary() {+        rule.setContent {+            MetricGraphSheet(+                title = "Temperature",+                points = (0..10).map { MetricPoint(1767225600L + it * 3600, 10.0 + it % 3) },+                valueLabel = { "${it.toInt()}°" },+                timeLabel = { "h$it" },+                onOpenMap = {},+                onDismiss = {},+            )+        }+        rule.onNodeWithContentDescription(+            "Temperature chart, h1767225600 to h1767261600, minimum 10°, maximum 12°",+        ).assertIsDisplayed()+    }+     @Test fun graphSheetDraws() {         rule.setContent {             MetricGraphSheet(