-
-
Notifications
You must be signed in to change notification settings - Fork 231
InputService: real-time gestures #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
ab6a0f6
to
c81edd0
Compare
Android O has added support for building gestures incrementally, allowing to send input events almost in real-time. Older versions of Android will continue to wait for gestures to complete before dispatching them.
c81edd0
to
7882167
Compare
@@ -260,7 +269,7 @@ public static void onPointerEvent(int buttonMask, int x, int y, long client) { | |||
// down, was up | |||
if ((buttonMask & (1 << 0)) != 0 && !inputContext.isButtonOneDown) { | |||
inputContext.isButtonOneDown = true; | |||
instance.startGesture(inputContext, x, y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces a regression regarding multi-client input. Please leave the logic client-specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I was so focused on getting gestures to work that I didn't even notice that there are multiple InputContext
instances. Fixed this here.
void endGesture(InputContext inputContext, int x, int y); | ||
} | ||
|
||
private static class LegacyGestureHandler implements GestureHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for these classes IMO, just do the Android version differentiation in the existing handlers .-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did you have in mind exactly? I'm trying to merge the two handlers, but the code is getting a lot more confusing and hard to follow.
Unrelated: I noticed that you were using System.currentTimeMillis()
, which is not monotonic. This means that if the system time changes while there is an ongoing gesture the resulting duration
will be wrong. SystemClock.elapsedRealtime()
is better for measuring intervals.
- Pass InputContext to the constructor to make the GestureHandler interface independent. - Remove unnecessary instance methods. - Duplicate some comments.
Android O has added support for building gestures incrementally, allowing to send input events almost in real-time.
Older versions of Android will continue to wait for gestures to complete before dispatching them.