diff --git a/android/app/src/main/java/com/fabledsword/minstrel/player/ui/QueueScreen.kt b/android/app/src/main/java/com/fabledsword/minstrel/player/ui/QueueScreen.kt index 490fad42..d25b75b1 100644 --- a/android/app/src/main/java/com/fabledsword/minstrel/player/ui/QueueScreen.kt +++ b/android/app/src/main/java/com/fabledsword/minstrel/player/ui/QueueScreen.kt @@ -234,23 +234,7 @@ private fun QueueRow( .graphicsLayer { translationY = dragOffsetY } .background(highlight) .clickable(onClick = onClick) - // Replaces the capability the grip icon carried. Its - // contentDescription ("Reorder track") was the ONLY thing telling a - // screen reader this list could be reordered, and a long-press drag - // is not operable with TalkBack at all. These custom actions are the - // Android counterpart to the web row's ArrowUp/ArrowDown keys — - // without them, dropping the grip would have quietly removed - // reordering for anyone not using touch. - .semantics { - customActions = listOf( - CustomAccessibilityAction("Move up") { - if (index > 0) { onMove(index, index - 1); true } else false - }, - CustomAccessibilityAction("Move down") { - if (index < queueSize - 1) { onMove(index, index + 1); true } else false - }, - ) - } + .queueReorderActions(index = index, queueSize = queueSize, onMove = onMove) .padding(horizontal = 16.dp, vertical = 12.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp), @@ -290,6 +274,31 @@ private fun QueueRow( } } +/** + * Screen-reader reordering for a queue row. + * + * Replaces the capability the grip icon carried: its contentDescription + * ("Reorder track") was the ONLY thing telling a screen reader this list could + * be reordered, and a long-press drag is not operable with TalkBack at all. + * These are the Android counterpart to the web row's ArrowUp/ArrowDown keys — + * without them, dropping the grip would have quietly removed reordering for + * anyone not using touch. + */ +private fun Modifier.queueReorderActions( + index: Int, + queueSize: Int, + onMove: (Int, Int) -> Unit, +): Modifier = semantics { + customActions = listOf( + CustomAccessibilityAction("Move up") { + if (index > 0) { onMove(index, index - 1); true } else false + }, + CustomAccessibilityAction("Move down") { + if (index < queueSize - 1) { onMove(index, index + 1); true } else false + }, + ) +} + /** * Reorder-drag behaviour for a queue row, applied to whatever element is the * grab surface — the album art, since #2395 removed the grip icon.