From 226ed8143d21761418b69f50431c6e5e6c4ecb1f Mon Sep 17 00:00:00 2001 From: mpodolian Date: Mon, 2 Dec 2024 16:53:29 -0800 Subject: [PATCH] Shift transient taskbar to ensure 12dp distance with the bubble bar. Shift the taskbar to fulfill the 12dp distance if the distance between the taskbar and the bubble bar is below this threshold. Fixes: 376929094 Test: TaskbarViewControllerTest Test: Manual. Test that the transient taskbar shifts properly. Increased the minimum distance to 120 dp and verified that the taskbar shifts correctly. Moved bubbles side to side, confirming the taskbar follows. The return-to-home-screen animation to the hotseat plays as expected from either side. Video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/bJZ8PclmltZu7IupvBFrLn Test: Manual. Test that the transient taskbar stashes properly. Increased the minimum distance to 120 dp and verified that the taskbar shifts correctly. Go to any application. Stash and un-stash the taskbar. Video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/hCGRhUgIqvcehOrTQ2Ulvj Test: Manual. Test that the transient taskbar pin/unpin properly. Increased the minimum distance to 120 dp and verified that the taskbar shifts correctly. Pin/unpin the taskbar. Video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/f3fy5JKVZAk4wLCpVra4DK Flag: com.android.wm.shell.enable_bubble_bar Change-Id: Id4bd713da93053f90d9c2be8503dc93531a03b29 --- quickstep/res/values/dimens.xml | 1 + .../taskbar/TaskbarActivityContext.java | 8 +- .../taskbar/TaskbarBackgroundRenderer.kt | 9 +- .../launcher3/taskbar/TaskbarDragLayer.java | 5 + .../taskbar/TaskbarDragLayerController.java | 7 + .../taskbar/TaskbarViewController.java | 148 +++++++++++++----- .../taskbar/bubbles/BubbleBarView.java | 8 + .../bubbles/BubbleBarViewController.java | 51 +++++- .../util/MultiTranslateDelegate.java | 3 +- 9 files changed, 193 insertions(+), 47 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index b221b22e80..2442b7578a 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -465,6 +465,7 @@ @dimen/bubblebar_icon_spacing 12dp 1dp + 12dp 96dp diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 107facf023..51d69412e7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -268,8 +268,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { mWindowManager = c.getSystemService(WindowManager.class); // Inflate views. - final boolean isTransientTaskbar = DisplayController.isTransientTaskbar(this) - && !isPhoneMode(); + boolean isTransientTaskbar = isTransientTaskbar(); int taskbarLayout = isTransientTaskbar ? R.layout.transient_taskbar : R.layout.taskbar; mDragLayer = (TaskbarDragLayer) mLayoutInflater.inflate(taskbarLayout, null, false); TaskbarView taskbarView = mDragLayer.findViewById(R.id.taskbar_view); @@ -382,6 +381,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext { dispatchDeviceProfileChanged(); } + /** Returns whether current taskbar is transient. */ + public boolean isTransientTaskbar() { + return DisplayController.isTransientTaskbar(this) && !isPhoneMode(); + } + /** * Copy the original DeviceProfile, match the number of hotseat icons and qsb width and update * the icon size diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt index ea6d82b7e2..e44bce1a07 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt @@ -57,6 +57,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { var backgroundHeight = context.deviceProfile.taskbarHeight.toFloat() var translationYForSwipe = 0f var translationYForStash = 0f + var translationXForBubbleBar = 0f private val transientBackgroundBounds = context.transientTaskbarBounds @@ -244,12 +245,12 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { setColorAlphaBound(Color.BLACK, Math.round(newShadowAlpha)), ) strokePaint.alpha = (paint.alpha * strokeAlpha) / 255 - + val currentTranslationX = translationXForBubbleBar * progress lastDrawnTransientRect.set( - transientBackgroundBounds.left + halfWidthDelta, + transientBackgroundBounds.left + halfWidthDelta + currentTranslationX, bottom - newBackgroundHeight, - transientBackgroundBounds.right - halfWidthDelta, - bottom + transientBackgroundBounds.right - halfWidthDelta + currentTranslationX, + bottom, ) val horizontalInset = fullWidth * widthInsetPercentage lastDrawnTransientRect.inset(horizontalInset, 0f) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java index 8b521128a7..59ef57773c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java @@ -254,6 +254,11 @@ public class TaskbarDragLayer extends BaseDragLayer { invalidate(); } + protected void setBackgroundTranslationXForBubbleBar(float translationX) { + mBackgroundRenderer.setTranslationXForBubbleBar(translationX); + invalidate(); + } + /** Returns the bounds in DragLayer coordinates of where the transient background was drawn. */ protected RectF getLastDrawnTransientRect() { return mBackgroundRenderer.getLastDrawnTransientRect(); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java index 925e10bdce..68c252a592 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java @@ -197,6 +197,13 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa mTaskbarDragLayer.setBackgroundTranslationYForSwipe(transY); } + /** + * Sets the translation of the background for the bubble bar. + */ + public void setTranslationXForBubbleBar(float transX) { + mTaskbarDragLayer.setBackgroundTranslationXForBubbleBar(transX); + } + /** * Sets the translation of the background during the spring on stash animation. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 438478f275..56a6277726 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -40,6 +40,7 @@ import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_TRA import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_IN_ANIM_ALPHA_DURATION_MS; import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_OUT_ANIM_POSITION_DURATION_MS; import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE; +import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_BUBBLE_BAR_ANIM; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_NAV_BAR_ANIM; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_ALIGNMENT_ANIM; import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_PINNING_ANIM; @@ -81,6 +82,7 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.TaskItemInfo; import com.android.launcher3.taskbar.bubbles.BubbleBarController; +import com.android.launcher3.taskbar.bubbles.BubbleControllers; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.LauncherBindableItemsContainer; @@ -108,6 +110,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar private static final Runnable NO_OP = () -> { }; + public static long TRANSLATION_X_FOR_BUBBLEBAR_ANIM_DURATION_MS = 250; + public static final int ALPHA_INDEX_HOME = 0; public static final int ALPHA_INDEX_KEYGUARD = 1; public static final int ALPHA_INDEX_STASH = 2; @@ -133,6 +137,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar private static boolean sEnableModelLoadingForTests = true; private final TaskbarActivityContext mActivity; + private @Nullable TaskbarDragLayerController mDragLayerController; private final TaskbarView mTaskbarView; private final MultiValueAlpha mTaskbarIconAlpha; private final AnimatedFloat mTaskbarIconScaleForStash = new AnimatedFloat(this::updateScale); @@ -145,15 +150,22 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar this::updateTaskbarIconsScale); private final AnimatedFloat mTaskbarIconTranslationXForPinning = new AnimatedFloat( - this::updateTaskbarIconTranslationXForPinning); + () -> updateTaskbarIconTranslationXForPinning()); private final AnimatedFloat mIconsTranslationXForNavbar = new AnimatedFloat( this::updateTranslationXForNavBar); + private final AnimatedFloat mTranslationXForBubbleBar = new AnimatedFloat( + this::updateTranslationXForBubbleBar); + @Nullable private Animator mTaskbarShiftXAnim; @Nullable private BubbleBarLocation mCurrentBubbleBarLocation; + @Nullable + private BubbleControllers mBubbleControllers = null; + @Nullable + private ObjectAnimator mTranslationXAnimation; private final AnimatedFloat mTaskbarIconTranslationYForPinning = new AnimatedFloat( this::updateTranslationY); @@ -175,11 +187,12 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar private final View.OnLayoutChangeListener mTaskbarViewLayoutChangeListener = (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { if (!taskbarRecentsLayoutTransition()) { - updateTaskbarIconTranslationXForPinning(); - } - if (BubbleBarController.isBubbleBarEnabled()) { - mControllers.navbarButtonsViewController.onLayoutsUpdated(); + // update shiftX is handled with the animation at the end of the method + updateTaskbarIconTranslationXForPinning(/* updateShiftXForBubbleBar = */ false); } + if (mBubbleControllers == null) return; + mControllers.navbarButtonsViewController.onLayoutsUpdated(); + adjustTaskbarXForBubbleBar(); }; // Animation to align icons with Launcher, created lazily. This allows the controller to be @@ -223,11 +236,11 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mIsRtl = Utilities.isRtl(mTaskbarView.getResources()); mTaskbarLeftRightMargin = mActivity.getResources().getDimensionPixelSize( R.dimen.transient_taskbar_padding); - } public void init(TaskbarControllers controllers) { mControllers = controllers; + controllers.bubbleControllers.ifPresent(bc -> mBubbleControllers = bc); mTaskbarView.init(TaskbarViewCallbacksFactory.newInstance(mActivity).create( mActivity, mControllers, mTaskbarView)); mTaskbarView.getLayoutParams().height = mActivity.isPhoneMode() @@ -252,7 +265,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar controllers.navbarButtonsViewController.getTaskbarNavButtonTranslationY(); mTaskbarNavButtonTranslationYForInAppDisplay = controllers.navbarButtonsViewController .getTaskbarNavButtonTranslationYForInAppDisplay(); - + mDragLayerController = controllers.taskbarDragLayerController; mActivity.addOnDeviceProfileChangeListener(mDeviceProfileChangeListener); if (ENABLE_TASKBAR_NAVBAR_UNIFICATION) { @@ -270,24 +283,59 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar @Override public void onBubbleBarLocationUpdated(BubbleBarLocation location) { updateCurrentBubbleBarLocation(location); - if (!shouldMoveTaskbarOnBubbleBarLocationUpdate()) return; - cancelTaskbarShiftAnimation(); - // reset translation x, taskbar will position icons with the updated location - mIconsTranslationXForNavbar.updateValue(0); - mTaskbarView.onBubbleBarLocationUpdated(location); + if (mActivity.isTransientTaskbar()) { + translateTaskbarXForBubbleBar(/* animate= */ false); + } else if (mActivity.shouldStartAlignTaskbar()) { + cancelTaskbarShiftAnimation(); + // reset translation x, taskbar will position icons with the updated location + mIconsTranslationXForNavbar.updateValue(0); + mTaskbarView.onBubbleBarLocationUpdated(location); + } } /** Animates start aligned taskbar accordingly to the bubble bar position. */ @Override public void onBubbleBarLocationAnimated(BubbleBarLocation location) { - if (!updateCurrentBubbleBarLocation(location) - || !shouldMoveTaskbarOnBubbleBarLocationUpdate()) { - return; + boolean locationUpdated = updateCurrentBubbleBarLocation(location); + if (mActivity.isTransientTaskbar()) { + translateTaskbarXForBubbleBar(/* animate= */ true); + } else if (locationUpdated && mActivity.shouldStartAlignTaskbar()) { + cancelTaskbarShiftAnimation(); + float translationX = mTaskbarView.getTranslationXForBubbleBarPosition(location); + mTaskbarShiftXAnim = createTaskbarIconsShiftAnimator(translationX); + mTaskbarShiftXAnim.start(); } - cancelTaskbarShiftAnimation(); - float translationX = mTaskbarView.getTranslationXForBubbleBarPosition(location); - mTaskbarShiftXAnim = createTaskbarIconsShiftAnimator(translationX); - mTaskbarShiftXAnim.start(); + } + + private void translateTaskbarXForBubbleBar(boolean animate) { + cancelCurrentTranslationXAnimation(); + if (!mActivity.isTransientTaskbar()) return; + int shiftX = getTransientTaskbarShiftXForBubbleBar(); + if (animate) { + mTranslationXAnimation = mTranslationXForBubbleBar.animateToValue(shiftX); + mTranslationXAnimation.setInterpolator(EMPHASIZED); + mTranslationXAnimation.setDuration(TRANSLATION_X_FOR_BUBBLEBAR_ANIM_DURATION_MS); + mTranslationXAnimation.start(); + } else { + mTranslationXForBubbleBar.updateValue(shiftX); + } + } + + private void cancelCurrentTranslationXAnimation() { + if (mTranslationXAnimation != null) { + if (mTranslationXAnimation.isRunning()) { + mTranslationXAnimation.cancel(); + } + mTranslationXAnimation = null; + } + } + + private int getTransientTaskbarShiftXForBubbleBar() { + if (mBubbleControllers == null || !mActivity.isTransientTaskbar()) { + return 0; + } + return mBubbleControllers.bubbleBarViewController + .getTransientTaskbarTranslationXForBubbleBar(mCurrentBubbleBarLocation); } /** Updates the mCurrentBubbleBarLocation, returns {@code} true if location is updated. */ @@ -300,13 +348,6 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar } } - /** Returns whether taskbar should be moved on the bubble bar location update. */ - private boolean shouldMoveTaskbarOnBubbleBarLocationUpdate() { - return mControllers.bubbleControllers.isPresent() - && mActivity.shouldStartAlignTaskbar() - && mActivity.isThreeButtonNav(); - } - private void cancelTaskbarShiftAnimation() { if (mTaskbarShiftXAnim != null) { mTaskbarShiftXAnim.cancel(); @@ -450,16 +491,26 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar } void updateTaskbarIconTranslationXForPinning() { + updateTaskbarIconTranslationXForPinning(/* updateShiftXForBubbleBar = */ true); + } + + void updateTaskbarIconTranslationXForPinning(boolean updateShiftXForBubbleBar) { View[] iconViews = mTaskbarView.getIconViews(); float scale = mTaskbarIconTranslationXForPinning.value; float transientTaskbarAllAppsOffset = mActivity.getResources().getDimension( mTaskbarView.getAllAppsButtonContainer().getAllAppsButtonTranslationXOffset(true)); float persistentTaskbarAllAppsOffset = mActivity.getResources().getDimension( mTaskbarView.getAllAppsButtonContainer().getAllAppsButtonTranslationXOffset(false)); - + if (mBubbleControllers != null && updateShiftXForBubbleBar) { + cancelCurrentTranslationXAnimation(); + int translationXForTransientTaskbar = mBubbleControllers.bubbleBarViewController + .getTransientTaskbarTranslationXForBubbleBar(mCurrentBubbleBarLocation); + float currentTranslationXForTransientTaskbar = mapRange(scale, + translationXForTransientTaskbar, 0); + mTranslationXForBubbleBar.updateValue(currentTranslationXForTransientTaskbar); + } float allAppIconTranslateRange = mapRange(scale, transientTaskbarAllAppsOffset, persistentTaskbarAllAppsOffset); - // Task icons are laid out so the taskbar content is centered. The taskbar width (used for // centering taskbar icons) depends on the all apps button X translation, and is different // for persistent and transient taskbar. If the offset used for current taskbar layout is @@ -551,13 +602,23 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar } private void updateTranslationXForNavBar() { + updateIconViewsTranslationX(INDEX_NAV_BAR_ANIM, mIconsTranslationXForNavbar.value); + } + + private void updateTranslationXForBubbleBar() { + float translationX = mTranslationXForBubbleBar.value; + updateIconViewsTranslationX(INDEX_BUBBLE_BAR_ANIM, translationX); + if (mDragLayerController != null) { + mDragLayerController.setTranslationXForBubbleBar(translationX); + } + } + + private void updateIconViewsTranslationX(int translationXChannel, float translationX) { View[] iconViews = mTaskbarView.getIconViews(); - float translationX = mIconsTranslationXForNavbar.value; - for (int iconIndex = 0; iconIndex < iconViews.length; iconIndex++) { - View iconView = iconViews[iconIndex]; + for (View iconView : iconViews) { MultiTranslateDelegate translateDelegate = ((Reorderable) iconView).getTranslateDelegate(); - translateDelegate.getTranslationX(INDEX_NAV_BAR_ANIM).setValue(translationX); + translateDelegate.getTranslationX(translationXChannel).setValue(translationX); } } @@ -811,6 +872,13 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar if (mTaskbarView.updateMaxNumIcons()) { commitRunningAppsToUI(); } + adjustTaskbarXForBubbleBar(); + } + + private void adjustTaskbarXForBubbleBar() { + if (mBubbleControllers != null && mActivity.isTransientTaskbar()) { + translateTaskbarXForBubbleBar(/* animate= */ true); + } } /** @@ -841,7 +909,17 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, interpolator); setter.setFloat(mTaskbarNavButtonTranslationY, VALUE, -offsetY, interpolator); setter.setFloat(mTaskbarNavButtonTranslationYForInAppDisplay, VALUE, offsetY, interpolator); - + if (mBubbleControllers != null + && mCurrentBubbleBarLocation != null + && mActivity.isTransientTaskbar()) { + int offsetX = mBubbleControllers.bubbleBarViewController + .getTransientTaskbarTranslationXForBubbleBar(mCurrentBubbleBarLocation); + if (offsetX != 0) { + // if taskbar should be adjusted for the bubble bar adjust the taskbar translation + mTranslationXForBubbleBar.updateValue(offsetX); + setter.setFloat(mTranslationXForBubbleBar, VALUE, 0, interpolator); + } + } int collapsedHeight = mActivity.getDefaultTaskbarWindowSize(); int expandedHeight = Math.max(collapsedHeight, taskbarDp.taskbarHeight + offsetY); setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowSize( @@ -1042,8 +1120,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar } private boolean bubbleBarHasBubbles() { - return mControllers.bubbleControllers.isPresent() - && mControllers.bubbleControllers.get().bubbleBarViewController.hasBubbles(); + return mBubbleControllers != null + && mBubbleControllers.bubbleBarViewController.hasBubbles(); } public void onRotationChanged(DeviceProfile deviceProfile) { diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 37c619496d..a04ae9b6dd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -1326,6 +1326,14 @@ public class BubbleBarView extends FrameLayout { return getScaledIconSize() + mIconOverlapAmount + 2 * mBubbleBarPadding; } + float getCollapsedWidthForIconSizeAndPadding(int iconSize, int bubbleBarPadding) { + final int bubbleChildCount = Math.min(getBubbleChildCount(), MAX_VISIBLE_BUBBLES_COLLAPSED); + if (bubbleChildCount == 0) return 0; + final int spacesCount = bubbleChildCount - 1; + final float horizontalPadding = 2 * bubbleBarPadding; + return iconSize * bubbleChildCount + mIconOverlapAmount * spacesCount + horizontalPadding; + } + /** Returns the child count excluding the overflow if it's present. */ int getBubbleChildCount() { return hasOverflow() ? getChildCount() - 1 : getChildCount(); diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index dd1b0ca87e..e7fb1c2127 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -122,7 +122,8 @@ public class BubbleBarViewController { private float mBubbleBarSwipeUpTranslationY; // Modified when bubble bar is springing back into the stash handle. private float mBubbleBarStashTranslationY; - + // Minimum distance between the BubbleBar and the taskbar + private final int mBubbleBarTaskbarMinDistance; // Whether the bar is hidden for a sysui state. private boolean mHiddenForSysui; // Whether the bar is hidden because there are no bubbles. @@ -150,10 +151,11 @@ public class BubbleBarViewController { mBubbleBarContainer = bubbleBarContainer; mSystemUiProxy = SystemUiProxy.INSTANCE.get(mActivity); mBubbleBarAlpha = new MultiValueAlpha(mBarView, 1 /* num alpha channels */); - mIconSize = activity.getResources().getDimensionPixelSize( - R.dimen.bubblebar_icon_size); - mDragElevation = activity.getResources().getDimensionPixelSize( - R.dimen.bubblebar_drag_elevation); + Resources res = activity.getResources(); + mIconSize = res.getDimensionPixelSize(R.dimen.bubblebar_icon_size); + mBubbleBarTaskbarMinDistance = res.getDimensionPixelSize( + R.dimen.bubblebar_transient_taskbar_min_distance); + mDragElevation = res.getDimensionPixelSize(R.dimen.bubblebar_drag_elevation); mTaskbarTranslationDelta = getBubbleBarTranslationDeltaForTaskbar(activity); } @@ -657,6 +659,45 @@ public class BubbleBarViewController { } } + /** + * Returns the translation X of the transient taskbar according to the bubble bar location + * regardless of the current taskbar mode. + */ + public int getTransientTaskbarTranslationXForBubbleBar(BubbleBarLocation location) { + int taskbarShift = 0; + if (!isBubbleBarVisible() || mTaskbarViewPropertiesProvider == null) return taskbarShift; + Rect taskbarViewBounds = mTaskbarViewPropertiesProvider.getTaskbarViewBounds(); + if (taskbarViewBounds.isEmpty()) return taskbarShift; + int actualDistance = + getDistanceBetweenTransientTaskbarAndBubbleBar(location, taskbarViewBounds); + if (actualDistance < mBubbleBarTaskbarMinDistance) { + taskbarShift = mBubbleBarTaskbarMinDistance - actualDistance; + if (!location.isOnLeft(mBarView.isLayoutRtl())) { + taskbarShift = -taskbarShift; + } + } + return taskbarShift; + } + + private int getDistanceBetweenTransientTaskbarAndBubbleBar(BubbleBarLocation location, + Rect taskbarViewBounds) { + Resources res = mActivity.getResources(); + DeviceProfile transientDp = mActivity.getTransientTaskbarDeviceProfile(); + int transientIconSize = getBubbleBarIconSizeFromDeviceProfile(res, transientDp); + int transientPadding = getBubbleBarPaddingFromDeviceProfile(res, transientDp); + int transientWidthWithMargin = (int) (mBarView.getCollapsedWidthForIconSizeAndPadding( + transientIconSize, transientPadding) + mBarView.getHorizontalMargin()); + int distance; + if (location.isOnLeft(mBarView.isLayoutRtl())) { + distance = taskbarViewBounds.left - transientWidthWithMargin; + } else { + int displayWidth = res.getDisplayMetrics().widthPixels; + int bubbleBarLeft = displayWidth - transientWidthWithMargin; + distance = bubbleBarLeft - taskbarViewBounds.right; + } + return distance; + } + // // Modifying view related properties. // diff --git a/src/com/android/launcher3/util/MultiTranslateDelegate.java b/src/com/android/launcher3/util/MultiTranslateDelegate.java index 38c87c8d5a..ce006c4184 100644 --- a/src/com/android/launcher3/util/MultiTranslateDelegate.java +++ b/src/com/android/launcher3/util/MultiTranslateDelegate.java @@ -38,6 +38,7 @@ public class MultiTranslateDelegate { public static final int INDEX_TASKBAR_REVEAL_ANIM = 4; public static final int INDEX_TASKBAR_PINNING_ANIM = 5; public static final int INDEX_NAV_BAR_ANIM = 6; + public static final int INDEX_BUBBLE_BAR_ANIM = 7; // Affect all items inside of a MultipageCellLayout public static final int INDEX_CELLAYOUT_MULTIPAGE_SPACING = 3; @@ -48,7 +49,7 @@ public class MultiTranslateDelegate { // Specific for hotseat items when adjusting for bubbles public static final int INDEX_BUBBLE_ADJUSTMENT_ANIM = 3; - public static final int COUNT = 7; + public static final int COUNT = 8; private final MultiPropertyFactory mTranslationX; private final MultiPropertyFactory mTranslationY;