From fa1e14c4b8c2f28d767f3776923030ef671bfa38 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 21 Jun 2021 18:05:25 -0700 Subject: [PATCH] Polish folder icon bugs. - Fix bug where folders are misaligned. - Fix bug when closing on 2nd page of large folder. Bug: 184822585 Test: drag folder originally in hotseat to workspace, vice versa test on grid where isScalable=true and isScalable=false Change-Id: I08a79b8d280df3e3974baaa07e80db6bc4165e58 --- src/com/android/launcher3/CellLayout.java | 3 --- src/com/android/launcher3/ShortcutAndWidgetContainer.java | 8 +++++--- .../android/launcher3/folder/FolderAnimationManager.java | 5 ++--- src/com/android/launcher3/folder/FolderIcon.java | 5 ----- src/com/android/launcher3/folder/PreviewBackground.java | 3 +-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index bfa1769ea8..382343793c 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -684,9 +684,6 @@ public class CellLayout extends ViewGroup { if (child instanceof BubbleTextView) { BubbleTextView bubbleChild = (BubbleTextView) child; bubbleChild.setTextVisibility(mContainerType != HOTSEAT); - if (mActivity.getDeviceProfile().isScalableGrid) { - bubbleChild.setCenterVertically(mContainerType != HOTSEAT); - } } child.setScaleX(mChildScale); diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java index 4579705f5a..2a5187d025 100644 --- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java +++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java @@ -138,12 +138,14 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon. mBorderSpacing, null); // Center the icon/folder int cHeight = getCellContentHeight(); - int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f)); + int cellPaddingY = dp.isScalableGrid && mContainerType == WORKSPACE + ? dp.cellYPaddingPx + : (int) Math.max(0, ((lp.height - cHeight) / 2f)); // No need to add padding when cell layout border spacing is present. - boolean noPadding = (dp.cellLayoutBorderSpacingPx > 0 && mContainerType == WORKSPACE) + boolean noPaddingX = (dp.cellLayoutBorderSpacingPx > 0 && mContainerType == WORKSPACE) || (dp.folderCellLayoutBorderSpacingPx > 0 && mContainerType == FOLDER); - int cellPaddingX = noPadding + int cellPaddingX = noPaddingX ? 0 : mContainerType == WORKSPACE ? dp.workspaceCellPaddingXPx diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java index 4fe85be820..cb3884dc47 100644 --- a/src/com/android/launcher3/folder/FolderAnimationManager.java +++ b/src/com/android/launcher3/folder/FolderAnimationManager.java @@ -245,9 +245,8 @@ public class FolderAnimationManager { + mDeviceProfile.folderCellHeightPx * 2; int page = mIsOpening ? mContent.getCurrentPage() : mContent.getDestinationPage(); int left = mContent.getPaddingLeft() + page * lp.width; - Rect contentStart = new Rect(0, 0, width, height); - Rect contentEnd = new Rect(endRect.left + left, endRect.top, endRect.right + left, - endRect.bottom); + Rect contentStart = new Rect(left, 0, left + width, height); + Rect contentEnd = new Rect(left, 0, left + lp.width, lp.height); play(a, getShape().createRevealAnimator( mFolder.getContent(), contentStart, contentEnd, finalRadius, !mIsOpening)); diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 5c11451535..25a01414d2 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -174,8 +174,6 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel folder.setFolderIcon(icon); folder.bind(folderInfo); icon.setFolder(folder); - icon.mBackground.paddingY = icon.isInHotseat() - ? 0 : activityContext.getDeviceProfile().cellYPaddingPx; return icon; } @@ -217,7 +215,6 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel icon.setAccessibilityDelegate(activity.getAccessibilityDelegate()); - icon.mBackground.paddingY = icon.isInHotseat() ? 0 : grid.cellYPaddingPx; icon.mPreviewVerifier = new FolderGridOrganizer(activity.getDeviceProfile().inv); icon.mPreviewVerifier.setFolderInfo(folderInfo); icon.updatePreviewItems(false); @@ -580,7 +577,6 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel public void setFolderBackground(PreviewBackground bg) { mBackground = bg; mBackground.setInvalidateDelegate(this); - mBackground.paddingY = isInHotseat() ? 0 : mActivity.getDeviceProfile().cellYPaddingPx; } @Override @@ -628,7 +624,6 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel if (!mForceHideDot && ((mDotInfo != null && mDotInfo.hasDot()) || mDotScale > 0)) { Rect iconBounds = mDotParams.iconBounds; BubbleTextView.getIconBounds(this, iconBounds, mActivity.getDeviceProfile().iconSizePx); - iconBounds.offset(0, mBackground.paddingY); float iconScale = (float) mBackground.previewSize / iconBounds.width(); Utilities.scaleRectAboutCenter(iconBounds, iconScale); diff --git a/src/com/android/launcher3/folder/PreviewBackground.java b/src/com/android/launcher3/folder/PreviewBackground.java index 204decbee4..460521f1a4 100644 --- a/src/com/android/launcher3/folder/PreviewBackground.java +++ b/src/com/android/launcher3/folder/PreviewBackground.java @@ -77,7 +77,6 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing { int previewSize; int basePreviewOffsetX; int basePreviewOffsetY; - int paddingY; private CellLayout mDrawingDelegate; @@ -161,7 +160,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing { previewSize = grid.folderIconSizePx; basePreviewOffsetX = (availableSpaceX - previewSize) / 2; - basePreviewOffsetY = paddingY + topPadding + grid.folderIconOffsetYPx; + basePreviewOffsetY = topPadding + grid.folderIconOffsetYPx; // Stroke width is 1dp mStrokeWidth = context.getResources().getDisplayMetrics().density;