Merge "Shift transient taskbar to ensure 12dp distance with the bubble bar." into main

This commit is contained in:
Mykola Podolian
2025-01-13 12:52:21 -08:00
committed by Android (Google) Code Review
9 changed files with 193 additions and 47 deletions
@@ -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);
}
@@ -664,6 +666,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.
//