Fix bug where icons in hotseat were clipped when display size is Small.
Simplify calculations to ensure the hotseat sizes are always accurate.
Bug: 186556930
Test: changed display setting from small to largest on different grid
sizes (5x5, 4x4, 4x5, 3x3, 2x2)
Change-Id: I97580c50a9d821577eb63335950d5695d9bf035d
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index e9245b0..d301787 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -149,10 +149,11 @@
// Hotseat
public final int numShownHotseatIcons;
public int hotseatCellHeightPx;
+ private final int hotseatExtraVerticalSize;
// In portrait: size = height, in landscape: size = width
public int hotseatBarSizePx;
public final int hotseatBarTopPaddingPx;
- public int hotseatBarBottomPaddingPx;
+ public final int hotseatBarBottomPaddingPx;
// Start is the side next to the nav bar, end is the side next to the workspace
public final int hotseatBarSidePaddingStartPx;
public final int hotseatBarSidePaddingEndPx;
@@ -326,13 +327,9 @@
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
// Add a bit of space between nav bar and hotseat in vertical bar layout.
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
- int hotseatExtraVerticalSize =
+ hotseatExtraVerticalSize =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size);
- hotseatBarSizePx = pxFromDp(inv.iconSize, mMetrics, 1f)
- + (isVerticalBarLayout()
- ? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
- : (hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx
- + (isScalableGrid ? 0 : hotseatExtraVerticalSize)));
+ updateHotseatIconSize(pxFromDp(inv.iconSize, mMetrics, 1f));
overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
overviewTaskIconSizePx =
@@ -362,7 +359,6 @@
extraHotseatBottomPadding = Math.round(paddingHotseatBottom * iconScale);
hotseatBarSizePx += extraHotseatBottomPadding;
- hotseatBarBottomPaddingPx += extraHotseatBottomPadding;
} else if (!isVerticalBarLayout() && isPhone && isTallDevice) {
// We increase the hotseat size when there is extra space.
// ie. For a display with a large aspect ratio, we can keep the icons on the workspace
@@ -371,7 +367,6 @@
int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2
- workspacePageIndicatorHeight;
hotseatBarSizePx += extraSpace;
- hotseatBarBottomPaddingPx += extraSpace;
// Recalculate the available dimensions using the new hotseat size.
updateAvailableDimensions(res);
@@ -388,6 +383,17 @@
new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE);
}
+ private void updateHotseatIconSize(int hotseatIconSizePx) {
+ hotseatCellHeightPx = hotseatIconSizePx;
+ if (isVerticalBarLayout()) {
+ hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
+ + hotseatBarSidePaddingEndPx;
+ } else {
+ hotseatBarSizePx = hotseatIconSizePx + hotseatBarTopPaddingPx
+ + hotseatBarBottomPaddingPx + (isScalableGrid ? 0 : hotseatExtraVerticalSize);
+ }
+ }
+
private void setCellLayoutBorderSpacing(int borderSpacing) {
cellLayoutBorderSpacingPx = isScalableGrid ? borderSpacing : 0;
}
@@ -573,11 +579,7 @@
}
// Hotseat
- if (isVerticalLayout) {
- hotseatBarSizePx = iconSizePx + hotseatBarSidePaddingStartPx
- + hotseatBarSidePaddingEndPx;
- }
- hotseatCellHeightPx = iconSizePx;
+ updateHotseatIconSize(iconSizePx);
if (!isVerticalLayout) {
int expectedWorkspaceHeight = availableHeightPx - hotseatBarSizePx
@@ -763,7 +765,8 @@
hotseatBarTopPaddingPx,
hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx
+ mInsets.right,
- hotseatBarBottomPaddingPx + mInsets.bottom + cellLayoutBottomPaddingPx);
+ hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
+ + cellLayoutBottomPaddingPx + mInsets.bottom);
}
return mHotseatPadding;
}