diff options
| author | 2021-03-02 11:36:13 -0800 | |
|---|---|---|
| committer | 2021-03-02 11:36:13 -0800 | |
| commit | f7c8568beaf5cb304997fa063db374c021135d73 (patch) | |
| tree | d0fb10ac2c1de61246b2462c782be1556c1a6b5f | |
| parent | af76755ff76e5e323ee31af593870dcde154b1d2 (diff) | |
Only use nearest touch frame for button nav
- When calculating the touchable region for the nav bar window
in gestural + IME, we can not use the cached screen space nearest
bounds in particular because the region needs to be in window
space, but also because the IME may want to handle the area
under the spacebar
Bug: 180881900
Test: Open IME, rotate a few times, and try to dismiss
Change-Id: Ib02daa22d327b51953d2107ae9fd498561ee0272
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java index 19e32783f765..35d5ca949f85 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java @@ -279,9 +279,11 @@ public class NavigationBarView extends FrameLayout implements return; } + // When in gestural and the IME is showing, don't use the nearest region since it will take + // gesture space away from the IME info.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION); info.touchableRegion.set(getButtonLocations(false /* includeFloatingRotationButton */, - false /* inScreen */)); + false /* inScreen */, false /* useNearestRegion */)); }; private final Consumer<Boolean> mRotationButtonListener = (visible) -> { @@ -981,7 +983,8 @@ public class NavigationBarView extends FrameLayout implements */ public void notifyActiveTouchRegions() { mOverviewProxyService.onActiveNavBarRegionChanges( - getButtonLocations(true /* includeFloatingRotationButton */, true /* inScreen */)); + getButtonLocations(true /* includeFloatingRotationButton */, true /* inScreen */, + true /* useNearestRegion */)); } private void updateButtonTouchRegionCache() { @@ -992,35 +995,49 @@ public class NavigationBarView extends FrameLayout implements .findViewById(R.id.nav_buttons)).getFullTouchableChildRegions(); } + /** + * @param includeFloatingRotationButton Whether to include the floating rotation button in the + * region for all the buttons + * @param inScreenSpace Whether to return values in screen space or window space + * @param useNearestRegion Whether to use the nearest region instead of the actual button bounds + * @return + */ private Region getButtonLocations(boolean includeFloatingRotationButton, - boolean inScreenSpace) { + boolean inScreenSpace, boolean useNearestRegion) { + if (useNearestRegion && !inScreenSpace) { + // We currently don't support getting the nearest region in anything but screen space + useNearestRegion = false; + } mTmpRegion.setEmpty(); updateButtonTouchRegionCache(); - updateButtonLocation(getBackButton(), inScreenSpace); - updateButtonLocation(getHomeButton(), inScreenSpace); - updateButtonLocation(getRecentsButton(), inScreenSpace); - updateButtonLocation(getImeSwitchButton(), inScreenSpace); - updateButtonLocation(getAccessibilityButton(), inScreenSpace); + updateButtonLocation(getBackButton(), inScreenSpace, useNearestRegion); + updateButtonLocation(getHomeButton(), inScreenSpace, useNearestRegion); + updateButtonLocation(getRecentsButton(), inScreenSpace, useNearestRegion); + updateButtonLocation(getImeSwitchButton(), inScreenSpace, useNearestRegion); + updateButtonLocation(getAccessibilityButton(), inScreenSpace, useNearestRegion); if (includeFloatingRotationButton && mFloatingRotationButton.isVisible()) { + // Note: this button is floating so the nearest region doesn't apply updateButtonLocation(mFloatingRotationButton.getCurrentView(), inScreenSpace); } else { - updateButtonLocation(getRotateSuggestionButton(), inScreenSpace); + updateButtonLocation(getRotateSuggestionButton(), inScreenSpace, useNearestRegion); } if (mNavBarOverlayController.isNavigationBarOverlayEnabled() && mNavBarOverlayController.isVisible()) { + // Note: this button is floating so the nearest region doesn't apply updateButtonLocation(mNavBarOverlayController.getCurrentView(), inScreenSpace); } return mTmpRegion; } - private void updateButtonLocation(ButtonDispatcher button, boolean inScreenSpace) { + private void updateButtonLocation(ButtonDispatcher button, boolean inScreenSpace, + boolean useNearestRegion) { View view = button.getCurrentView(); 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)) { + if (useNearestRegion && mButtonFullTouchableRegions.containsKey(view)) { mTmpRegion.op(mButtonFullTouchableRegions.get(view), Op.UNION); return; } |