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

Commit 7e77da43 authored by Matthew Ng's avatar Matthew Ng
Browse files

Allow nearesttouchframe to hit the recents button in 3 button layout

Menu Ime for 3 button layout cannot be hit because nearesttouchframe is
trying to hit the framelayout of menu_ime that contains nothing inside.
Making it check for non-focused buttons will allow it to hit the recents
button.

Change-Id: Id464e9931345911ffba374a1349536cbf270abdf
Fixes: 112432937
Test: atest NearestTouchFrameTest
parent 1ff73729
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
    android:id="@+id/menu_container"
    android:layout_width="@dimen/navigation_key_width"
    android:layout_height="match_parent"
    android:focusable="false"
    android:importantForAccessibility="no"
    >
    <!-- Use nav button width & height=match_parent for parent FrameLayout and buttons because they
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ public class NearestTouchFrame extends FrameLayout {
        return mClickableChildren
                .stream()
                .filter(v -> v.isAttachedToWindow())
                .filter(v -> v.isFocusable())
                .map(v -> new Pair<>(distance(v, event), v))
                .min(Comparator.comparingInt(f -> f.first))
                .get().second;
+18 −0
Original line number Diff line number Diff line
@@ -171,6 +171,23 @@ public class NearestTouchFrameTest extends SysuiTestCase {
        ev.recycle();
    }

    @Test
    public void testFurtherSelectedWhenCloserNotFocusable() {
        View closer = mockViewAt(0, 0, 10, 10);
        View further = mockViewAt(20, 0, 10, 10);
        closer.setFocusable(false);

        mNearestTouchFrame.addView(closer);
        mNearestTouchFrame.addView(further);
        mNearestTouchFrame.onMeasure(0, 0);

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

    private View mockViewAt(int x, int y, int width, int height) {
        View v = spy(new View(mContext));
        doAnswer(invocation -> {
@@ -187,6 +204,7 @@ public class NearestTouchFrameTest extends SysuiTestCase {
        v.setRight(width);
        v.setTop(0);
        v.setBottom(height);
        v.setFocusable(true);
        return v;
    }
}
 No newline at end of file