From 01b729f2b45884836edb7627723b56ff692e05c3 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Fri, 16 Feb 2018 17:27:22 -0600 Subject: [PATCH] Allow TouchDelegate to forward non-primary pointer Currently, TouchDelegate can be used to receive the primary pointer events with actions ACTION_DOWN, ACTION_UP, and ACTION_MOVE. While ACTION_MOVE will contain the data for all active pointers (not just primary), currently TouchDelegate will not forward ACTION_POINTER_DOWN and ACTION_POINTER_UP events. This change modifies TouchDelegate behaviour to also forward the non-primary pointer DOWN and UP events to the target view. Bug: 37060799 Test: atest cts.TouchDelegateTest Change-Id: Ieb457c9e15058302cb26d9d4a83f958bbec8dbc0 --- core/java/android/view/TouchDelegate.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/TouchDelegate.java b/core/java/android/view/TouchDelegate.java index dc50fa1d6036..d6c43e80390f 100644 --- a/core/java/android/view/TouchDelegate.java +++ b/core/java/android/view/TouchDelegate.java @@ -105,11 +105,13 @@ public class TouchDelegate { boolean hit = true; boolean handled = false; - switch (event.getAction()) { + switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: mDelegateTargeted = mBounds.contains(x, y); sendToDelegate = mDelegateTargeted; break; + case MotionEvent.ACTION_POINTER_DOWN: + case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_UP: case MotionEvent.ACTION_MOVE: sendToDelegate = mDelegateTargeted; -- 2.11.0