Fix Taskbar Icon going beyond screen

The problem: Currently, when users increases font size to fullest and also display size to fullest, taskbar icons goes beyond screen. The isssue is event worst when there is bubble bar present in the Taskbar. This is currently a problem with 3 button nav button.

The Solution: The solution is in two parts.
Part 1: figure out amount of icons we need to remove from hotseat for the taskbar icons to not got beyond screen and not collide with nav buttons or bubble bar.
Part 2: Once we figure out how many icon we need to not show in takbar which are present in the hotseat, we need to modify the takbar icon alignment controlled to modify alpha animation and eventually the visibility of those taksbar views. We also need to modify taskbar icon layout logic so that we don't take space for invisible taksbar icons and we layout next visible icon on the place of invisible icons.

Test: Manual, Presubmit
Bug: 412835965
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8def3264e3f4fa3a2354dfa693751ea3d5f33f36)
Merged-In: I8dea948df09c0a86871a9ac649f312ecf281545a
Change-Id: I8dea948df09c0a86871a9ac649f312ecf281545a
This commit is contained in:
Jagrut Desai
2025-06-13 11:03:38 -07:00
committed by Android Build Coastguard Worker
parent 710f20e89c
commit 4970befcdc
2 changed files with 107 additions and 5 deletions
@@ -115,6 +115,14 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
private int mNextViewIndex;
public int getIgnoreTaskbarIconCount() {
return mIgnoreTaskbarIconCount;
}
// TODO: clean it up in follow up cl with removal of taskbar icon alignment.
// Only used for edge of 3 button navigation mode, where we need to hide icons which go
// beyond the bounds.
private int mIgnoreTaskbarIconCount = 0;
/**
* Whether the divider is between Hotseat icons and Recents,
* instead of between All Apps button and Hotseat.
@@ -435,6 +443,9 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
}
removeView(mQsb);
mIgnoreTaskbarIconCount = getIgnoreCountForTaskbarIcons(recentTasks.size(),
hotseatItemInfos.length);
updateHotseatItems(hotseatItemInfos);
if (mTaskbarDividerContainer != null && !recentTasks.isEmpty()) {
@@ -472,6 +483,9 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
mNextViewIndex++;
}
mIgnoreTaskbarIconCount = getIgnoreCountForTaskbarIcons(recentTasks.size(),
hotseatItemInfos.length);
// Update left section.
if (mIsRtl) {
updateRecents(recentTasks.reversed(), hotseatItemInfos.length);
@@ -542,6 +556,53 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
return mIsRtl ? getChildCount() - mNumStaticViews - 1 : mNumStaticViews;
}
/**
* Calculate how many icon we need to not show in Taskbar that are present in hotseat.
*/
private int getIgnoreCountForTaskbarIcons(int recentsIcons, int hotseatIcons) {
if (!mActivityContext.isThreeButtonNav()
|| mActivityContext.getTaskbarFeatureEvaluator().isRecentsEnabled()) {
return 0;
}
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
// Add icon for all apps.
int icons = 1;
// Only include divider line in count if will be added to Taskbar view which is in
// conditions below.
if (mActivityContext.isInDesktopMode() && recentsIcons > 0) {
icons += 1;
} else if (recentsIcons + hotseatIcons != 0) {
icons += 1;
}
int spaceNeeded = getIconLayoutWidth(icons + recentsIcons + hotseatIcons);
boolean areBubblesVisible =
mControllerCallbacks.isBubbleBarEnabled() && mBubbleBarLocation != null;
int screenWidth = this.getResources().getDisplayMetrics().widthPixels;
int navSpaceNeeded = deviceProfile.getHotseatProfile().getBarEndOffset();
int ignoreCount = 0;
//Screen Width - nav space
int amountOfSpaceTaskbarIconsCanHave = screenWidth - navSpaceNeeded;
if (areBubblesVisible) {
// size of bubbles Icon and margin on the side.
int bubbleBarMargin = getResources().getDimensionPixelSize(
R.dimen.transient_taskbar_bottom_margin);
amountOfSpaceTaskbarIconsCanHave -= (mIconTouchSize + bubbleBarMargin);
}
int taskbarIconSpaceNeeded = spaceNeeded;
while (amountOfSpaceTaskbarIconsCanHave < taskbarIconSpaceNeeded) {
ignoreCount++;
int iconSpace = mIconTouchSize + (2 * mItemMarginLeftRight);
taskbarIconSpaceNeeded -= iconSpace;
}
return ignoreCount;
}
private void updateHotseatItems(ItemInfo[] hotseatItemInfos) {
int numViewsAnimated = 0;
@@ -832,7 +893,15 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
return 0;
}
Rect iconsBounds = getTransientTaskbarIconLayoutBoundsInParent();
return getTaskBarIconsEndForBubbleBarLocation(location) - iconsBounds.right;
int translateXFromIgnoredIcons =
mIgnoreTaskbarIconCount * (mIconTouchSize + mItemMarginLeftRight);
// If bubble bar or right translate in opposite direction.
if (!location.isOnLeft(isLayoutRtl())) {
translateXFromIgnoredIcons *= -1;
}
return getTaskBarIconsEndForBubbleBarLocation(location) - iconsBounds.right
+ translateXFromIgnoredIcons;
}
@Override
@@ -907,6 +976,16 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
iconEnd += mAllAppsButtonTranslationOffset;
}
if (mActivityContext.isThreeButtonNav()) {
boolean navbarOnLeft = mBubbleBarLocation != null && !mBubbleBarLocation.isOnLeft(
layoutRtl);
if (navbarOnLeft && layoutRtl) {
iconEnd -= (mIconTouchSize + mItemMarginLeftRight) * mIgnoreTaskbarIconCount;
} else if (!navbarOnLeft && !layoutRtl) {
iconEnd += (mIconTouchSize + mItemMarginLeftRight) * mIgnoreTaskbarIconCount;
}
}
mControllerCallbacks.onPreLayoutChildren();
int count = getChildCount();
@@ -1009,10 +1088,17 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
}
/**
* Returns the space used by the icons
* Returns the space used by the icons.
*/
private int getIconLayoutWidth() {
int countExcludingQsb = getChildCount();
return getIconLayoutWidth(getChildCount());
}
/**
* Return the space needed based on the number of taskbar icons supplied vs existing children.
*/
private int getIconLayoutWidth(int expectedNumberOfTaskbarIcons) {
int countExcludingQsb = expectedNumberOfTaskbarIcons;
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
if (deviceProfile.isQsbInline) {
countExcludingQsb--;