Status Update
Comments
ma...@google.com <ma...@google.com> #2
I wasn't sure if long click or double click should have their own label and how actions actually will be integrates, so I'm leaving this for you.
qa...@google.com <qa...@google.com>
yi...@google.com <yi...@google.com> #3
The double click will need need a custom action (will show in local context menu with the action label) and may be a bit confusing for TalkBack users (so we need a good default action label).
Do you want to pass the double click action to accessibility?
ma...@google.com <ma...@google.com> #4
Do you want to pass the double click action to accessibility?
No, there's no such requirement from our side. I filed this bug in order to make sure that we have proper support for long/double clicks in a11y no matter what the support will be.
You mentioned that this is done by custom action with the label. Do you think it makes sense to add an API to clickable to make it easy for developers to just specify doubleClick label and (if also onDoubleCkick lambda is non-null) we can insert this custom action by them. This is probably what devs want is most of the cases, isn't it?
We also need to consider cases where this is not what you want, how often are this cases occur and whether or not we need to make it easy to opt out from this custom action.
yi...@google.com <yi...@google.com> #5
@Composable
fun Modifier.clickable(
enabled: Boolean = true,
onClickLabel: String? = null,
interactionState: InteractionState = remember { InteractionState() },
indication: Indication? = IndicationAmbient.current(),
onLongClickLabel: String? = null,
onLongClick: (() -> Unit)? = null,
onDoubleClickLabel: String? = null, <-------------
onDoubleClick: (() -> Unit)? = null,
onClick: () -> Unit
) = composed {
val semanticModifier = Modifier.semantics(mergeAllDescendants = true) {
if (enabled) {
//
onClick(action = { onClick(); true }, label = onClickLabel)
if (onLongClick != null) {
onLongClick(action = { onLongClick(); true }, label = onLongClickLabel)
}
if (onDoubleClick != null) {. <-----------------------
this.customActions = listOf(
CustomAccessibilityAction(
action = { onDoubleClick(); true},
label = onDoubleClickLabel ?: defaultDoubleClickLabel
)
)
}
} else {
disabled()
}
This will pass a custom accessibility action to accessibility framework. In talkback (not very familiar with switch access, but I think they should have ways to handle it), this custom action will show up in local context menu (when focus on the item, swipe up then right. The context menu is a list. The custom action will show up as a list item with the onDoubleClickLabel or defaultDoubleClickLabel as the text). When user clicks on local context menu item, it performs the onDoubleClick lambda.
Is this what you have in mind? The only concern I have is whether talkback user will be confused if the developer didn't pass a good onDoubleClick label because when talkback is turned on, single click is used to place accessibility focus on an item and double click is used to perform "normal click (onClick)".
ap...@google.com <ap...@google.com> #6
Branch: androidx-master-dev
commit 93463e73490f38e19b2baa4cc6e0ee97a4d30081
Author: yingleiw <yingleiw@google.com>
Date: Thu Sep 17 14:52:59 2020
Add long click semantics action and handle it in accessibility
Relnote: "Add long click semantics action"
Bug:
Test: tested with switch access and compose demo app. Also added unit
test on semantics side. Will add unit test when accessibility unit test
is in.
Change-Id: I6281b383328d549b30b3ef915e717abbbb28ddaa
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ClickableTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/public_plus_experimental_current.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/semantics/SemanticsProperties.kt
Description