Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d27a6319 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Prevent touch delegate from blocking parent events

Make sure that TouchDelegate does not interfere with
handling of parent's events, such as onClick().
Currently, the variable mDelegateTargeted is sticky,
and after the TouchDelegate is first activated,
stays true for the remainder of its life. Therefore, the
parent view will no longer receive clicks after the
TouchDelegate is first clicked. This patch forces the
re-evaluation of mDelegateTargeted on each new ACTION_DOWN
event.

Test: bit CtsViewTestCases:.TouchDelegateTest
Bug: 65392236
Change-Id: Ifa6430ce6e8400c0411df7da66281219ea97733c
parent a5da2cf5
Loading
Loading
Loading
Loading
+20 −26
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class TouchDelegate {

    /**
     * mBounds inflated to include some slop. This rect is to track whether the motion events
     * should be considered to be be within the delegate view.
     * should be considered to be within the delegate view.
     */
    private Rect mSlopBounds;

@@ -64,14 +64,12 @@ public class TouchDelegate {
    public static final int BELOW = 2;

    /**
     * The touchable region of the View extends to the left of its
     * actual extent.
     * The touchable region of the View extends to the left of its actual extent.
     */
    public static final int TO_LEFT = 4;

    /**
     * The touchable region of the View extends to the right of its
     * actual extent.
     * The touchable region of the View extends to the right of its actual extent.
     */
    public static final int TO_RIGHT = 8;

@@ -109,12 +107,8 @@ public class TouchDelegate {

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            Rect bounds = mBounds;

            if (bounds.contains(x, y)) {
                mDelegateTargeted = true;
                sendToDelegate = true;
            }
                mDelegateTargeted = mBounds.contains(x, y);
                sendToDelegate = mDelegateTargeted;
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_MOVE: