a11y: expose swipe actions to screen readers
- Commit
7f09a9997a895b3bc87297da87affb48269c891e- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-21 04:18 UTC (15 days ago)
- Parents
d049676
Swipe-only actions were unreachable without the gesture. Health (conditions, labs, medications, vaccinations, allergies), email (mark read/unread, delete), securemail (mark read, trash/delete-forever, delete draft) and todo (delete - the one action its established pattern lacked) now pass accessibilityActions through SwipeActionsBox, wired to the same callbacks as the swipes, labels from resources. Verified: compile for health, email, securemail, todo.
Diff
email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt
diff --git a/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt b/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.ktindex 451e7cc4e9..4e30074ae4 100644--- a/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt+++ b/email/src/main/java/com/vayunmathur/email/ui/MessageListScreen.kt@@ -32,6 +32,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource+import androidx.compose.ui.semantics.CustomAccessibilityAction import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp@@ -218,11 +219,27 @@ fun MessageListScreen( val accountBandColor = Color(accountColor(message.accountEmail)) val isSelected = message.id in state.selectedUids val currentMessage by rememberUpdatedState(message)+ val deleteLabel = stringResource(R.string.action_delete)+ val markLabel = stringResource(+ if (currentMessage.isRead) R.string.action_mark_as_unread else R.string.action_mark_as_read,+ ) com.vayunmathur.library.ui.SwipeActionsBox( onEndToStart = { pendingDelete = currentMessage }, onStartToEnd = { actions.markAsRead(currentMessage.accountEmail, currentMessage.folderName, currentMessage.id, !currentMessage.isRead) },+ accessibilityActions = listOf(+ CustomAccessibilityAction(markLabel) {+ actions.markAsRead(+ currentMessage.accountEmail,+ currentMessage.folderName,+ currentMessage.id,+ !currentMessage.isRead,+ )+ true+ },+ CustomAccessibilityAction(deleteLabel) { pendingDelete = currentMessage; true },+ ), background = { side -> when (side) { com.vayunmathur.library.ui.SwipeActionSide.EndToStart ->
email/src/main/res/values/strings.xml
diff --git a/email/src/main/res/values/strings.xml b/email/src/main/res/values/strings.xmlindex 9a6f18572c..c29204e8de 100644--- a/email/src/main/res/values/strings.xml+++ b/email/src/main/res/values/strings.xml@@ -128,6 +128,9 @@ <item quantity="other"><xliff:g id="count" example="2">%1$s</xliff:g> attempts</item> </plurals> + <string name="action_delete">Delete</string>+ <string name="action_mark_as_read">Mark as read</string>+ <string name="action_mark_as_unread">Mark as unread</string> <string name="cd_insert_image">Insert image</string> <string name="normal">Normal</string> <string name="heading_1">Heading 1</string>
health/src/main/java/com/vayunmathur/health/ui/MedicalPage.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/MedicalPage.kt b/health/src/main/java/com/vayunmathur/health/ui/MedicalPage.ktindex 87b452f5d2..177ecb65ba 100644--- a/health/src/main/java/com/vayunmathur/health/ui/MedicalPage.kt+++ b/health/src/main/java/com/vayunmathur/health/ui/MedicalPage.kt@@ -10,6 +10,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.res.stringResource+import androidx.compose.ui.semantics.CustomAccessibilityAction import androidx.compose.ui.unit.dp import com.vayunmathur.health.R import com.vayunmathur.health.Route@@ -231,9 +232,13 @@ fun MedicalPage(backStack: NavBackStack<Route>, viewModel: MedicalViewModel) { itemCount = vaccinations.size, ) { index -> val entry = vaccinations[index]+ val deleteLabel = stringResource(R.string.a11y_delete_vaccination) SwipeActionsBox( enableStartToEnd = false, onEndToStart = { pendingVaccinationDelete = entry },+ accessibilityActions = listOf(+ CustomAccessibilityAction(deleteLabel) { pendingVaccinationDelete = entry; true },+ ), ) { HealthRow( headline = entry.displayName,@@ -258,9 +263,13 @@ fun MedicalPage(backStack: NavBackStack<Route>, viewModel: MedicalViewModel) { itemCount = allergies.size, ) { index -> val entry = allergies[index]+ val deleteLabel = stringResource(R.string.a11y_delete_allergy) SwipeActionsBox( enableStartToEnd = false, onEndToStart = { pendingAllergyDelete = entry },+ accessibilityActions = listOf(+ CustomAccessibilityAction(deleteLabel) { pendingAllergyDelete = entry; true },+ ), ) { HealthRow( headline = entry.displayName,
health/src/main/java/com/vayunmathur/health/ui/MedicalSections.kt
diff --git a/health/src/main/java/com/vayunmathur/health/ui/MedicalSections.kt b/health/src/main/java/com/vayunmathur/health/ui/MedicalSections.ktindex 6815c52a2e..e128cb3358 100644--- a/health/src/main/java/com/vayunmathur/health/ui/MedicalSections.kt+++ b/health/src/main/java/com/vayunmathur/health/ui/MedicalSections.kt@@ -10,6 +10,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Shape import androidx.compose.ui.res.stringResource+import androidx.compose.ui.semantics.CustomAccessibilityAction import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.vayunmathur.health.R@@ -54,9 +55,13 @@ internal fun MedicalConditionsSection( itemCount = entries.size, ) { index -> val entry = entries[index]+ val deleteLabel = stringResource(R.string.a11y_delete_condition) SwipeActionsBox( enableStartToEnd = false, onEndToStart = { onDelete(entry) },+ accessibilityActions = listOf(+ CustomAccessibilityAction(deleteLabel) { onDelete(entry); true },+ ), ) { HealthRow( headline = entry.displayName,@@ -85,9 +90,13 @@ internal fun MedicalLabSection( itemCount = entries.size, ) { index -> val entry = entries[index]+ val deleteLabel = stringResource(R.string.a11y_delete_lab_result) SwipeActionsBox( enableStartToEnd = false, onEndToStart = { onDelete(entry) },+ accessibilityActions = listOf(+ CustomAccessibilityAction(deleteLabel) { onDelete(entry); true },+ ), ) { HealthRow( headline = entry.displayName,@@ -128,9 +137,13 @@ internal fun MedicalMedicationsSection( ) { index -> if (index < current.size) { val entry = current[index]+ val deleteLabel = stringResource(R.string.a11y_delete_medication) SwipeActionsBox( enableStartToEnd = false, onEndToStart = { onDelete(entry) },+ accessibilityActions = listOf(+ CustomAccessibilityAction(deleteLabel) { onDelete(entry); true },+ ), ) { HealthRow( headline = listOfNotNull(@@ -192,9 +205,13 @@ internal fun MedicalMedicationsSection( ), color = MaterialTheme.colorScheme.surfaceContainerHighest, ) {+ val deleteLabel = stringResource(R.string.a11y_delete_medication) SwipeActionsBox( enableStartToEnd = false, onEndToStart = { onDelete(entry) },+ accessibilityActions = listOf(+ CustomAccessibilityAction(deleteLabel) { onDelete(entry); true },+ ), ) { HealthRow( headline = listOfNotNull(
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 236ddb39e2..8c3119fa9c 100644--- a/health/src/main/res/values/strings.xml+++ b/health/src/main/res/values/strings.xml@@ -300,6 +300,16 @@ <string name="edit_vaccination">Edit vaccination</string> <!-- MedicalPage: Confirm deleting one medical record (vaccination, medication, allergy, condition, lab result). %1$s = record display name. Sentence --> <string name="delete_record_confirm">Delete the record of %1$s?</string>+ <!-- MedicalPage: accessibility action mirroring the swipe-to-delete gesture. Verb phrase -->+ <string name="a11y_delete_vaccination">Delete vaccination</string>+ <!-- MedicalPage: accessibility action mirroring the swipe-to-delete gesture. Verb phrase -->+ <string name="a11y_delete_allergy">Delete allergy</string>+ <!-- MedicalSections: accessibility action mirroring the swipe-to-delete gesture. Verb phrase -->+ <string name="a11y_delete_condition">Delete condition</string>+ <!-- MedicalSections: accessibility action mirroring the swipe-to-delete gesture. Verb phrase -->+ <string name="a11y_delete_lab_result">Delete lab result</string>+ <!-- MedicalSections: accessibility action mirroring the swipe-to-delete gesture. Verb phrase -->+ <string name="a11y_delete_medication">Delete medication</string> <!-- MedicalPage: CVX code shown under a vaccination entry. %1$s = code, e.g. 08 --> <!-- MedicalPage: Empty state when no medications are recorded. Sentence -->
securemail/src/main/java/com/vayunmathur/securemail/ui/MessageRow.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/MessageRow.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/MessageRow.ktindex 7c011c2fec..1ff64f8106 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/ui/MessageRow.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/MessageRow.kt@@ -22,6 +22,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource+import androidx.compose.ui.semantics.CustomAccessibilityAction import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp@@ -60,9 +61,15 @@ fun MessageRow( onSwipeDelete: () -> Unit, inTrash: Boolean, ) {+ val markLabel = stringResource(if (msg.isRead) R.string.action_mark_as_unread else R.string.action_mark_as_read)+ val deleteLabel = stringResource(if (inTrash) R.string.action_delete_forever else R.string.action_move_to_trash) SwipeActionsBox( onStartToEnd = onToggleRead, onEndToStart = onSwipeDelete,+ accessibilityActions = listOf(+ CustomAccessibilityAction(markLabel) { onToggleRead(); true },+ CustomAccessibilityAction(deleteLabel) { onSwipeDelete(); true },+ ), background = { side -> when (side) { SwipeActionSide.StartToEnd -> Box(
securemail/src/main/java/com/vayunmathur/securemail/ui/OutScreen.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/OutScreen.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/OutScreen.ktindex 0d074253cc..453ddcdcfb 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/ui/OutScreen.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/OutScreen.kt@@ -16,6 +16,7 @@ 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.CustomAccessibilityAction import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.AppScaffold@@ -153,9 +154,13 @@ private fun SectionDivider() { @Composable private fun DraftRow(draft: Draft, onOpen: () -> Unit, onDelete: () -> Unit) {+ val deleteLabel = stringResource(R.string.action_delete_draft) SwipeActionsBox( enableStartToEnd = false, onEndToStart = onDelete,+ accessibilityActions = listOf(+ CustomAccessibilityAction(deleteLabel) { onDelete(); true },+ ), background = { side -> if (side == SwipeActionSide.EndToStart) { Box(Modifier.fillMaxSize().padding(horizontal = 20.dp), contentAlignment = Alignment.CenterEnd) {
securemail/src/main/res/values/strings.xml
diff --git a/securemail/src/main/res/values/strings.xml b/securemail/src/main/res/values/strings.xmlindex 072eb1a742..850e199e7c 100644--- a/securemail/src/main/res/values/strings.xml+++ b/securemail/src/main/res/values/strings.xml@@ -105,6 +105,16 @@ <string name="encrypted_sender_parenthesized">(encrypted sender)</string> <!-- MessageRow: preview placeholder prompting to open an encrypted message. Verb phrase. --> <string name="message_open_to_decrypt">Open to decrypt</string>+ <!-- MessageRow: accessibility action mirroring the swipe to toggle read state. Verb phrase. -->+ <string name="action_mark_as_read">Mark as read</string>+ <!-- MessageRow: accessibility action mirroring the swipe to toggle read state. Verb phrase. -->+ <string name="action_mark_as_unread">Mark as unread</string>+ <!-- MessageRow: accessibility action mirroring the swipe to move to Trash. Verb phrase. -->+ <string name="action_move_to_trash">Move to Trash</string>+ <!-- MessageRow: accessibility action mirroring the swipe to permanently delete in Trash. Verb phrase. -->+ <string name="action_delete_forever">Delete forever</string>+ <!-- OutScreen DraftRow: accessibility action mirroring the swipe to delete a draft. Verb phrase. -->+ <string name="action_delete_draft">Delete draft</string> <!-- NavigationEntries: reply subject prefix. %1$s is the original subject. --> <string name="reply_subject_format">Re: %1$s</string>
todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt
diff --git a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.ktindex faa8e620c4..21ad21468e 100644--- a/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt+++ b/todo/src/main/java/com/vayunmathur/todo/ui/TodoListRow.kt@@ -49,8 +49,10 @@ fun LazyItemScope.TodoListRow( val toggleLabel = stringResource(if (row.todo.done) R.string.action_mark_not_done else R.string.action_mark_done) val upLabel = stringResource(R.string.action_move_up) val downLabel = stringResource(R.string.action_move_down)+ val deleteLabel = stringResource(R.string.delete) val a11y = buildList { add(CustomAccessibilityAction(toggleLabel) { handlers.onToggle(row); true })+ add(CustomAccessibilityAction(deleteLabel) { handlers.onDelete(row); true }) handlers.onMoveUp?.let { up -> add(CustomAccessibilityAction(upLabel) { up(row); true }) } handlers.onMoveDown?.let { down -> add(CustomAccessibilityAction(downLabel) { down(row); true }) } }