Status Update
Comments
cl...@google.com <cl...@google.com>
an...@google.com <an...@google.com> #2
Branch: androidx-master-dev
commit 23a7d960caf43390a554700d3c56ada189a9d10e
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Mon Aug 10 15:11:36 2020
IconButton / IconToggleButton API scrub
Test: ./gradlew updateApi
Bug:
Bug:
Relnote: "Adds enabled parameter to IconButton, and reorders parameters in IconToggleButton"
Change-Id: I0a9419b1a631cadad451395302ad87b7f9214f96
M ui/ui-material/api/current.txt
M ui/ui-material/api/public_plus_experimental_current.txt
M ui/ui-material/api/restricted_current.txt
M ui/ui-material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt
ma...@google.com <ma...@google.com>
ma...@google.com <ma...@google.com> #3
I gave it some thinking and my current inclination is that it doesn't make sense at all to make it a foundational requirement.
It's a grey areas, but still it strikes me as a design choice more than a general concept, so I wonder if we can just add delay(80)
to our ripple logic to solve the issue, but allow other indication/design system devs to decide on their own.
Louis, wdyt?
an...@google.com <an...@google.com> #4
This shouldn't be inside our Ripple, as it applies not only for this ripple. Plus once we migrate to the ripple imlementation based on RippleDrawable we would still need this delay. I think this should affect all indications
lp...@google.com <lp...@google.com> #5
I agree, I think this is core touch slop behavior for Android - it doesn't matter what the indication type is, we probably just don't want to propagate the down event until we are sure it wont' be the start of a scroll event
lp...@google.com <lp...@google.com> #6
Maybe it's reasonable to make this configurable (per platform?) but I don't think we should have any logic in indication / ripple at this level
bv...@gmail.com <bv...@gmail.com> #7
ma...@google.com <ma...@google.com> #8
We can utilize the ViewConfiguration that we have and that lives in commonMain for that. Would be great if we can somehow manage to incorporate it into the generic foundation indication then.
I don't like the idea of not propagating any events without any particular reason. It seems like the issue is with the indication, not the touch behaviour itself. The item should remain interactable and clickable even if click (down + up) fits into the 80msa or whatever timeframe we have for delaying the indication. Please, let me know if there are reasons why we would want to delay the pointer event itself.
Unless we have a strong reason, I'd like to keep this change localised in the indication api surface, not the touch surface. But I agree that generic foundation indication might be a better fit than ripples.
Folks, let me know what you think about it.
lp...@google.com <lp...@google.com> #9
I don't like the idea of not propagating any events without any particular reason.
Sorry, my message was confusing. What I mean is propagating the PressInteraction
inside clickable
, etc. I think these components should wait before sending the interaction - the actual motion events should not be touched.
If I read View.java correctly, this is how it works in the framework as well:
// For views inside a scrolling container, delay the pressed feedback for
// a short period in case this is a scroll.
if (isInScrollingContainer) {
mPrivateFlags |= PFLAG_PREPRESSED;
if (mPendingCheckForTap == null) {
mPendingCheckForTap = new CheckForTap();
}
mPendingCheckForTap.x = event.getX();
mPendingCheckForTap.y = event.getY();
postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout());
}
and
private final class CheckForTap implements Runnable {
public float x;
public float y;
@Override
public void run() {
mPrivateFlags &= ~PFLAG_PREPRESSED;
setPressed(true, x, y);
final long delay =
ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout();
checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS);
}
}
So setPressed()
is only called after the delay, when inside a scrolling container.
Do we have any current metadata for 'in a scrolling container' (presumably we do in semantics somewhere?) - can we use this in a similar way? It doesn't makes sense to delay the indication when there is no scroll action
ma...@google.com <ma...@google.com> #10
Thanks for checking, this rouse makes sense to me.
100% agree that we need to do it only in the scroll container -- that's a separate issue on it's own and I don't think semantics will help much here, but maybe?
talking out-loud: I was wondering if there's any reason other than indication when you want to delay the press interaction other than for the indication? probably if you long the event you can also want to not to have flakes when scrolling or similar, so it's the similar problem then.
And if we have ViewConfiguration, than you can always opt out specifically from the time out by providing a different ViewConfiguration
in LocalViewConfiguration
ambient
lp...@google.com <lp...@google.com> #11
And if we have ViewConfiguration, than you can always opt out specifically from the time out by providing a different ViewConfiguration in LocalViewConfiguration ambient
Oh I didn't realize we already had a common abstraction here, nice - yeah this looks really flexible to me.
talking out-loud: I was wondering if there's any reason other than indication when you want to delay the press interaction other than for the indication?
Yeah I think every case that cares (indication, changing a button to appear pressed (like elevation), sending logging metrics to a server when it is pressed, etc) should have this delay - if a scroll happens in the timeout then we cancel the click, so I think this should not emit the PressInteraction as well
bv...@gmail.com <bv...@gmail.com> #12
lp...@google.com <lp...@google.com> #13
Good point, the same is probably true for clickable list items with a swipe to dismiss action as well (and similar) - anything where the parent or this layout can be dragged / swiped.
ma...@google.com <ma...@google.com>
ap...@google.com <ap...@google.com> #14
Branch: androidx-main
commit 9066ec36bd05e42ffe8f2c37e0c74da2d0d5ba08
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Wed May 19 23:07:07 2021
Adds a tap timeout to clickable / toggleable to prevent showing a ripple during a scroll / drag
This results in the following behavior:
Press AND release within the timeout - show a ripple after release
Press, wait until timeout - show a ripple after timeout
Press, drag / scroll within the timeout - no ripple
Press, drag / scroll after the timout - ripple, then cancelled
Currently this happens for all cases, but in the future we should investigate disabling the timeout if the content is not in a scrollable container / if there is nothing that would consume move events.
Bug:
Test: ClickableTest
Relnote: "Adds a tap timeout to clickable / toggleable to prevent showing a ripple during a scroll / drag"
Change-Id: Ia27044999597dd9411344119a7b77180943d9a25
M compose/foundation/foundation/api/1.0.0-beta08.txt
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_1.0.0-beta08.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_1.0.0-beta08.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/androidAndroidTest/kotlin/androidx/compose/foundation/IndicationTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/SelectableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ToggleableTest.kt
A compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/Clickable.android.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt
A compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/Clickable.desktop.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CardTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
lp...@google.com <lp...@google.com> #15
Back to Matvei to consider providing scrolling-container metadata so we can only enable this timeout if there could be a scroll / drag in the post 1.0 timeframe.
lp...@google.com <lp...@google.com> #16
Filed
Description
Solution: use ViewConfiguration.getTapTimeout() to delay drawing the effect and ViewConfiguration.getScaledTouchSlop() to cancel the effect when the touches move.
A sample project and a screenrecord is attached.
Component used: Box, Text, Any (modifier)
Version used: 1.0.0-alpha02
Devices/Android versions reproduced on: Pixel 3A emulator API 29