From e9b5e14a2b1da2f58a067e1ce4f77ca810b90e03 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Sat, 4 Nov 2023 17:10:13 +0000 Subject: [PATCH] Use new icon stepping logic for Folders Bug: 307694237 Test: DeviceProfileResponsiveDumpTest Test: DeviceProfileResponsiveAlternativeDisplaysDumpTest Test: ResponsiveFolderImageTest Flag: ACONFIG com.android.launcher3.enable_responsive_workspace TEAMFOOD Change-Id: Ifbfb714e48c2e0851ef55ac60cadafbb6358d074 --- src/com/android/launcher3/DeviceProfile.java | 27 ++++++-------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 73cd8c42f2..23b1a00740 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -1338,8 +1338,6 @@ public class DeviceProfile { if (mIsResponsiveGrid) { folderCellWidthPx = mResponsiveFolderWidthSpec.getCellSizePx(); - - // Height folderCellHeightPx = mResponsiveFolderHeightSpec.getCellSizePx(); folderContentPaddingTop = mResponsiveFolderHeightSpec.getStartPaddingPx(); folderFooterHeightPx = mResponsiveFolderHeightSpec.getEndPaddingPx(); @@ -1356,24 +1354,15 @@ public class DeviceProfile { // Recalculating padding and cell height folderChildDrawablePaddingPx = getNormalizedFolderChildDrawablePaddingPx(textHeight); - int folderCellContentHeight = folderChildIconSizePx + folderChildDrawablePaddingPx - + textHeight; - // Reduce the icon in height when it's taller than the expected cell height - while (folderChildIconSizePx > mIconSizeSteps.minimumIconSize() - && folderCellContentHeight > folderCellHeightPx) { - folderChildDrawablePaddingPx -= folderCellContentHeight - folderCellHeightPx; - if (folderChildDrawablePaddingPx < 0) { - // get a smaller icon size - folderChildIconSizePx = mIconSizeSteps.getNextLowerIconSize( - folderChildIconSizePx); - folderChildDrawablePaddingPx = - getNormalizedFolderChildDrawablePaddingPx(textHeight); - } - // calculate new cellContentHeight - folderCellContentHeight = folderChildIconSizePx + folderChildDrawablePaddingPx - + textHeight; - } + CellContentDimensions cellContentDimensions = new CellContentDimensions( + folderChildIconSizePx, + folderChildDrawablePaddingPx, + folderChildTextSizePx); + cellContentDimensions.resizeToFitCellHeight(folderCellHeightPx, mIconSizeSteps); + folderChildIconSizePx = cellContentDimensions.getIconSizePx(); + folderChildDrawablePaddingPx = cellContentDimensions.getIconDrawablePaddingPx(); + folderChildTextSizePx = cellContentDimensions.getIconTextSizePx(); } else if (mIsScalableGrid) { if (inv.folderStyle == INVALID_RESOURCE_HANDLE) { folderCellWidthPx = roundPxValueFromFloat(getCellSize().x * scale);