From 080d890383db046de7587efdca83846892544c13 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Mon, 28 Mar 2022 15:30:29 +0100 Subject: [PATCH] Add border space to all apps cells Also remove tablet condition, phones should also follow the workspace size. Fix: 218638090 Test: visual and HSV Change-Id: Ib201011391c28c0f1dcd0ce8645c3191655a7227 --- res/values/attrs.xml | 42 +++++++++++++---- src/com/android/launcher3/DeviceProfile.java | 31 +++++++----- .../launcher3/InvariantDeviceProfile.java | 47 ++++++++++++++----- 3 files changed, 89 insertions(+), 31 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index c96a2284e7..187689f8c3 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -258,14 +258,6 @@ - - - - - - - - @@ -280,6 +272,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 0c33bce5e0..7e7e078d89 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -319,7 +319,7 @@ public class DeviceProfile { pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics), pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics)); cellLayoutBorderSpaceOriginalPx = new Point(cellLayoutBorderSpacePx); - folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics, 1f); + folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics); folderCellLayoutBorderSpacePx = new Point(folderCellLayoutBorderSpaceOriginalPx, folderCellLayoutBorderSpaceOriginalPx); @@ -525,21 +525,21 @@ public class DeviceProfile { } private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) { + return getCellLayoutBorderSpace(idp, 1f); + + } + + private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp, float scale) { if (!isScalableGrid) { return new Point(0, 0); } - int horizontalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].x, mMetrics); - int verticalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].y, mMetrics); + int horizontalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].x, mMetrics, scale); + int verticalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].y, mMetrics, scale); return new Point(horizontalSpacePx, verticalSpacePx); } - private Point getCellLayoutBorderSpaceScaled(InvariantDeviceProfile idp, float scale) { - Point original = getCellLayoutBorderSpace(idp); - return new Point((int) (original.x * scale), (int) (original.y * scale)); - } - public Info getDisplayInfo() { return mInfo; } @@ -708,7 +708,7 @@ public class DeviceProfile { iconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * iconScale); iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale); - cellLayoutBorderSpacePx = getCellLayoutBorderSpaceScaled(inv, scale); + cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv, scale); if (isScalableGrid) { cellWidthPx = pxFromDp(inv.minCellSize[mTypeIndex].x, mMetrics, scale); @@ -756,15 +756,22 @@ public class DeviceProfile { * Updates the iconSize for allApps* variants. */ public void updateAllAppsIconSize(float scale, Resources res) { - //TODO(b/218638090): remove the tablet condition once we have phone specs - if (isScalableGrid && isTablet) { + allAppsBorderSpacePx = new Point( + pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics, scale), + pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics, scale)); + if (isScalableGrid) { allAppsIconSizePx = pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics); allAppsIconTextSizePx = pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics); allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx; + // AllApps cells don't have real space between cells, + // so we add the border space to the cell height + allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics, scale) + + allAppsBorderSpacePx.y; + // but width is just the cell, + // the border is added in #updateAllAppsContainerWidth allAppsCellWidthPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].x, mMetrics, scale); - allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics, scale); } else { float invIconSizeDp = inv.iconSize[mTypeIndex]; float invIconTextSizeSp = inv.iconTextSize[mTypeIndex]; diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 219ed9e371..59ef28380b 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -900,19 +900,44 @@ public class InvariantDeviceProfile { allAppsCellSize[INDEX_DEFAULT].y); allAppsCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); - x = y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpace, - borderSpace); - allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y); - x = y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscape, - allAppsBorderSpaces[INDEX_DEFAULT].x); - allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y); - x = y = a.getFloat( + float allAppsBorderSpace = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsBorderSpace, borderSpace); + float allAppsBorderSpaceLandscape = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscape, + allAppsBorderSpace); + float allAppsBorderSpaceTwoPanelPortrait = a.getFloat( R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait, - allAppsBorderSpaces[INDEX_DEFAULT].x); - allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); - x = y = a.getFloat( + allAppsBorderSpace); + float allAppsBorderSpaceTwoPanelLandscape = a.getFloat( R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscape, - allAppsBorderSpaces[INDEX_DEFAULT].x); + allAppsBorderSpace); + + x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceHorizontal, + allAppsBorderSpace); + y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceVertical, + allAppsBorderSpace); + allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y); + + x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeHorizontal, + allAppsBorderSpaceLandscape); + y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpaceLandscapeVertical, + allAppsBorderSpaceLandscape); + allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y); + + x = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitHorizontal, + allAppsBorderSpaceTwoPanelPortrait); + y = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortraitVertical, + allAppsBorderSpaceTwoPanelPortrait); + allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); + + x = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeHorizontal, + allAppsBorderSpaceTwoPanelLandscape); + y = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscapeVertical, + allAppsBorderSpaceTwoPanelLandscape); allAppsBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y); iconSizes[INDEX_DEFAULT] =