Include border spacing to align tasbar icons with hotseat.
The original calculation was including spacing in the the
hotseatCellSize, but that causes us to incorrectly compute the
hotseatIconCenter. If we take advantage of
DeviceProfile.calculateCellWidth, we get the width without the spacing.
Then we can add spacing for every icon to the left of the current one
when figuring out the center.
Test: Manual on tablet using device types tablet and multi display.
Fix: 210123477
Change-Id: Ie182718ad3a229ffa8bae031f3ac7f73f8539f49
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index a4d899c..e00d177 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -204,9 +204,11 @@
PendingAnimation setter = new PendingAnimation(100);
Rect hotseatPadding = launcherDp.getHotseatLayoutPadding(mActivity);
float scaleUp = ((float) launcherDp.iconSizePx) / mActivity.getDeviceProfile().iconSizePx;
- int hotseatCellSize =
- (launcherDp.availableWidthPx - hotseatPadding.left - hotseatPadding.right)
- / launcherDp.numShownHotseatIcons;
+ int borderSpacing = launcherDp.cellLayoutBorderSpacePx.x;
+ int hotseatCellSize = DeviceProfile.calculateCellWidth(
+ launcherDp.availableWidthPx - hotseatPadding.left - hotseatPadding.right,
+ borderSpacing,
+ launcherDp.numShownHotseatIcons);
int offsetY = launcherDp.getTaskbarOffsetY();
setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
@@ -225,7 +227,8 @@
setter.setFloat(child, SCALE_PROPERTY, scaleUp, LINEAR);
float childCenter = (child.getLeft() + child.getRight()) / 2;
- float hotseatIconCenter = hotseatPadding.left + hotseatCellSize * info.screenId
+ float hotseatIconCenter = hotseatPadding.left
+ + (hotseatCellSize + borderSpacing) * info.screenId
+ hotseatCellSize / 2;
setter.setFloat(child, ICON_TRANSLATE_X, hotseatIconCenter - childCenter, LINEAR);
}