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

Commit 99d189d1 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Cache locations of where nearest child is.

Computing the full tap area of a child/button helps
determine which regions launcher avoids starting the recents
animation for (ex. tapping over back button).
Previously we were only sending a button view's bounds
instead of the tappable region outside those bounds.

bug: 165805948
Test: Modifying existing tests in-progress.
Repro steps from bug no longer repro.

Change-Id: Icf11a0cf3de5b563b265c21f04afc13ea264f75b
parent 8168b608
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipChildren="false"
        android:clipToPadding="false">
        android:clipToPadding="false"
        systemui:isVertical="false">

        <LinearLayout
            android:id="@+id/ends_group"
+2 −1
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipChildren="false"
        android:clipToPadding="false">
        android:clipToPadding="false"
        systemui:isVertical="true">

        <com.android.systemui.navigationbar.buttons.ReverseLinearLayout
            android:id="@+id/ends_group"
+2 −0
Original line number Diff line number Diff line
@@ -143,6 +143,8 @@
    <attr name="handleColor" format="color" />
    <attr name="scrimColor" format="color" />

    <attr name="isVertical" format="boolean" />

    <!-- Used display CarrierText in Keyguard or QS Footer -->
    <declare-styleable name="CarrierText">
        <attr name="allCaps" format="boolean" />
+1 −1
Original line number Diff line number Diff line
@@ -1116,7 +1116,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        }
        // If an incoming call is ringing, HOME is totally disabled.
        // (The user is already on the InCallUI at this point,
        // and his ONLY options are to answer or reject the call.)
        // and their ONLY options are to answer or reject the call.)
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mHomeBlockedThisTouch = false;
+19 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import com.android.systemui.navigationbar.buttons.ContextualButton;
import com.android.systemui.navigationbar.buttons.ContextualButtonGroup;
import com.android.systemui.navigationbar.buttons.DeadZone;
import com.android.systemui.navigationbar.buttons.KeyButtonDrawable;
import com.android.systemui.navigationbar.buttons.NearestTouchFrame;
import com.android.systemui.navigationbar.buttons.RotationContextButton;
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
import com.android.systemui.navigationbar.gestural.FloatingRotationButton;
@@ -97,6 +98,8 @@ import com.android.wm.shell.legacysplitscreen.LegacySplitScreen;
import com.android.wm.shell.pip.Pip;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;

public class NavigationBarView extends FrameLayout implements
@@ -129,6 +132,7 @@ public class NavigationBarView extends FrameLayout implements
    private final Region mTmpRegion = new Region();
    private final int[] mTmpPosition = new int[2];
    private Rect mTmpBounds = new Rect();
    private Map<View, Rect> mButtonFullTouchableRegions = new HashMap<>();

    private KeyButtonDrawable mBackIcon;
    private KeyButtonDrawable mHomeDefaultIcon;
@@ -973,9 +977,18 @@ public class NavigationBarView extends FrameLayout implements
                getButtonLocations(true /* includeFloatingRotationButton */, true /* inScreen */));
    }

    private void updateButtonTouchRegionCache() {
        FrameLayout navBarLayout = mIsVertical
                ? mNavigationInflaterView.mVertical
                : mNavigationInflaterView.mHorizontal;
        mButtonFullTouchableRegions = ((NearestTouchFrame) navBarLayout
                .findViewById(R.id.nav_buttons)).getFullTouchableChildRegions();
    }

    private Region getButtonLocations(boolean includeFloatingRotationButton,
            boolean inScreenSpace) {
        mTmpRegion.setEmpty();
        updateButtonTouchRegionCache();
        updateButtonLocation(getBackButton(), inScreenSpace);
        updateButtonLocation(getHomeButton(), inScreenSpace);
        updateButtonLocation(getRecentsButton(), inScreenSpace);
@@ -999,6 +1012,12 @@ public class NavigationBarView extends FrameLayout implements
        if (view == null || !button.isVisible()) {
            return;
        }
        // If the button is tappable from perspective of NearestTouchFrame, then we'll
        // include the regions where the tap is valid instead of just the button layout location
        if (mButtonFullTouchableRegions.containsKey(view)) {
            mTmpRegion.op(mButtonFullTouchableRegions.get(view), Op.UNION);
            return;
        }
        updateButtonLocation(view, inScreenSpace);
    }

Loading