Merge "Remove OverviewProxyService from NavBarView." into tm-dev

This commit is contained in:
Dave Mankoff
2022-04-07 23:35:23 +00:00
committed by Android (Google) Code Review
2 changed files with 43 additions and 22 deletions

View File

@@ -327,7 +327,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
private final OverviewProxyListener mOverviewProxyListener = new OverviewProxyListener() { private final OverviewProxyListener mOverviewProxyListener = new OverviewProxyListener() {
@Override @Override
public void onConnectionChanged(boolean isConnected) { public void onConnectionChanged(boolean isConnected) {
mView.updateStates(); mView.onOverviewProxyConnectionChange(
mOverviewProxyService.isEnabled(), mOverviewProxyService.shouldShowSwipeUpUI());
updateScreenPinningGestures(); updateScreenPinningGestures();
} }
@@ -557,11 +558,10 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
@Override @Override
public void onInit() { public void onInit() {
// TODO: A great deal of this code should probalby live in onViewAttached. // TODO: A great deal of this code should probably live in onViewAttached.
// It should also has corresponding cleanup in onViewDetached. // It should also has corresponding cleanup in onViewDetached.
mView.setTouchHandler(mTouchHandler); mView.setTouchHandler(mTouchHandler);
mView.setNavBarMode(mNavBarMode); mView.setNavBarMode(mNavBarMode);
mView.updateRotationButton(); mView.updateRotationButton();
mView.setVisibility( mView.setVisibility(
@@ -637,6 +637,12 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
mView.setWindowVisible(isNavBarWindowVisible()); mView.setWindowVisible(isNavBarWindowVisible());
mView.setBehavior(mBehavior); mView.setBehavior(mBehavior);
mView.setNavBarMode(mNavBarMode); mView.setNavBarMode(mNavBarMode);
mView.setUpdateActiveTouchRegionsCallback(
() -> mOverviewProxyService.onActiveNavBarRegionChanges(
mView.getButtonLocations(
true /* includeFloatingButtons */,
true /* inScreen */,
true /* useNearestRegion */)));
mNavBarHelper.registerNavTaskStateUpdater(mNavbarTaskbarStateUpdater); mNavBarHelper.registerNavTaskStateUpdater(mNavbarTaskbarStateUpdater);
@@ -697,6 +703,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
final RotationButtonController rotationButtonController = final RotationButtonController rotationButtonController =
mView.getRotationButtonController(); mView.getRotationButtonController();
rotationButtonController.setRotationCallback(null); rotationButtonController.setRotationCallback(null);
mView.setUpdateActiveTouchRegionsCallback(null);
mView.getBarTransitions().destroy(); mView.getBarTransitions().destroy();
mView.getLightTransitionsController().destroy(mContext); mView.getLightTransitionsController().destroy(mContext);
mOverviewProxyService.removeCallback(mOverviewProxyListener); mOverviewProxyService.removeCallback(mOverviewProxyListener);

View File

@@ -77,7 +77,6 @@ import com.android.systemui.navigationbar.buttons.KeyButtonDrawable;
import com.android.systemui.navigationbar.buttons.NearestTouchFrame; import com.android.systemui.navigationbar.buttons.NearestTouchFrame;
import com.android.systemui.navigationbar.buttons.RotationContextButton; import com.android.systemui.navigationbar.buttons.RotationContextButton;
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler; import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.Recents; import com.android.systemui.recents.Recents;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper; import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import com.android.systemui.shared.rotation.FloatingRotationButton; import com.android.systemui.shared.rotation.FloatingRotationButton;
@@ -142,7 +141,6 @@ public class NavigationBarView extends FrameLayout {
private final DeadZone mDeadZone; private final DeadZone mDeadZone;
private boolean mDeadZoneConsuming = false; private boolean mDeadZoneConsuming = false;
private final NavigationBarTransitions mBarTransitions; private final NavigationBarTransitions mBarTransitions;
private final OverviewProxyService mOverviewProxyService;
@Nullable @Nullable
private AutoHideController mAutoHideController; private AutoHideController mAutoHideController;
@@ -198,6 +196,9 @@ public class NavigationBarView extends FrameLayout {
*/ */
private final boolean mImeCanRenderGesturalNavButtons = canImeRenderGesturalNavButtons(); private final boolean mImeCanRenderGesturalNavButtons = canImeRenderGesturalNavButtons();
private Gefingerpoken mTouchHandler; private Gefingerpoken mTouchHandler;
private boolean mOverviewProxyEnabled;
private boolean mShowSwipeUpUi;
private UpdateActiveTouchRegionsCallback mUpdateActiveTouchRegionsCallback;
private class NavTransitionListener implements TransitionListener { private class NavTransitionListener implements TransitionListener {
private boolean mBackTransitioning; private boolean mBackTransitioning;
@@ -364,8 +365,6 @@ public class NavigationBarView extends FrameLayout {
R.drawable.ic_sysbar_rotate_button_cw_start_90, R.drawable.ic_sysbar_rotate_button_cw_start_90,
() -> getDisplay().getRotation()); () -> getDisplay().getRotation());
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
mConfiguration = new Configuration(); mConfiguration = new Configuration();
mTmpLastConfiguration = new Configuration(); mTmpLastConfiguration = new Configuration();
mConfiguration.updateFrom(context.getResources().getConfiguration()); mConfiguration.updateFrom(context.getResources().getConfiguration());
@@ -562,7 +561,7 @@ public class NavigationBarView extends FrameLayout {
} }
private boolean isQuickStepSwipeUpEnabled() { private boolean isQuickStepSwipeUpEnabled() {
return mOverviewProxyService.shouldShowSwipeUpUI() && isOverviewEnabled(); return mShowSwipeUpUi && isOverviewEnabled();
} }
private void reloadNavIcons() { private void reloadNavIcons() {
@@ -616,8 +615,7 @@ public class NavigationBarView extends FrameLayout {
} }
public KeyButtonDrawable getHomeDrawable() { public KeyButtonDrawable getHomeDrawable() {
final boolean quickStepEnabled = mOverviewProxyService.shouldShowSwipeUpUI(); KeyButtonDrawable drawable = mShowSwipeUpUi
KeyButtonDrawable drawable = quickStepEnabled
? getDrawable(R.drawable.ic_sysbar_home_quick_step) ? getDrawable(R.drawable.ic_sysbar_home_quick_step)
: getDrawable(R.drawable.ic_sysbar_home); : getDrawable(R.drawable.ic_sysbar_home);
orientHomeButton(drawable); orientHomeButton(drawable);
@@ -640,7 +638,7 @@ public class NavigationBarView extends FrameLayout {
// Animate the back button's rotation to the new degrees and only in portrait move up the // Animate the back button's rotation to the new degrees and only in portrait move up the
// back button to line up with the other buttons // back button to line up with the other buttons
float targetY = !mOverviewProxyService.shouldShowSwipeUpUI() && !mIsVertical && useAltBack float targetY = !mShowSwipeUpUi && !mIsVertical && useAltBack
? - getResources().getDimension(R.dimen.navbar_back_button_ime_offset) ? - getResources().getDimension(R.dimen.navbar_back_button_ime_offset)
: 0; : 0;
ObjectAnimator navBarAnimator = ObjectAnimator.ofPropertyValuesHolder(drawable, ObjectAnimator navBarAnimator = ObjectAnimator.ofPropertyValuesHolder(drawable,
@@ -657,8 +655,7 @@ public class NavigationBarView extends FrameLayout {
private @DrawableRes int chooseNavigationIconDrawableRes(@DrawableRes int icon, private @DrawableRes int chooseNavigationIconDrawableRes(@DrawableRes int icon,
@DrawableRes int quickStepIcon) { @DrawableRes int quickStepIcon) {
final boolean quickStepEnabled = mOverviewProxyService.shouldShowSwipeUpUI(); return mShowSwipeUpUi ? quickStepIcon : icon;
return quickStepEnabled ? quickStepIcon : icon;
} }
private KeyButtonDrawable getDrawable(@DrawableRes int icon) { private KeyButtonDrawable getDrawable(@DrawableRes int icon) {
@@ -770,7 +767,7 @@ public class NavigationBarView extends FrameLayout {
// recents buttons when disconnected from launcher service in screen pinning mode, // recents buttons when disconnected from launcher service in screen pinning mode,
// as they are used for exiting. // as they are used for exiting.
final boolean pinningActive = ActivityManagerWrapper.getInstance().isScreenPinningActive(); final boolean pinningActive = ActivityManagerWrapper.getInstance().isScreenPinningActive();
if (mOverviewProxyService.isEnabled()) { if (mOverviewProxyEnabled) {
// Force disable recents when not in legacy mode // Force disable recents when not in legacy mode
disableRecent |= !QuickStepContract.isLegacyMode(mNavBarMode); disableRecent |= !QuickStepContract.isLegacyMode(mNavBarMode);
if (pinningActive && !QuickStepContract.isGesturalMode(mNavBarMode)) { if (pinningActive && !QuickStepContract.isGesturalMode(mNavBarMode)) {
@@ -891,9 +888,14 @@ public class NavigationBarView extends FrameLayout {
} }
} }
public void updateStates() { void onOverviewProxyConnectionChange(boolean enabled, boolean showSwipeUpUi) {
final boolean showSwipeUpUI = mOverviewProxyService.shouldShowSwipeUpUI(); mOverviewProxyEnabled = enabled;
mShowSwipeUpUi = showSwipeUpUi;
updateStates();
}
/** */
public void updateStates() {
if (mNavigationInflaterView != null) { if (mNavigationInflaterView != null) {
// Reinflate the navbar if needed, no-op unless the swipe up state changes // Reinflate the navbar if needed, no-op unless the swipe up state changes
mNavigationInflaterView.onLikelyDefaultLayoutChange(); mNavigationInflaterView.onLikelyDefaultLayoutChange();
@@ -902,9 +904,10 @@ public class NavigationBarView extends FrameLayout {
updateSlippery(); updateSlippery();
reloadNavIcons(); reloadNavIcons();
updateNavButtonIcons(); updateNavButtonIcons();
WindowManagerWrapper.getInstance().setNavBarVirtualKeyHapticFeedbackEnabled(!showSwipeUpUI); WindowManagerWrapper.getInstance().setNavBarVirtualKeyHapticFeedbackEnabled(
!mShowSwipeUpUi);
getHomeButton().setAccessibilityDelegate( getHomeButton().setAccessibilityDelegate(
showSwipeUpUI ? mQuickStepAccessibilityDelegate : null); mShowSwipeUpUi ? mQuickStepAccessibilityDelegate : null);
} }
/** /**
@@ -1010,9 +1013,14 @@ public class NavigationBarView extends FrameLayout {
* Notifies the overview service of the active touch regions. * Notifies the overview service of the active touch regions.
*/ */
public void notifyActiveTouchRegions() { public void notifyActiveTouchRegions() {
mOverviewProxyService.onActiveNavBarRegionChanges( if (mUpdateActiveTouchRegionsCallback != null) {
getButtonLocations(true /* includeFloatingButtons */, true /* inScreen */, mUpdateActiveTouchRegionsCallback.update();
true /* useNearestRegion */)); }
}
void setUpdateActiveTouchRegionsCallback(UpdateActiveTouchRegionsCallback callback) {
mUpdateActiveTouchRegionsCallback = callback;
notifyActiveTouchRegions();
} }
private void updateButtonTouchRegionCache() { private void updateButtonTouchRegionCache() {
@@ -1030,8 +1038,10 @@ public class NavigationBarView extends FrameLayout {
* @param useNearestRegion Whether to use the nearest region instead of the actual button bounds * @param useNearestRegion Whether to use the nearest region instead of the actual button bounds
* @return * @return
*/ */
private Region getButtonLocations(boolean includeFloatingButtons, boolean inScreenSpace, Region getButtonLocations(boolean includeFloatingButtons, boolean inScreenSpace,
boolean useNearestRegion) { boolean useNearestRegion) {
// TODO: move this method to NavigationBar.
// TODO: don't use member variables for temp storage like mTmpRegion.
if (useNearestRegion && !inScreenSpace) { if (useNearestRegion && !inScreenSpace) {
// We currently don't support getting the nearest region in anything but screen space // We currently don't support getting the nearest region in anything but screen space
useNearestRegion = false; useNearestRegion = false;
@@ -1426,4 +1436,8 @@ public class NavigationBarView extends FrameLayout {
mRegionSamplingHelper.stop(); mRegionSamplingHelper.stop();
} }
} }
interface UpdateActiveTouchRegionsCallback {
void update();
}
} }