Fix taskbar icon flicker and jump when transforming to hotseat

- Apply additional translation on TaskbarView to account for difference between taskbar icon to bottom spacing compared to hotseat icon to bottom spacing
- Call updateIconAlignment outside of synchronizeNextDraw's then block, which get run after the synchronization

Bug: 204850744
Test: manual
Change-Id: Id65842f506eb342105082649446eb694cd5c33a4
This commit is contained in:
Alex Chau
2022-05-20 13:32:10 +01:00
parent a8b8de1fa0
commit 51da219869
4 changed files with 34 additions and 42 deletions
+26 -14
View File
@@ -100,6 +100,8 @@ public class DeviceProfile {
// Workspace
public final int desiredWorkspaceHorizontalMarginOriginalPx;
public int desiredWorkspaceHorizontalMarginPx;
public int gridVisualizationPaddingX;
public int gridVisualizationPaddingY;
public Point cellLayoutBorderSpaceOriginalPx;
public Point cellLayoutBorderSpacePx;
public Rect cellLayoutPaddingPx = new Rect();
@@ -303,6 +305,10 @@ public class DeviceProfile {
desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
gridVisualizationPaddingX = res.getDimensionPixelSize(
R.dimen.grid_visualization_horizontal_cell_spacing);
gridVisualizationPaddingY = res.getDimensionPixelSize(
R.dimen.grid_visualization_vertical_cell_spacing);
bottomSheetTopPadding = mInsets.top // statusbar height
+ res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding)
@@ -1069,24 +1075,23 @@ public class DeviceProfile {
mInsets.right + hotseatBarSidePaddingStartPx, paddingBottom);
}
} else if (isTaskbarPresent) {
boolean isRtl = Utilities.isRtl(context.getResources());
int hotseatHeight = workspacePadding.bottom;
int taskbarOffset = getTaskbarOffsetY();
// Center the QSB vertically with hotseat
int hotseatBottomPadding = getHotseatBottomPadding();
int hotseatTopPadding =
workspacePadding.bottom - hotseatBottomPadding - hotseatCellHeightPx;
// Push icons to the side
int additionalQsbSpace = isQsbInline ? qsbWidth + hotseatBorderSpace : 0;
// Center the QSB vertically with hotseat
int hotseatTopPadding = hotseatHeight - taskbarOffset - hotseatCellHeightPx;
int endOffset = ApiWrapper.getHotseatEndOffset(context);
int requiredWidth = iconSizePx * numShownHotseatIcons
+ hotseatBorderSpace * (numShownHotseatIcons - 1)
+ additionalQsbSpace;
int endOffset = ApiWrapper.getHotseatEndOffset(context);
int hotseatWidth = Math.min(requiredWidth, availableWidthPx - endOffset);
int sideSpacing = (availableWidthPx - hotseatWidth) / 2;
mHotseatPadding.set(sideSpacing, hotseatTopPadding, sideSpacing, taskbarOffset);
mHotseatPadding.set(sideSpacing, hotseatTopPadding, sideSpacing, hotseatBottomPadding);
boolean isRtl = Utilities.isRtl(context.getResources());
if (isRtl) {
mHotseatPadding.right += additionalQsbSpace;
} else {
@@ -1146,10 +1151,7 @@ public class DeviceProfile {
}
}
/**
* Returns the number of pixels the taskbar is translated from the bottom of the screen.
*/
public int getTaskbarOffsetY() {
private int getHotseatBottomPadding() {
if (isQsbInline) {
return getQsbOffsetY() - (Math.abs(hotseatQsbHeight - hotseatCellHeightPx) / 2);
} else {
@@ -1157,6 +1159,16 @@ public class DeviceProfile {
}
}
/**
* Returns the number of pixels the taskbar is translated from the bottom of the screen.
*/
public int getTaskbarOffsetY() {
int taskbarIconBottomSpace = (taskbarSize - iconSizePx) / 2;
int launcherIconBottomSpace =
Math.min((hotseatCellHeightPx - iconSizePx) / 2, gridVisualizationPaddingY);
return getHotseatBottomPadding() + launcherIconBottomSpace - taskbarIconBottomSpace;
}
/**
* Returns the number of pixels required below OverviewActions excluding insets.
*/