diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml index cf63cc74521dd513707e673e9837ebefda98489e..d1efc825511b048430511adcb37d9bf886d50e58 100644 --- a/packages/SystemUI/res/values/ids.xml +++ b/packages/SystemUI/res/values/ids.xml @@ -88,8 +88,6 @@ <item type="id" name="requires_remeasuring"/> - <item type="id" name="secondary_home_handle" /> - <!-- Whether the icon is from a notification for which targetSdk < L --> <item type="id" name="icon_is_pre_L"/> diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index e522f8c4851b91e050695b96507b71ed6ca491bb..9c83d12fd543670bb0eaef6e650c9adc6c675043 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -29,7 +29,6 @@ import static android.inputmethodservice.InputMethodService.ENABLE_HIDE_IME_CAPT import static android.view.InsetsSource.FLAG_SUPPRESS_SCRIM; import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; @@ -127,7 +126,6 @@ import com.android.systemui.navigationbar.buttons.DragDropSurfaceCallback; 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; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.recents.Recents; @@ -268,37 +266,13 @@ public class NavigationBar extends ViewController<NavigationBarView> implements private boolean mIsOnDefaultDisplay; private boolean mHomeBlockedThisTouch; - /** - * When user is QuickSwitching between apps of different orientations, we'll draw a fake - * home handle on the orientation they originally touched down to start their swipe - * gesture to indicate to them that they can continue in that orientation without having to - * rotate the phone - * The secondary handle will show when we get - * {@link OverviewProxyListener#notifyPrioritizedRotation(int)} callback with the - * original handle hidden and we'll flip the visibilities once the - * {@link #mTasksFrozenListener} fires - */ - private QuickswitchOrientedNavHandle mOrientationHandle; - private WindowManager.LayoutParams mOrientationParams; - private int mStartingQuickSwitchRotation = -1; private int mCurrentRotation; - private ViewTreeObserver.OnGlobalLayoutListener mOrientationHandleGlobalLayoutListener; - private boolean mShowOrientedHandleForImmersiveMode; private final DeadZone mDeadZone; private boolean mImeVisible; private final Rect mSamplingBounds = new Rect(); private final Binder mInsetsSourceOwner = new Binder(); private boolean mForceDisableOverview = false; - /** - * When quickswitching between apps of different orientations, we draw a secondary home handle - * in the position of the first app's orientation. This rect represents the region of that - * home handle so we can apply the correct light/dark luma on that. - * @see {@link NavigationBar#mOrientationHandle} - */ - @android.annotation.Nullable - private Rect mOrientedHandleSamplingRegion; - @com.android.internal.annotations.VisibleForTesting public enum NavBarActionEvent implements UiEventLogger.UiEventEnum { @@ -386,11 +360,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements @Override public void onPrioritizedRotation(@Surface.Rotation int rotation) { - mStartingQuickSwitchRotation = rotation; - if (rotation == -1) { - mShowOrientedHandleForImmersiveMode = false; - } - orientSecondaryHomeHandle(); } @Override @@ -433,14 +402,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements } }; - private NavigationBarTransitions.DarkIntensityListener mOrientationHandleIntensityListener = - new NavigationBarTransitions.DarkIntensityListener() { - @Override - public void onDarkIntensity(float darkIntensity) { - mOrientationHandle.setDarkIntensity(darkIntensity); - } - }; - private final Runnable mAutoDim = () -> getBarTransitions().setAutoDim(true); private final Runnable mEnableLayoutTransitions = () -> mView.setLayoutTransitionsEnabled(true); private final Runnable mOnVariableDurationHomeLongClick = () -> { @@ -661,10 +622,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements @Override public Rect getSampledRegion(View sampledView) { - if (mOrientedHandleSamplingRegion != null) { - return mOrientedHandleSamplingRegion; - } - return calculateSamplingRect(); } @@ -826,8 +783,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements } setDisabled2Flags(mDisabledFlags2); - initSecondaryHomeHandleForRotation(); - // Unfortunately, we still need it because status bar needs LightBarController // before notifications creation. We cannot directly use getLightBarController() // from NavigationBarFragment directly. @@ -854,13 +809,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements mOverviewProxyService.removeCallback(mOverviewProxyListener); mUserTracker.removeCallback(mUserChangedCallback); mWakefulnessLifecycle.removeObserver(mWakefulnessObserver); - if (mOrientationHandle != null) { - resetSecondaryHandle(); - getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener); - mWindowManager.removeView(mOrientationHandle); - mOrientationHandle.getViewTreeObserver().removeOnGlobalLayoutListener( - mOrientationHandleGlobalLayoutListener); - } mView.getViewTreeObserver().removeOnComputeInternalInsetsListener( mOnComputeInternalInsetsListener); mHandler.removeCallbacks(mAutoDim); @@ -873,7 +821,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements viewRoot.removeSurfaceChangedCallback(mSurfaceChangedCallback); } mFrame = null; - mOrientationHandle = null; notifyNavigationBarSurface(); } @@ -911,106 +858,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements // propagate to EdgeBackGestureHandler (which is injected into this and NBV). As such, we // should also force-update the gesture handler to ensure it updates to the right bounds mEdgeBackGestureHandler.onConfigurationChanged(newConfig); - if (canShowSecondaryHandle()) { - if (rotation != mCurrentRotation) { - mCurrentRotation = rotation; - orientSecondaryHomeHandle(); - } - } - } - - private void initSecondaryHomeHandleForRotation() { - if (mNavBarMode != NAV_BAR_MODE_GESTURAL) { - return; - } - - mOrientationHandle = new QuickswitchOrientedNavHandle(mContext); - mOrientationHandle.setId(R.id.secondary_home_handle); - - getBarTransitions().addDarkIntensityListener(mOrientationHandleIntensityListener); - mOrientationParams = new WindowManager.LayoutParams(0, 0, - WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, - WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE - | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL - | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN - | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE - | WindowManager.LayoutParams.FLAG_SLIPPERY, - PixelFormat.TRANSLUCENT); - mOrientationParams.setTitle("SecondaryHomeHandle" + mContext.getDisplayId()); - mOrientationParams.privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION - | WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT; - mWindowManager.addView(mOrientationHandle, mOrientationParams); - mOrientationHandle.setVisibility(View.GONE); - mOrientationParams.setFitInsetsTypes(0 /* types*/); - mOrientationHandleGlobalLayoutListener = - () -> { - if (mStartingQuickSwitchRotation == -1) { - return; - } - - RectF boundsOnScreen = mOrientationHandle.computeHomeHandleBounds(); - mOrientationHandle.mapRectFromViewToScreenCoords(boundsOnScreen, true); - Rect boundsRounded = new Rect(); - boundsOnScreen.roundOut(boundsRounded); - setOrientedHandleSamplingRegion(boundsRounded); - }; - mOrientationHandle.getViewTreeObserver().addOnGlobalLayoutListener( - mOrientationHandleGlobalLayoutListener); - } - - private void orientSecondaryHomeHandle() { - if (!canShowSecondaryHandle()) { - if (mStartingQuickSwitchRotation == -1) { - resetSecondaryHandle(); - } - return; + if (rotation != mCurrentRotation) { + mCurrentRotation = rotation; } - - int deltaRotation = deltaRotation(mCurrentRotation, mStartingQuickSwitchRotation); - if (mStartingQuickSwitchRotation == -1 || deltaRotation == -1) { - // Curious if starting quickswitch can change between the if check and our delta - Log.d(TAG, "secondary nav delta rotation: " + deltaRotation - + " current: " + mCurrentRotation - + " starting: " + mStartingQuickSwitchRotation); - } - int height = 0; - int width = 0; - Rect dispSize = mWindowManager.getCurrentWindowMetrics().getBounds(); - mOrientationHandle.setDeltaRotation(deltaRotation); - switch (deltaRotation) { - case Surface.ROTATION_90, Surface.ROTATION_270: - height = dispSize.height(); - width = mView.getHeight(); - break; - case Surface.ROTATION_180, Surface.ROTATION_0: - // TODO(b/152683657): Need to determine best UX for this - if (!mShowOrientedHandleForImmersiveMode) { - resetSecondaryHandle(); - return; - } - width = dispSize.width(); - height = mView.getHeight(); - break; - } - - mOrientationParams.gravity = - deltaRotation == Surface.ROTATION_0 ? Gravity.BOTTOM : - (deltaRotation == Surface.ROTATION_90 ? Gravity.LEFT : Gravity.RIGHT); - mOrientationParams.height = height; - mOrientationParams.width = width; - mWindowManager.updateViewLayout(mOrientationHandle, mOrientationParams); - mView.setVisibility(View.GONE); - mOrientationHandle.setVisibility(View.VISIBLE); - } - - private void resetSecondaryHandle() { - if (mOrientationHandle != null) { - // Case where nav mode is changed w/o ever invoking a quickstep - // mOrientedHandle is initialized lazily - mOrientationHandle.setVisibility(View.GONE); - } - mView.setVisibility(View.VISIBLE); - setOrientedHandleSamplingRegion(null); } private void parseCurrentSysuiState() { @@ -1054,7 +904,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements public void dump(PrintWriter pw) { pw.println("NavigationBar (displayId=" + mDisplayId + "):"); - pw.println(" mStartingQuickSwitchRotation=" + mStartingQuickSwitchRotation); pw.println(" mCurrentRotation=" + mCurrentRotation); pw.println(" mHomeButtonLongPressDurationMs=" + mHomeButtonLongPressDurationMs); pw.println(" mLongPressHomeEnabled=" + mLongPressHomeEnabled); @@ -1068,7 +917,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements pw.println(" mScreenPinningActive=" + mScreenPinningActive); dumpBarTransitions(pw, "mNavigationBarView", getBarTransitions()); - pw.println(" mOrientedHandleSamplingRegion: " + mOrientedHandleSamplingRegion); mView.dump(pw); mRegionSamplingHelper.dump(pw); if (mAutoHideController != null) { @@ -1103,11 +951,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements && mNavigationBarWindowState != state) { mNavigationBarWindowState = state; updateSystemUiStateFlags(); - mShowOrientedHandleForImmersiveMode = state == WINDOW_STATE_HIDDEN; - if (mOrientationHandle != null - && mStartingQuickSwitchRotation != -1) { - orientSecondaryHomeHandle(); - } if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); setWindowVisible(isNavBarWindowVisible()); } @@ -1796,11 +1639,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements }; } - private boolean canShowSecondaryHandle() { - return mNavBarMode == NAV_BAR_MODE_GESTURAL && mOrientationHandle != null - && mStartingQuickSwitchRotation != -1; - } - private final UserTracker.Callback mUserChangedCallback = new UserTracker.Callback() { @Override @@ -1932,11 +1770,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements region.op(bounds, Region.Op.UNION); } - void setOrientedHandleSamplingRegion(Rect orientedHandleSamplingRegion) { - mOrientedHandleSamplingRegion = orientedHandleSamplingRegion; - mRegionSamplingHelper.updateSamplingRect(); - } - private Rect calculateSamplingRect() { mSamplingBounds.setEmpty(); // TODO: Extend this to 2/3 button layout as well @@ -2009,9 +1842,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements } updateScreenPinningGestures(); - if (!canShowSecondaryHandle()) { - resetSecondaryHandle(); - } setNavBarMode(mode); mView.setShouldShowSwipeUpUi(mOverviewProxyService.shouldShowSwipeUpUI()); } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationHandle.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationHandle.java index a6f9a3f8021aae6c4825ac63b4106dac3c762eed..80e59b12e0476557a039a9a9cb41152407cfdbae 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationHandle.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationHandle.java @@ -37,7 +37,7 @@ import com.android.systemui.res.R; public class NavigationHandle extends View implements ButtonInterface { - protected final Paint mPaint = new Paint(); + private final Paint mPaint = new Paint(); private @ColorInt final int mLightColor; private @ColorInt final int mDarkColor; protected final float mRadius; diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/QuickswitchOrientedNavHandle.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/QuickswitchOrientedNavHandle.java deleted file mode 100644 index b55de279dc281b84ffc06e092f435814320d8cc6..0000000000000000000000000000000000000000 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/QuickswitchOrientedNavHandle.java +++ /dev/null @@ -1,80 +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.gestural; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.RectF; -import android.view.Surface; - -import com.android.systemui.res.R; - -/** Temporarily shown view when using QuickSwitch to switch between apps of different rotations */ -public class QuickswitchOrientedNavHandle extends NavigationHandle { - private final int mWidth; - private final RectF mTmpBoundsRectF = new RectF(); - private @Surface.Rotation int mDeltaRotation; - - public QuickswitchOrientedNavHandle(Context context) { - super(context); - mWidth = context.getResources().getDimensionPixelSize(R.dimen.navigation_home_handle_width); - } - - public void setDeltaRotation(@Surface.Rotation int rotation) { - mDeltaRotation = rotation; - } - - @Override - protected void onDraw(Canvas canvas) { - canvas.drawRoundRect(computeHomeHandleBounds(), mRadius, mRadius, mPaint); - } - - public RectF computeHomeHandleBounds() { - float left; - float top; - float bottom; - float right; - float radiusOffset = mRadius * 2; - int topStart = getLocationOnScreen()[1]; - - switch (mDeltaRotation) { - default: - case Surface.ROTATION_0: - case Surface.ROTATION_180: - float height = mRadius * 2; - left = getWidth() / 2f - mWidth / 2f; - top = (getHeight() - mBottom - height); - right = getWidth() / 2f + mWidth / 2f; - bottom = top + height; - break; - case Surface.ROTATION_90: - left = mBottom; - right = left + radiusOffset; - top = getHeight() / 2f - (mWidth / 2f) - (topStart / 2f); - bottom = top + mWidth; - break; - case Surface.ROTATION_270: - right = getWidth() - mBottom; - left = right - radiusOffset; - top = getHeight() / 2f - (mWidth / 2f) - (topStart / 2f); - bottom = top + mWidth; - break; - } - mTmpBoundsRectF.set(left, top, right, bottom); - return mTmpBoundsRectF; - } -}