summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sukesh Ram <sukeshram@google.com> 2024-05-06 17:31:50 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-05-06 17:31:50 +0000
commit08044638ec98a6d80fc0a4731e7a80d03a1a586c (patch)
treee2cb4cac37c9625e72b416c83930d58d3ce982de
parent8ea0b235fb04dc2bd22448a4d489b1a7dc906e88 (diff)
parent771bc51e99f5489a04bd579db977e582846aab10 (diff)
Merge "Replace Contextual Rotation Button with Floating Action Button" into 24D1-dev
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java30
-rw-r--r--packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/navigationbar/buttons/RotationContextButton.java79
4 files changed, 12 insertions, 121 deletions
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 400f6529eed6..49728e7976c0 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
@@ -77,6 +77,7 @@ import java.util.function.Supplier;
* 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 13ba9c360aa3..d711162f76ae 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.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_B
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;
@@ -120,7 +121,6 @@ import com.android.systemui.navigationbar.NavigationModeController.ModeChangedLi
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;
@@ -133,7 +133,6 @@ import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeViewController;
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;
@@ -627,8 +626,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
// 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,
@@ -764,10 +763,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
repositionNavigationBar(mCurrentRotation);
mView.setUpdateActiveTouchRegionsCallback(
() -> mOverviewProxyService.onActiveNavBarRegionChanges(
- getButtonLocations(
- true /* includeFloatingButtons */,
- true /* inScreen */,
- true /* useNearestRegion */)));
+ getButtonLocations(true /* inScreen */, true /* useNearestRegion */)));
mView.getViewTreeObserver().addOnComputeInternalInsetsListener(
mOnComputeInternalInsetsListener);
@@ -1096,16 +1092,14 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
.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;
@@ -1823,14 +1817,11 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
}
/**
- * @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;
@@ -1848,13 +1839,10 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
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 bc0a1da77b4e..c1e1e94d353c 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.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.recents.Recents;
import com.android.systemui.res.R;
@@ -150,7 +149,6 @@ public class NavigationBarView extends FrameLayout {
private Optional<Recents> mRecentsOptional = Optional.empty();
@Nullable
private ShadeViewController mPanelView;
- private RotationContextButton mRotationContextButton;
private FloatingRotationButton mFloatingRotationButton;
private RotationButtonController mRotationButtonController;
@@ -290,8 +288,6 @@ public class NavigationBarView extends FrameLayout {
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,
@@ -429,10 +425,6 @@ public class NavigationBarView extends FrameLayout {
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);
}
@@ -479,18 +471,8 @@ public class NavigationBarView extends FrameLayout {
* 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() {
@@ -1138,7 +1120,6 @@ public class NavigationBarView extends FrameLayout {
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 ac014b5b4a64..000000000000
--- 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();
- }
-}