From b563271ff55c78cd68ab62799d95209e59a592e1 Mon Sep 17 00:00:00 2001 From: mpodolian Date: Wed, 13 Nov 2024 15:17:59 -0800 Subject: [PATCH] Fix hotseat layout on device rotation. When rotating the device, a few issues were causing improper hotseat layout: - BubbleBarController receives an initial configuration before the UI controller is set. - The updated device profile, including the correct `isQsbInline` value, arrives after all controllers are recreated, and the UI controller is not informed of the device profile update. Added logic to carry over the bubble bar bubble visibility state to the new UI controller. Included a call to notify the UI controller of the device profile update. Fixes: 378400160 Flag: com.android.wm.shell.enable_bubble_bar Test: Manual. Have a Tangor device in landscape orientation with the bubble bar. Rotate the device - observe hotseat and QSB are reduced in width. Dismiss the bubble bar - observe hotseat and QSB extends to the full width. video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/e8e1ZFRQlbHQtUlCXVJbFJ Change-Id: If180b01c8cdb329cd45d084af63a986c08cf65a1 --- .../taskbar/LauncherTaskbarUIController.java | 10 ++++++++++ .../launcher3/taskbar/TaskbarControllers.java | 5 ++++- src/com/android/launcher3/Hotseat.java | 14 ++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index b1cb2c6e67..7dc1669f61 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -33,6 +33,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Flags; +import com.android.launcher3.Hotseat; import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatedFloat; @@ -83,6 +84,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController { private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener = dp -> { onStashedInAppChanged(dp); + adjustHotseatForBubbleBar(); if (mControllers != null && mControllers.taskbarViewController != null) { mControllers.taskbarViewController.onRotationChanged(dp); } @@ -263,6 +265,14 @@ public class LauncherTaskbarUIController extends TaskbarUIController { } } + private void adjustHotseatForBubbleBar() { + Hotseat hotseat = mLauncher.getHotseat(); + if (mControllers.bubbleControllers.isEmpty() || hotseat == null) return; + boolean hiddenForBubbles = + mControllers.bubbleControllers.get().bubbleBarViewController.isHiddenForNoBubbles(); + hotseat.post(() -> adjustHotseatForBubbleBar(!hiddenForBubbles)); + } + /** * Create Taskbar animation when going from an app to Launcher as part of recents transition. * @param toState If known, the state we will end up in when reaching Launcher. diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java index 5a63ca69aa..db707247ad 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java @@ -221,10 +221,13 @@ public class TaskbarControllers { uiController = newUiController; uiController.init(this); uiController.updateStateForSysuiFlags(mSharedState.sysuiStateFlags); - // if bubble controllers are present take bubble bar location, else set it to null + // if bubble controllers are present configure the UI controller bubbleControllers.ifPresentOrElse(bubbleControllers -> { BubbleBarLocation location = bubbleControllers.bubbleBarViewController.getBubbleBarLocation(); + boolean hiddenForBubbles = + bubbleControllers.bubbleBarViewController.isHiddenForNoBubbles(); + uiController.adjustHotseatForBubbleBar(!hiddenForBubbles); uiController.onBubbleBarLocationUpdated(location); }, () -> uiController.onBubbleBarLocationUpdated(null)); // Notify that the ui controller has changed diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index 6468f749ac..b2ccba431c 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -187,22 +187,20 @@ public class Hotseat extends CellLayout implements Insettable { public void adjustForBubbleBar(boolean isBubbleBarVisible) { DeviceProfile dp = mActivity.getDeviceProfile(); float adjustedBorderSpace = dp.getHotseatAdjustedBorderSpaceForBubbleBar(getContext()); - boolean adjustmentRequired = Float.compare(adjustedBorderSpace, 0f) != 0; - + boolean shouldAdjustHotseat = isBubbleBarVisible + && Float.compare(adjustedBorderSpace, 0f) != 0; ShortcutAndWidgetContainer icons = getShortcutsAndWidgets(); // update the translation provider for future layout passes of hotseat icons. - if (adjustmentRequired && isBubbleBarVisible) { + if (shouldAdjustHotseat) { icons.setTranslationProvider( cellX -> dp.getHotseatAdjustedTranslation(getContext(), cellX)); } else { icons.setTranslationProvider(null); } - if (!adjustmentRequired) return; - AnimatorSet animatorSet = new AnimatorSet(); for (int i = 0; i < icons.getChildCount(); i++) { View child = icons.getChildAt(i); - float tx = isBubbleBarVisible ? dp.getHotseatAdjustedTranslation(getContext(), i) : 0; + float tx = shouldAdjustHotseat ? dp.getHotseatAdjustedTranslation(getContext(), i) : 0; if (child instanceof Reorderable) { MultiTranslateDelegate mtd = ((Reorderable) child).getTranslateDelegate(); animatorSet.play( @@ -213,8 +211,8 @@ public class Hotseat extends CellLayout implements Insettable { } if (mQsb instanceof HorizontalInsettableView horizontalInsettableQsb) { final float currentInsetFraction = horizontalInsettableQsb.getHorizontalInsets(); - final float targetInsetFraction = - isBubbleBarVisible ? (float) dp.iconSizePx / dp.hotseatQsbWidth : 0; + final float targetInsetFraction = shouldAdjustHotseat + ? (float) dp.iconSizePx / dp.hotseatQsbWidth : 0; ValueAnimator qsbAnimator = ValueAnimator.ofFloat(currentInsetFraction, targetInsetFraction); qsbAnimator.addUpdateListener(animation -> {