Merge "Account for bubble bar bounds for taskbar overflow" into main
This commit is contained in:
commit
a8440279bf
6 files changed
+63
-11
No files matched your search
@@ -418,7 +418,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
/** Called when the visibility of the bubble bar changed. */
|
||||
public void bubbleBarVisibilityChanged(boolean isVisible) {
|
||||
mControllers.uiController.adjustHotseatForBubbleBar(isVisible);
|
||||
mControllers.taskbarViewController.resetIconAlignmentController();
|
||||
mControllers.taskbarViewController.adjustTaskbarForBubbleBar();
|
||||
}
|
||||
|
||||
public void init(@NonNull TaskbarSharedState sharedState) {
|
||||
|
||||
@@ -120,7 +120,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
private boolean mShouldTryStartAlign;
|
||||
|
||||
private final int mMaxNumIcons;
|
||||
private int mMaxNumIcons = 0;
|
||||
private int mIdealNumIcons = 0;
|
||||
|
||||
private final int mAllAppsButtonTranslationOffset;
|
||||
|
||||
@@ -188,8 +189,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
// TODO: Disable touch events on QSB otherwise it can crash.
|
||||
mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
|
||||
|
||||
mMaxNumIcons = calculateMaxNumIcons();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,11 +199,15 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
int availableWidth = deviceProfile.widthPx;
|
||||
int defaultEdgeMargin =
|
||||
(int) getResources().getDimension(deviceProfile.inv.inlineNavButtonsEndSpacing);
|
||||
int spaceForBubbleBar =
|
||||
Math.round(mControllerCallbacks.getBubbleBarMaxCollapsedWidthIfVisible());
|
||||
|
||||
// Reserve space required for edge margins, or for navbar if shown. If task bar needs to be
|
||||
// center aligned with nav bar shown, reserve space on both sides.
|
||||
availableWidth -= Math.max(defaultEdgeMargin, deviceProfile.hotseatBarEndOffset);
|
||||
availableWidth -= Math.max(defaultEdgeMargin,
|
||||
availableWidth -=
|
||||
Math.max(defaultEdgeMargin + spaceForBubbleBar, deviceProfile.hotseatBarEndOffset);
|
||||
availableWidth -= Math.max(
|
||||
defaultEdgeMargin + (mShouldTryStartAlign ? 0 : spaceForBubbleBar),
|
||||
mShouldTryStartAlign ? 0 : deviceProfile.hotseatBarEndOffset);
|
||||
|
||||
// The space taken by an item icon used during layout.
|
||||
@@ -231,6 +234,21 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
return Math.floorDiv(availableWidth, iconSize) + additionalIcons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates the max number of icons the taskbar view can show without entering overflow.
|
||||
* Returns whether the max number of icons changed and the change affects the number of icons
|
||||
* that should be shown in the taskbar.
|
||||
*/
|
||||
boolean updateMaxNumIcons() {
|
||||
if (!Flags.taskbarOverflow()) {
|
||||
return false;
|
||||
}
|
||||
int oldMaxNumIcons = mMaxNumIcons;
|
||||
mMaxNumIcons = calculateMaxNumIcons();
|
||||
return oldMaxNumIcons != mMaxNumIcons
|
||||
&& (mIdealNumIcons > oldMaxNumIcons || mIdealNumIcons > mMaxNumIcons);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
boolean changed = getVisibility() != visibility;
|
||||
@@ -328,6 +346,10 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
&& mActivityContext.getTaskbarFeatureEvaluator().getSupportsPinningPopup()) {
|
||||
setOnTouchListener(mControllerCallbacks.getTaskbarTouchListener());
|
||||
}
|
||||
|
||||
if (Flags.taskbarOverflow()) {
|
||||
mMaxNumIcons = calculateMaxNumIcons();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAndRecycle(View view) {
|
||||
@@ -460,8 +482,9 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
}
|
||||
}
|
||||
|
||||
overflowSize =
|
||||
nextViewIndex + numberOfSupportedRecents + nonTaskIconsToBeAdded - mMaxNumIcons;
|
||||
mIdealNumIcons = nextViewIndex + numberOfSupportedRecents + nonTaskIconsToBeAdded;
|
||||
overflowSize = mIdealNumIcons - mMaxNumIcons;
|
||||
|
||||
if (overflowSize > 0 && mTaskbarOverflowView != null) {
|
||||
addView(mTaskbarOverflowView, nextViewIndex++);
|
||||
} else if (mTaskbarOverflowView != null) {
|
||||
|
||||
@@ -137,6 +137,17 @@ public class TaskbarViewCallbacks {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max bubble bar collapsed width for the current bubble bar visibility state. Used to
|
||||
* reserve space for the bubble bar when transitioning taskbar view into overflow.
|
||||
*/
|
||||
public float getBubbleBarMaxCollapsedWidthIfVisible() {
|
||||
return mControllers.bubbleControllers
|
||||
.filter(c -> !c.bubbleBarViewController.isHiddenForNoBubbles())
|
||||
.map(c -> c.bubbleBarViewController.getCollapsedWidthWithMaxVisibleBubbles())
|
||||
.orElse(0f);
|
||||
}
|
||||
|
||||
/** Returns true if bubble bar controllers present and enabled in persistent taskbar. */
|
||||
public boolean isBubbleBarEnabledInPersistentTaskbar() {
|
||||
return Flags.enableBubbleBarInPersistentTaskBar()
|
||||
|
||||
@@ -779,9 +779,16 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
}
|
||||
}
|
||||
|
||||
/** Resets the icon alignment controller so that it can be recreated again later. */
|
||||
void resetIconAlignmentController() {
|
||||
/**
|
||||
* Resets the icon alignment controller so that it can be recreated again later, and updates
|
||||
* the list of icons shown in the taskbar if the bubble bar visibility changes the taskbar
|
||||
* overflow state.
|
||||
*/
|
||||
void adjustTaskbarForBubbleBar() {
|
||||
mIconAlignControllerLazy = null;
|
||||
if (mTaskbarView.updateMaxNumIcons()) {
|
||||
commitRunningAppsToUI();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1290,10 +1290,14 @@ public class BubbleBarView extends FrameLayout {
|
||||
// If there are more than 2 bubbles, the first 2 should be visible when collapsed,
|
||||
// excluding the overflow.
|
||||
return bubbleChildCount >= MAX_VISIBLE_BUBBLES_COLLAPSED
|
||||
? getScaledIconSize() + mIconOverlapAmount + horizontalPadding
|
||||
? getCollapsedWidthWithMaxVisibleBubbles()
|
||||
: getScaledIconSize() + horizontalPadding;
|
||||
}
|
||||
|
||||
float getCollapsedWidthWithMaxVisibleBubbles() {
|
||||
return getScaledIconSize() + mIconOverlapAmount + 2 * mBubbleBarPadding;
|
||||
}
|
||||
|
||||
/** Returns the child count excluding the overflow if it's present. */
|
||||
int getBubbleChildCount() {
|
||||
return hasOverflow() ? getChildCount() - 1 : getChildCount();
|
||||
|
||||
@@ -472,6 +472,13 @@ public class BubbleBarViewController {
|
||||
return mBarView.getBubbleBarLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max collapsed width for the bubble bar.
|
||||
*/
|
||||
public float getCollapsedWidthWithMaxVisibleBubbles() {
|
||||
return mBarView.getCollapsedWidthWithMaxVisibleBubbles();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if bubble bar is on the left edge of the screen, {@code false} if on
|
||||
* the right
|
||||
|
||||
Reference in new issue
Block a user