From af6ebe87ea1de17f948031b218d9bc44e6f01e21 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Fri, 11 Jun 2021 17:57:05 -0700 Subject: [PATCH] Do not add padding left/right when cell layout border spacing exists. Bug: 188094809 Test: enable layout bounds and view text spanning entire cell Change-Id: Ia7ed45d0e844b2594a8708e03fe385a321345f5e --- .../launcher3/ShortcutAndWidgetContainer.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java index 2c24c3a52e..4579705f5a 100644 --- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java +++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java @@ -18,6 +18,9 @@ package com.android.launcher3; import static android.view.MotionEvent.ACTION_DOWN; +import static com.android.launcher3.CellLayout.FOLDER; +import static com.android.launcher3.CellLayout.WORKSPACE; + import android.app.WallpaperManager; import android.content.Context; import android.graphics.Rect; @@ -124,21 +127,27 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon. public void measureChild(View child) { CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams(); - final DeviceProfile profile = mActivity.getDeviceProfile(); + final DeviceProfile dp = mActivity.getDeviceProfile(); if (child instanceof LauncherAppWidgetHostView) { - ((LauncherAppWidgetHostView) child).getWidgetInset(profile, mTempRect); + ((LauncherAppWidgetHostView) child).getWidgetInset(dp, mTempRect); lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY, - profile.appWidgetScale.x, profile.appWidgetScale.y, mBorderSpacing, mTempRect); + dp.appWidgetScale.x, dp.appWidgetScale.y, mBorderSpacing, mTempRect); } else { lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY, mBorderSpacing, null); // Center the icon/folder int cHeight = getCellContentHeight(); int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f)); - int cellPaddingX = mContainerType == CellLayout.WORKSPACE - ? profile.workspaceCellPaddingXPx - : (int) (profile.edgeMarginPx / 2f); + + // No need to add padding when cell layout border spacing is present. + boolean noPadding = (dp.cellLayoutBorderSpacingPx > 0 && mContainerType == WORKSPACE) + || (dp.folderCellLayoutBorderSpacingPx > 0 && mContainerType == FOLDER); + int cellPaddingX = noPadding + ? 0 + : mContainerType == WORKSPACE + ? dp.workspaceCellPaddingXPx + : (int) (dp.edgeMarginPx / 2f); child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0); } int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);