Merge "Replace Contextual Rotation Button with Floating Action Button" into main
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java
index 87b473f..6e1b670 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java
@@ -74,6 +74,7 @@
* Contains logic that deals with showing a rotate suggestion button with animation.
*/
public class RotationButtonController {
+ public static final boolean DEBUG_ROTATION = false;
private static final String TAG = "RotationButtonController";
private static final int BUTTON_FADE_IN_OUT_DURATION_MS = 100;
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
index 1a2ae8a..906ebad 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
@@ -39,6 +39,7 @@
import static com.android.systemui.navigationbar.NavBarHelper.transitionMode;
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen;
+import static com.android.systemui.shared.rotation.RotationButtonController.DEBUG_ROTATION;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY;
@@ -121,7 +122,6 @@
import com.android.systemui.navigationbar.buttons.ButtonDispatcher;
import com.android.systemui.navigationbar.buttons.DeadZone;
import com.android.systemui.navigationbar.buttons.KeyButtonView;
-import com.android.systemui.navigationbar.buttons.RotationContextButton;
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
import com.android.systemui.navigationbar.gestural.QuickswitchOrientedNavHandle;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -135,7 +135,6 @@
import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import com.android.systemui.shared.recents.utilities.Utilities;
-import com.android.systemui.shared.rotation.RotationButton;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.SysUiStatsLog;
@@ -658,8 +657,8 @@
// 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 /* includeFloatingButtons */,
- false /* inScreen */, false /* useNearestRegion */));
+ info.touchableRegion.set(
+ getButtonLocations(false /* inScreen */, false /* useNearestRegion */));
};
mRegionSamplingHelper = new RegionSamplingHelper(mView,
@@ -795,10 +794,7 @@
repositionNavigationBar(mCurrentRotation);
mView.setUpdateActiveTouchRegionsCallback(
() -> mOverviewProxyService.onActiveNavBarRegionChanges(
- getButtonLocations(
- true /* includeFloatingButtons */,
- true /* inScreen */,
- true /* useNearestRegion */)));
+ getButtonLocations(true /* inScreen */, true /* useNearestRegion */)));
mView.getViewTreeObserver().addOnComputeInternalInsetsListener(
mOnComputeInternalInsetsListener);
@@ -1135,16 +1131,14 @@
.hasDisable2RotateSuggestionFlag(mDisabledFlags2);
final RotationButtonController rotationButtonController =
mView.getRotationButtonController();
- final RotationButton rotationButton = rotationButtonController.getRotationButton();
-
- if (RotationContextButton.DEBUG_ROTATION) {
+ if (DEBUG_ROTATION) {
Log.v(TAG, "onRotationProposal proposedRotation=" + Surface.rotationToString(rotation)
+ ", isValid=" + isValid + ", mNavBarWindowState="
+ StatusBarManager.windowStateToString(mNavigationBarWindowState)
+ ", rotateSuggestionsDisabled=" + rotateSuggestionsDisabled
- + ", isRotateButtonVisible=" + rotationButton.isVisible());
+ + ", isRotateButtonVisible="
+ + rotationButtonController.getRotationButton().isVisible());
}
-
// Respect the disabled flag, no need for action as flag change callback will handle hiding
if (rotateSuggestionsDisabled) return;
@@ -1903,14 +1897,11 @@
}
/**
- * @param includeFloatingButtons Whether to include the floating rotation and overlay 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
*/
- Region getButtonLocations(boolean includeFloatingButtons, boolean inScreenSpace,
- boolean useNearestRegion) {
+ Region getButtonLocations(boolean inScreenSpace, boolean useNearestRegion) {
if (useNearestRegion && !inScreenSpace) {
// We currently don't support getting the nearest region in anything but screen space
useNearestRegion = false;
@@ -1928,13 +1919,10 @@
updateButtonLocation(
region, touchRegionCache, mView.getAccessibilityButton(), inScreenSpace,
useNearestRegion);
- if (includeFloatingButtons && mView.getFloatingRotationButton().isVisible()) {
+ if (mView.getFloatingRotationButton().isVisible()) {
// Note: this button is floating so the nearest region doesn't apply
updateButtonLocation(
region, mView.getFloatingRotationButton().getCurrentView(), inScreenSpace);
- } else {
- updateButtonLocation(region, touchRegionCache, mView.getRotateSuggestionButton(),
- inScreenSpace, useNearestRegion);
}
return region;
}
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
index 3c69ed9..a73275c 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
@@ -69,7 +69,6 @@
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.recents.Recents;
import com.android.systemui.res.R;
@@ -153,7 +152,6 @@
private ShadeViewController mShadeViewController;
@Nullable
private PanelExpansionInteractor mPanelExpansionInteractor;
- private RotationContextButton mRotationContextButton;
private FloatingRotationButton mFloatingRotationButton;
private RotationButtonController mRotationButtonController;
@@ -293,8 +291,6 @@
R.drawable.ic_sysbar_accessibility_button);
mContextualButtonGroup.addButton(imeSwitcherButton);
mContextualButtonGroup.addButton(accessibilityButton);
- mRotationContextButton = new RotationContextButton(R.id.rotate_suggestion,
- mLightContext, R.drawable.ic_sysbar_rotate_button_ccw_start_0);
mFloatingRotationButton = new FloatingRotationButton(mContext,
R.string.accessibility_rotate_button,
R.layout.rotate_suggestion,
@@ -433,10 +429,6 @@
return mButtonDispatchers.get(R.id.accessibility_button);
}
- public RotationContextButton getRotateSuggestionButton() {
- return (RotationContextButton) mButtonDispatchers.get(R.id.rotate_suggestion);
- }
-
public ButtonDispatcher getHomeHandle() {
return mButtonDispatchers.get(R.id.home_handle);
}
@@ -483,18 +475,8 @@
* Updates the rotation button based on the current navigation mode.
*/
void updateRotationButton() {
- if (isGesturalMode(mNavBarMode)) {
- mContextualButtonGroup.removeButton(R.id.rotate_suggestion);
- mButtonDispatchers.remove(R.id.rotate_suggestion);
- mRotationButtonController.setRotationButton(mFloatingRotationButton,
- mRotationButtonListener);
- } else if (mContextualButtonGroup.getContextButton(R.id.rotate_suggestion) == null) {
- mContextualButtonGroup.addButton(mRotationContextButton);
- mButtonDispatchers.put(R.id.rotate_suggestion, mRotationContextButton);
- mRotationButtonController.setRotationButton(mRotationContextButton,
- mRotationButtonListener);
- }
- mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers);
+ mRotationButtonController.setRotationButton(mFloatingRotationButton,
+ mRotationButtonListener);
}
public KeyButtonDrawable getBackDrawable() {
@@ -1143,7 +1125,6 @@
dumpButton(pw, "home", getHomeButton());
dumpButton(pw, "handle", getHomeHandle());
dumpButton(pw, "rcnt", getRecentsButton());
- dumpButton(pw, "rota", getRotateSuggestionButton());
dumpButton(pw, "a11y", getAccessibilityButton());
dumpButton(pw, "ime", getImeSwitchButton());
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/RotationContextButton.java b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/RotationContextButton.java
deleted file mode 100644
index ac014b5..0000000
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/RotationContextButton.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.navigationbar.buttons;
-
-import android.annotation.DrawableRes;
-import android.annotation.IdRes;
-import android.content.Context;
-import android.view.View;
-
-import com.android.systemui.shared.rotation.RotationButton;
-import com.android.systemui.shared.rotation.RotationButtonController;
-
-/** Containing logic for the rotation button in nav bar. */
-public class RotationContextButton extends ContextualButton implements RotationButton {
- public static final boolean DEBUG_ROTATION = false;
-
- private RotationButtonController mRotationButtonController;
-
- /**
- * @param lightContext the context to use to load the icon resource
- */
- public RotationContextButton(@IdRes int buttonResId, Context lightContext,
- @DrawableRes int iconResId) {
- super(buttonResId, lightContext, iconResId);
- }
-
- @Override
- public void setRotationButtonController(RotationButtonController rotationButtonController) {
- mRotationButtonController = rotationButtonController;
- }
-
- @Override
- public void setUpdatesCallback(RotationButtonUpdatesCallback updatesCallback) {
- setListener((button, visible) -> {
- if (updatesCallback != null) {
- updatesCallback.onVisibilityChanged(visible);
- }
- });
- }
-
- @Override
- public void setVisibility(int visibility) {
- super.setVisibility(visibility);
-
- // Start the rotation animation once it becomes visible
- final KeyButtonDrawable currentDrawable = getImageDrawable();
- if (visibility == View.VISIBLE && currentDrawable != null) {
- currentDrawable.resetAnimation();
- currentDrawable.startAnimation();
- }
- }
-
- @Override
- protected KeyButtonDrawable getNewDrawable(int lightIconColor, int darkIconColor) {
- return KeyButtonDrawable.create(mRotationButtonController.getContext(),
- lightIconColor, darkIconColor, mRotationButtonController.getIconResId(),
- false /* shadow */, null /* ovalBackgroundColor */);
- }
-
- @Override
- public boolean acceptRotationProposal() {
- View currentView = getCurrentView();
- return currentView != null && currentView.isAttachedToWindow();
- }
-}