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

Commit 87ce6fa6 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Make specific nav touchable region when the IME is showing"

parents cfa66d9e fc53675a
Loading
Loading
Loading
Loading
+34 −29
Original line number Original line Diff line number Diff line
@@ -124,7 +124,8 @@ public class NavigationBarView extends FrameLayout implements
    int mNavigationIconHints = 0;
    int mNavigationIconHints = 0;
    private int mNavBarMode;
    private int mNavBarMode;


    private final Region mActiveRegion = new Region();
    private final Region mTmpRegion = new Region();
    private final int[] mTmpPosition = new int[2];
    private Rect mTmpBounds = new Rect();
    private Rect mTmpBounds = new Rect();


    private KeyButtonDrawable mBackIcon;
    private KeyButtonDrawable mBackIcon;
@@ -266,24 +267,14 @@ public class NavigationBarView extends FrameLayout implements
    private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = info -> {
    private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = info -> {
        // When the nav bar is in 2-button or 3-button mode, or when IME is visible in fully
        // When the nav bar is in 2-button or 3-button mode, or when IME is visible in fully
        // gestural mode, the entire nav bar should be touchable.
        // gestural mode, the entire nav bar should be touchable.
        if (!mEdgeBackGestureHandler.isHandlingGestures() || mImeVisible) {
        if (!mEdgeBackGestureHandler.isHandlingGestures()) {
            info.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_FRAME);
            info.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_FRAME);
            return;
            return;
        }
        }


        info.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
        info.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
        ButtonDispatcher imeSwitchButton = getImeSwitchButton();
        info.touchableRegion.set(getButtonLocations(false /* includeFloatingRotationButton */,
        if (imeSwitchButton.getVisibility() == VISIBLE) {
                false /* inScreen */));
            // If the IME is not up, but the ime switch button is visible, then make sure that
            // button is touchable
            int[] loc = new int[2];
            View buttonView = imeSwitchButton.getCurrentView();
            buttonView.getLocationInWindow(loc);
            info.touchableRegion.set(loc[0], loc[1], loc[0] + buttonView.getWidth(),
                    loc[1] + buttonView.getHeight());
            return;
        }
        info.touchableRegion.setEmpty();
    };
    };


    private final Consumer<Boolean> mRotationButtonListener = (visible) -> {
    private final Consumer<Boolean> mRotationButtonListener = (visible) -> {
@@ -956,30 +947,44 @@ public class NavigationBarView extends FrameLayout implements
     * Notifies the overview service of the active touch regions.
     * Notifies the overview service of the active touch regions.
     */
     */
    public void notifyActiveTouchRegions() {
    public void notifyActiveTouchRegions() {
        mActiveRegion.setEmpty();
        mOverviewProxyService.onActiveNavBarRegionChanges(
        updateButtonLocation(getBackButton());
                getButtonLocations(true /* includeFloatingRotationButton */, true /* inScreen */));
        updateButtonLocation(getHomeButton());
    }
        updateButtonLocation(getRecentsButton());

        updateButtonLocation(getImeSwitchButton());
    private Region getButtonLocations(boolean includeFloatingRotationButton,
        updateButtonLocation(getAccessibilityButton());
            boolean inScreenSpace) {
        if (mFloatingRotationButton.isVisible()) {
        mTmpRegion.setEmpty();
            View floatingRotationView = mFloatingRotationButton.getCurrentView();
        updateButtonLocation(getBackButton(), inScreenSpace);
            floatingRotationView.getBoundsOnScreen(mTmpBounds);
        updateButtonLocation(getHomeButton(), inScreenSpace);
            mActiveRegion.op(mTmpBounds, Op.UNION);
        updateButtonLocation(getRecentsButton(), inScreenSpace);
        updateButtonLocation(getImeSwitchButton(), inScreenSpace);
        updateButtonLocation(getAccessibilityButton(), inScreenSpace);
        if (includeFloatingRotationButton && mFloatingRotationButton.isVisible()) {
            updateButtonLocation(mFloatingRotationButton.getCurrentView(), inScreenSpace);
        } else {
        } else {
            updateButtonLocation(getRotateSuggestionButton());
            updateButtonLocation(getRotateSuggestionButton(), inScreenSpace);
        }
        }
        mOverviewProxyService.onActiveNavBarRegionChanges(mActiveRegion);
        return mTmpRegion;
    }
    }


    private void updateButtonLocation(ButtonDispatcher button) {
    private void updateButtonLocation(ButtonDispatcher button, boolean inScreenSpace) {
        View view = button.getCurrentView();
        View view = button.getCurrentView();
        if (view == null || !button.isVisible()) {
        if (view == null || !button.isVisible()) {
            return;
            return;
        }
        }
        updateButtonLocation(view, inScreenSpace);
    }


    private void updateButtonLocation(View view, boolean inScreenSpace) {
        if (inScreenSpace) {
            view.getBoundsOnScreen(mTmpBounds);
            view.getBoundsOnScreen(mTmpBounds);
        mActiveRegion.op(mTmpBounds, Op.UNION);
        } else {
            view.getLocationInWindow(mTmpPosition);
            mTmpBounds.set(mTmpPosition[0], mTmpPosition[1],
                    mTmpPosition[0] + view.getWidth(),
                    mTmpPosition[1] + view.getHeight());
        }
        mTmpRegion.op(mTmpBounds, Op.UNION);
    }
    }


    private void updateOrientationViews() {
    private void updateOrientationViews() {