diff options
author | Ido Ben-Hur <idoybh2@gmail.com> | 2021-11-16 15:36:31 +0200 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2022-01-27 18:50:18 +0800 |
commit | 9c217703880db0a083bf203f2a7b65a08abd3105 (patch) | |
tree | f6b93cc830d670ea4a3b37ba52c6459be8ccc7c0 | |
parent | d5f342cc6b415803cd3e72a8605c19624ddca17c (diff) |
SystemUI: Kill fake navbar once again
* Will google ever learn from their mistakes?
Change-Id: I39e0dd89b53244e1458c87648af50439348fa150
2 files changed, 1 insertions, 242 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index 8e6eb02bb6f6..aa07cefa8ad8 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -124,7 +124,6 @@ import com.android.systemui.model.SysUiState; import com.android.systemui.navigationbar.buttons.ButtonDispatcher; import com.android.systemui.navigationbar.buttons.KeyButtonView; import com.android.systemui.navigationbar.buttons.RotationContextButton; -import com.android.systemui.navigationbar.gestural.QuickswitchOrientedNavHandle; import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.recents.OverviewProxyService; @@ -244,23 +243,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, private boolean mIsOnDefaultDisplay; public 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; - @com.android.internal.annotations.VisibleForTesting public enum NavBarActionEvent implements UiEventLogger.UiEventEnum { @@ -324,11 +306,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, @Override public void onPrioritizedRotation(@Surface.Rotation int rotation) { - mStartingQuickSwitchRotation = rotation; - if (rotation == -1) { - mShowOrientedHandleForImmersiveMode = false; - } - orientSecondaryHomeHandle(); + // nothing } @Override @@ -387,14 +365,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } }; - 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 = () -> mNavigationBarView.setLayoutTransitionsEnabled(true); @@ -670,8 +640,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } setDisabled2Flags(mDisabledFlags2); - initSecondaryHomeHandleForRotation(); - // Unfortunately, we still need it because status bar needs LightBarController // before notifications creation. We cannot directly use getLightBarController() // from NavigationBarFragment directly. @@ -704,18 +672,10 @@ public class NavigationBar implements View.OnAttachStateChangeListener, mNavigationBarView.getLightTransitionsController().destroy(mContext); mOverviewProxyService.removeCallback(mOverviewProxyListener); mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver); - if (mOrientationHandle != null) { - resetSecondaryHandle(); - getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener); - mWindowManager.removeView(mOrientationHandle); - mOrientationHandle.getViewTreeObserver().removeOnGlobalLayoutListener( - mOrientationHandleGlobalLayoutListener); - } mHandler.removeCallbacks(mAutoDim); mHandler.removeCallbacks(mOnVariableDurationHomeLongClick); mHandler.removeCallbacks(mEnableLayoutTransitions); mNavigationBarView = null; - mOrientationHandle = null; } // TODO: Remove this when we update nav bar recreation @@ -746,112 +706,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } repositionNavigationBar(); - if (canShowSecondaryHandle()) { - int rotation = newConfig.windowConfiguration.getRotation(); - 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; - 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); - mNavigationBarView.setOrientedHandleSamplingRegion(boundsRounded); - }; - mOrientationHandle.getViewTreeObserver().addOnGlobalLayoutListener( - mOrientationHandleGlobalLayoutListener); - } - - private void orientSecondaryHomeHandle() { - if (!canShowSecondaryHandle()) { - return; - } - - if (mStartingQuickSwitchRotation == -1 || mSplitScreenOptional - .map(LegacySplitScreen::isDividerVisible).orElse(false)) { - // Hide the secondary home handle if we are in multiwindow since apps in multiwindow - // aren't allowed to set the display orientation - resetSecondaryHandle(); - } else { - 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: - case Surface.ROTATION_270: - height = dispSize.height(); - width = mNavigationBarView.getHeight(); - break; - case Surface.ROTATION_180: - case Surface.ROTATION_0: - // TODO(b/152683657): Need to determine best UX for this - if (!mShowOrientedHandleForImmersiveMode) { - resetSecondaryHandle(); - return; - } - width = dispSize.width(); - height = mNavigationBarView.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); - mNavigationBarView.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); - } - mNavigationBarView.setVisibility(View.VISIBLE); - mNavigationBarView.setOrientedHandleSamplingRegion(null); } private void reconfigureHomeLongClick() { @@ -877,8 +731,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, 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); pw.println(" mAssistantTouchGestureEnabled=" + mAssistantTouchGestureEnabled); @@ -935,11 +787,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, && mNavigationBarWindowState != state) { mNavigationBarWindowState = state; updateSystemUiStateFlags(-1); - mShowOrientedHandleForImmersiveMode = state == WINDOW_STATE_HIDDEN; - if (mOrientationHandle != null - && mStartingQuickSwitchRotation != -1) { - orientSecondaryHomeHandle(); - } if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); mNavigationBarView.setWindowVisible(isNavBarWindowVisible()); } @@ -1580,10 +1427,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } updateScreenPinningGestures(); setAccessibilityFloatingMenuModeIfNeeded(); - - if (!canShowSecondaryHandle()) { - resetSecondaryHandle(); - } } @Override @@ -1618,10 +1461,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener, private final AccessibilityServicesStateChangeListener mAccessibilityListener = this::updateAccessibilityServicesState; - private boolean canShowSecondaryHandle() { - return mNavBarMode == NAV_BAR_MODE_GESTURAL && mOrientationHandle != null; - } - private final Consumer<Integer> mRotationWatcher = rotation -> { if (mNavigationBarView.needsReorient(rotation)) { repositionNavigationBar(); 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 71c8a2c1e6ca..000000000000 --- 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.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() { - int left; - int top; - int bottom; - int right; - int radiusOffset = mRadius * 2; - int topStart = getLocationOnScreen()[1]; - - switch (mDeltaRotation) { - default: - case Surface.ROTATION_0: - case Surface.ROTATION_180: - int height = mRadius * 2; - left = getWidth() / 2 - mWidth / 2; - top = (getHeight() - mBottom - height); - right = getWidth() / 2 + mWidth / 2; - bottom = top + height; - break; - case Surface.ROTATION_90: - left = mBottom; - right = left + radiusOffset; - top = getHeight() / 2 - (mWidth / 2) - (topStart / 2); - bottom = top + mWidth; - break; - case Surface.ROTATION_270: - right = getWidth() - mBottom; - left = right - radiusOffset; - top = getHeight() / 2 - (mWidth / 2) - (topStart / 2); - bottom = top + mWidth; - break; - } - mTmpBoundsRectF.set(left, top, right, bottom); - return mTmpBoundsRectF; - } -} |