app: fix accessibility labels

- The back buttons of the DenyList, flash and action screens, and the
  DenyList's clear search button, had no label, so TalkBack read them
  as unlabeled buttons. Label them like the other screens do.
- A module's enable switch is its own accessibility node without the
  module name. Name it after the module.
- The safe mode item in the reboot menu showed its state only with a
  check mark. Expose it as a toggleable state.
- Navigation items and the module action and update buttons labeled
  their icons with the same text as their visible label, so it was
  read twice. Make those icons decorative.

Assisted-by: Claude Opus 5.5
This commit is contained in:
topjohnwu
2026-10-24 13:01:45 -07:00
committed by John Wu
parent 9ee6815a54
commit d50f99e64c
6 changed files with 20 additions and 8 deletions
@@ -183,7 +183,8 @@ fun MainScreen(
icon = {
Icon(
imageVector = ImageVector.vectorResource(tab.iconRes),
contentDescription = stringResource(tab.titleRes),
// The label below already names the tab
contentDescription = null,
)
},
label = { Text(stringResource(tab.titleRes)) },
@@ -119,7 +119,7 @@ fun DenyListScreen(
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null,
contentDescription = stringResource(CoreR.string.back),
)
}
},
@@ -219,7 +219,7 @@ private fun SearchInput(
IconButton(onClick = { onQueryChange("") }) {
Icon(
imageVector = Icons.Default.Close,
contentDescription = null,
contentDescription = stringResource(CoreR.string.close),
tint = MaterialTheme.colorScheme.onSurfaceVariant
)
}
@@ -87,7 +87,7 @@ fun FlashScreen(
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null,
contentDescription = stringResource(CoreR.string.back),
)
}
},
@@ -65,6 +65,9 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
@@ -332,6 +335,10 @@ private fun RebootButton(
)
}
DropdownMenuItem(
// The check mark is the only sign of the safe mode state, so expose it
modifier = if (isSafeMode) {
Modifier.semantics { toggleableState = ToggleableState(safeModeEnabled >= 2) }
} else Modifier,
text = {
Text(
text = stringResource(item.labelRes),
@@ -82,7 +82,7 @@ fun ActionScreen(
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null,
contentDescription = stringResource(CoreR.string.back),
)
}
},
@@ -66,6 +66,8 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalResources
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.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
@@ -327,7 +329,9 @@ private fun ModuleCard(
}
Switch(
checked = item.isEnabled,
onCheckedChange = { viewModel.toggleEnabled(item) }
onCheckedChange = { viewModel.toggleEnabled(item) },
// The switch is its own node, so name the module it enables
modifier = Modifier.semantics { contentDescription = item.module.name },
)
}
@@ -389,7 +393,7 @@ private fun ModuleCard(
Icon(
modifier = Modifier.size(18.dp),
imageVector = Icons.Default.PlayArrow,
contentDescription = stringResource(CoreR.string.module_action)
contentDescription = null
)
Text(
text = stringResource(CoreR.string.module_action),
@@ -424,7 +428,7 @@ private fun ModuleCard(
Icon(
modifier = Modifier.size(18.dp),
imageVector = Icons.Default.CloudUpload,
contentDescription = stringResource(CoreR.string.update),
contentDescription = null,
)
Text(
text = stringResource(CoreR.string.update),