From a92a9f219897c7003465cb7601c7df48be5510d3 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 4 Aug 2026 08:52:40 -0400 Subject: [PATCH] =?UTF-8?q?fix(player):=20extract=20the=20reorder=20a11y?= =?UTF-8?q?=20actions=20to=20clear=20detekt=20LongMethod=20=E2=80=94=20#23?= =?UTF-8?q?95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QueueRow hit 61 statements against detekt's 60 — the semantics block I added for the screen-reader move actions pushed it one over. Extracted to a `Modifier.queueReorderActions` extension, which mirrors the `queueReorderDrag` extension from the same change: the row now composes two named modifiers, one for the gesture and one for the accessibility actions, instead of carrying either inline. Better than suppressing the rule — the suppression would have been permanent and the split reads better anyway. Co-Authored-By: Claude Opus 5 (1M context) --- .../minstrel/player/ui/QueueScreen.kt | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) 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.