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

Commit 3dd17a78 authored by Jason Monk's avatar Jason Monk
Browse files

Fix disabled views with nearest touch frame

Test: runtest systemui
Change-Id: I83fe0483d2d45c05750cb52fa66c579be0194091
Fixes: 65158062
parent 89eceea5
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -87,7 +87,8 @@ public class NearestTouchFrame extends FrameLayout {
            if (mTouchingChild != null) {
            if (mTouchingChild != null) {
                event.offsetLocation(mTouchingChild.getWidth() / 2 - event.getX(),
                event.offsetLocation(mTouchingChild.getWidth() / 2 - event.getX(),
                        mTouchingChild.getHeight() / 2 - event.getY());
                        mTouchingChild.getHeight() / 2 - event.getY());
                return mTouchingChild.dispatchTouchEvent(event);
                return mTouchingChild.getVisibility() == VISIBLE
                        && mTouchingChild.dispatchTouchEvent(event);
            }
            }
        }
        }
        return super.onTouchEvent(event);
        return super.onTouchEvent(event);
+18 −0
Original line number Original line Diff line number Diff line
@@ -70,6 +70,24 @@ public class NearestTouchFrameTest extends SysuiTestCase {
        ev.recycle();
        ev.recycle();
    }
    }


    @Test
    public void testInvisibleViews() {
        View left = mockViewAt(0, 0, 10, 10);
        View right = mockViewAt(20, 0, 10, 10);
        when(left.getVisibility()).thenReturn(View.INVISIBLE);

        mNearestTouchFrame.addView(left);
        mNearestTouchFrame.addView(right);
        mNearestTouchFrame.onMeasure(0, 0);

        MotionEvent ev = MotionEvent.obtain(0, 0, 0,
                12 /* x */, 5 /* y */, 0);
        mNearestTouchFrame.onTouchEvent(ev);
        verify(left, never()).onTouchEvent(eq(ev));
        verify(right, never()).onTouchEvent(eq(ev));
        ev.recycle();
    }

    @Test
    @Test
    public void testHorizontalSelection_Left() {
    public void testHorizontalSelection_Left() {
        View left = mockViewAt(0, 0, 10, 10);
        View left = mockViewAt(0, 0, 10, 10);