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

Commit 81d43788 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow nearesttouchframe to hit the recents button in 3 button layout"

parents f2c5ee59 7e77da43
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
    android:id="@+id/menu_container"
    android:id="@+id/menu_container"
    android:layout_width="@dimen/navigation_key_width"
    android:layout_width="@dimen/navigation_key_width"
    android:layout_height="match_parent"
    android:layout_height="match_parent"
    android:focusable="false"
    android:importantForAccessibility="no"
    android:importantForAccessibility="no"
    >
    >
    <!-- Use nav button width & height=match_parent for parent FrameLayout and buttons because they
    <!-- Use nav button width & height=match_parent for parent FrameLayout and buttons because they
+1 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ public class NearestTouchFrame extends FrameLayout {
        return mClickableChildren
        return mClickableChildren
                .stream()
                .stream()
                .filter(v -> v.isAttachedToWindow())
                .filter(v -> v.isAttachedToWindow())
                .filter(v -> v.isFocusable())
                .map(v -> new Pair<>(distance(v, event), v))
                .map(v -> new Pair<>(distance(v, event), v))
                .min(Comparator.comparingInt(f -> f.first))
                .min(Comparator.comparingInt(f -> f.first))
                .get().second;
                .get().second;
+18 −0
Original line number Original line Diff line number Diff line
@@ -171,6 +171,23 @@ public class NearestTouchFrameTest extends SysuiTestCase {
        ev.recycle();
        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) {
    private View mockViewAt(int x, int y, int width, int height) {
        View v = spy(new View(mContext));
        View v = spy(new View(mContext));
        doAnswer(invocation -> {
        doAnswer(invocation -> {
@@ -187,6 +204,7 @@ public class NearestTouchFrameTest extends SysuiTestCase {
        v.setRight(width);
        v.setRight(width);
        v.setTop(0);
        v.setTop(0);
        v.setBottom(height);
        v.setBottom(height);
        v.setFocusable(true);
        return v;
        return v;
    }
    }
}
}
 No newline at end of file