fix(player): extract the reorder a11y actions to clear detekt LongMethod — #2395
android / Build + lint + test (push) Successful in 3m51s

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) <noreply@anthropic.com>
This commit is contained in:
2026-08-04 08:52:40 -04:00
co-authored by Claude Opus 5
parent 6dea45a634
commit a92a9f2198
@@ -234,23 +234,7 @@ private fun QueueRow(
.graphicsLayer { translationY = dragOffsetY } .graphicsLayer { translationY = dragOffsetY }
.background(highlight) .background(highlight)
.clickable(onClick = onClick) .clickable(onClick = onClick)
// Replaces the capability the grip icon carried. Its .queueReorderActions(index = index, queueSize = queueSize, onMove = onMove)
// 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
},
)
}
.padding(horizontal = 16.dp, vertical = 12.dp), .padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp), 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 * Reorder-drag behaviour for a queue row, applied to whatever element is the
* grab surface — the album art, since #2395 removed the grip icon. * grab surface — the album art, since #2395 removed the grip icon.