Align QSB with hotseat and workspace icons
The QSB was a bit wider becuase icons visible size is a bit smaller than their actual size due to b/235886078 so we add a workaround to adjust QSB size based on the visible icon size
Bug: 281587788
Test: atest HomeScreenImageTest
Flag: NONE
Change-Id: I593ca2d588f08b830be0b2ac389c747b6f558b91
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 1ca7da9..53297f2 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -789,14 +789,16 @@
* width of the hotseat.
*/
private int calculateQsbWidth(int hotseatBorderSpace) {
+ int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx);
if (isQsbInline) {
int columns = getPanelCount() * inv.numColumns;
return getIconToIconWidthForColumns(columns)
- iconSizePx * numShownHotseatIcons
- - hotseatBorderSpace * numShownHotseatIcons;
+ - hotseatBorderSpace * numShownHotseatIcons
+ - iconExtraSpacePx;
} else {
int columns = inv.hotseatColumnSpan[mTypeIndex];
- return getIconToIconWidthForColumns(columns);
+ return getIconToIconWidthForColumns(columns) - iconExtraSpacePx;
}
}
@@ -1074,11 +1076,8 @@
}
private int getNormalizedIconDrawablePadding(int iconSizePx, int iconDrawablePadding) {
- // TODO(b/235886078): workaround needed because of this bug
- // Icons are 10% larger on XML than their visual size,
- // so remove that extra space to get labels closer to the correct padding
- int iconVisibleSizePx = Math.round(ICON_VISIBLE_AREA_FACTOR * iconSizePx);
- return Math.max(0, iconDrawablePadding - ((iconSizePx - iconVisibleSizePx) / 2));
+ return Math.max(0, iconDrawablePadding
+ - ((iconSizePx - getIconVisibleSizePx(iconSizePx)) / 2));
}
private int getNormalizedIconDrawablePadding() {
@@ -1091,8 +1090,7 @@
// so remove that extra space to get labels closer to the correct padding
int drawablePadding = (folderCellHeightPx - folderChildIconSizePx - textHeight) / 3;
- int iconVisibleSizePx = Math.round(ICON_VISIBLE_AREA_FACTOR * folderChildIconSizePx);
- int iconSizeDiff = folderChildIconSizePx - iconVisibleSizePx;
+ int iconSizeDiff = folderChildIconSizePx - getIconVisibleSizePx(folderChildIconSizePx);
return Math.max(0, drawablePadding - iconSizeDiff / 2);
}
@@ -1788,7 +1786,8 @@
}
} else if (mIsScalableGrid) {
- int sideSpacing = (availableWidthPx - hotseatQsbWidth) / 2;
+ int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx);
+ int sideSpacing = (availableWidthPx - (hotseatQsbWidth + iconExtraSpacePx)) / 2;
hotseatBarPadding.set(sideSpacing,
0,
sideSpacing,
@@ -1827,13 +1826,24 @@
availableWidthPx - allAppsSpacing,
0 /* borderSpace */,
numShownAllAppsColumns);
- int iconVisibleSize = Math.round(ICON_VISIBLE_AREA_FACTOR * allAppsIconSizePx);
- int iconAlignmentMargin = (cellWidth - iconVisibleSize) / 2;
+ int iconAlignmentMargin = (cellWidth - getIconVisibleSizePx(allAppsIconSizePx)) / 2;
return (Utilities.isRtl(context.getResources()) ? allAppsPadding.right
: allAppsPadding.left) + iconAlignmentMargin;
}
+ /**
+ * TODO(b/235886078): workaround needed because of this bug
+ * Icons are 10% larger on XML than their visual size, so remove that extra space to get
+ * some dimensions correct.
+ *
+ * When this bug is resolved this method will no longer be needed and we would be able to
+ * replace all instances where this method is called with iconSizePx.
+ */
+ private int getIconVisibleSizePx(int iconSizePx) {
+ return Math.round(ICON_VISIBLE_AREA_FACTOR * iconSizePx);
+ }
+
private int getAdditionalQsbSpace() {
return isQsbInline ? hotseatQsbWidth + hotseatBorderSpace : 0;
}