From b7ef569591faf672f86629bd6bc543afce3b4a1c Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Thu, 10 Mar 2022 10:32:36 +0000 Subject: [PATCH] Change size of All Apps bottom sheet This brings the size of the bottom sheet closer to the spec provided by UX. For that type of flexibility to be possible, more attributes are introduced and some calculations had to be changed. This shouldn't affect phones. Bug: 218638090 Test: visual, with dumpsys and HSV Change-Id: Ieee7580d80d8e100837b1cdd7a1455c4d65612dc --- res/values-sw600dp-land/dimens.xml | 9 +++-- res/values-sw600dp/dimens.xml | 2 +- res/values-sw720dp-land/dimens.xml | 7 ++++ res/values-sw720dp/dimens.xml | 5 ++- res/values/attrs.xml | 19 +++++++++++ src/com/android/launcher3/DeviceProfile.java | 20 ++++++----- .../launcher3/InvariantDeviceProfile.java | 34 +++++++++++++++++++ .../android/launcher3/DeviceProfileTest.kt | 6 ++++ 8 files changed, 89 insertions(+), 13 deletions(-) diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml index 6c5be914dd..daca048878 100644 --- a/res/values-sw600dp-land/dimens.xml +++ b/res/values-sw600dp-land/dimens.xml @@ -16,14 +16,17 @@ --> - + 44dp - + 11.33dp 11.33dp - + 0dp 16dp + + + 52dp diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 501ead685f..73edc6f8bd 100644 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -23,7 +23,7 @@ 0dp - 46dp + 48dp 75dp diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml index 33da4a1bd8..eb5c751588 100644 --- a/res/values-sw720dp-land/dimens.xml +++ b/res/values-sw720dp-land/dimens.xml @@ -18,13 +18,20 @@ 0dp 32dp + 21.93dp 29.33dp + 64dp + + + 32dp + 49dp + 0dp diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml index b4c8837224..3ec211a142 100644 --- a/res/values-sw720dp/dimens.xml +++ b/res/values-sw720dp/dimens.xml @@ -16,10 +16,12 @@ - 65dp + 28dp + 27.59dp 36dp + 20sp 72dp @@ -28,6 +30,7 @@ 32dp 32dp 32dp + 164dp diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 4ed31f8968..c96a2284e7 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -241,9 +241,28 @@ if not specified --> + + + + + + + + + + + + + + + + + + + diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 91fa4ca497..dee7d4ec4f 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -624,14 +624,15 @@ public class DeviceProfile { + textHeight + (topBottomPadding * 2); } - private void updateAllAppsWidth(Resources res) { + private void updateAllAppsContainerWidth(Resources res) { int cellLayoutHorizontalPadding = (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2; if (isTablet) { - allAppsLeftRightPadding = res.getDimensionPixelSize( - R.dimen.all_apps_bottom_sheet_horizontal_padding) + cellLayoutHorizontalPadding; + allAppsLeftRightPadding = + res.getDimensionPixelSize(R.dimen.all_apps_bottom_sheet_horizontal_padding); + int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns) - + (allAppsBorderSpacePx.x * (numShownAllAppsColumns + 1)) + + (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1)) + allAppsLeftRightPadding * 2; allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2); } else { @@ -755,24 +756,26 @@ public class DeviceProfile { * Updates the iconSize for allApps* variants. */ public void updateAllAppsIconSize(float scale, Resources res) { - if (numShownAllAppsColumns != inv.numColumns) { + //TODO(b/218638090): remove the tablet condition once we have phone specs + if (isScalableGrid && isTablet) { allAppsIconSizePx = pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics); allAppsIconTextSizePx = pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics); allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx; - autoResizeAllAppsCells(); + 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]; allAppsIconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, scale)); allAppsIconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * scale); allAppsIconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale); + allAppsCellWidthPx = allAppsIconSizePx + (2 * allAppsIconDrawablePaddingPx); allAppsCellHeightPx = getCellSize().y; } - allAppsCellWidthPx = allAppsIconSizePx + (2 * allAppsIconDrawablePaddingPx); - updateAllAppsWidth(res); + updateAllAppsContainerWidth(res); if (isVerticalBarLayout()) { hideWorkspaceLabelsIfNotEnoughSpace(); } @@ -1223,6 +1226,7 @@ public class DeviceProfile { allAppsIconDrawablePaddingPx)); writer.println(prefix + pxToDpStr("allAppsCellHeightPx", allAppsCellHeightPx)); writer.println(prefix + pxToDpStr("allAppsCellWidthPx", allAppsCellWidthPx)); + writer.println(prefix + pxToDpStr("allAppsBorderSpacePx", allAppsBorderSpacePx.x)); writer.println(prefix + "\tnumShownAllAppsColumns: " + numShownAllAppsColumns); writer.println(prefix + pxToDpStr("allAppsLeftRightPadding", allAppsLeftRightPadding)); writer.println(prefix + pxToDpStr("allAppsLeftRightMargin", allAppsLeftRightMargin)); diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 9dd1493d16..219ed9e371 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -128,6 +128,7 @@ public class InvariantDeviceProfile { public float[] horizontalMargin; + public PointF[] allAppsCellSize; public float[] allAppsIconSize; public float[] allAppsIconTextSize; public PointF[] allAppsBorderSpaces; @@ -357,6 +358,7 @@ public class InvariantDeviceProfile { numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns; + allAppsCellSize = displayOption.allAppsCellSize; allAppsBorderSpaces = displayOption.allAppsBorderSpaces; allAppsIconSize = displayOption.allAppsIconSizes; allAppsIconTextSize = displayOption.allAppsIconTextSizes; @@ -798,6 +800,7 @@ public class InvariantDeviceProfile { private final float[] iconSizes = new float[COUNT_SIZES]; private final float[] textSizes = new float[COUNT_SIZES]; + private final PointF[] allAppsCellSize = new PointF[COUNT_SIZES]; private final float[] allAppsIconSizes = new float[COUNT_SIZES]; private final float[] allAppsIconTextSizes = new float[COUNT_SIZES]; private final PointF[] allAppsBorderSpaces = new PointF[COUNT_SIZES]; @@ -873,9 +876,35 @@ public class InvariantDeviceProfile { folderBorderSpace = borderSpace; + x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidth, + minCellSize[INDEX_DEFAULT].x); + y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeight, + minCellSize[INDEX_DEFAULT].y); + allAppsCellSize[INDEX_DEFAULT] = new PointF(x, y); + + x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthLandscape, + allAppsCellSize[INDEX_DEFAULT].x); + y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightLandscape, + allAppsCellSize[INDEX_DEFAULT].y); + allAppsCellSize[INDEX_LANDSCAPE] = new PointF(x, y); + + x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelPortrait, + allAppsCellSize[INDEX_DEFAULT].x); + y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelPortrait, + allAppsCellSize[INDEX_DEFAULT].y); + allAppsCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y); + + x = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellWidthTwoPanelLandscape, + allAppsCellSize[INDEX_DEFAULT].x); + y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellHeightTwoPanelLandscape, + 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( R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait, @@ -971,6 +1000,7 @@ public class InvariantDeviceProfile { textSizes[i] = 0; borderSpaces[i] = new PointF(); minCellSize[i] = new PointF(); + allAppsCellSize[i] = new PointF(); allAppsIconSizes[i] = 0; allAppsIconTextSizes[i] = 0; allAppsBorderSpaces[i] = new PointF(); @@ -987,6 +1017,8 @@ public class InvariantDeviceProfile { minCellSize[i].y *= w; horizontalMargin[i] *= w; hotseatBorderSpaces[i] *= w; + allAppsCellSize[i].x *= w; + allAppsCellSize[i].y *= w; allAppsIconSizes[i] *= w; allAppsIconTextSizes[i] *= w; allAppsBorderSpaces[i].x *= w; @@ -1008,6 +1040,8 @@ public class InvariantDeviceProfile { minCellSize[i].y += p.minCellSize[i].y; horizontalMargin[i] += p.horizontalMargin[i]; hotseatBorderSpaces[i] += p.hotseatBorderSpaces[i]; + allAppsCellSize[i].x += p.allAppsCellSize[i].x; + allAppsCellSize[i].y += p.allAppsCellSize[i].y; allAppsIconSizes[i] += p.allAppsIconSizes[i]; allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i]; allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x; diff --git a/tests/src/com/android/launcher3/DeviceProfileTest.kt b/tests/src/com/android/launcher3/DeviceProfileTest.kt index 75ad21d8aa..d1e91ed072 100644 --- a/tests/src/com/android/launcher3/DeviceProfileTest.kt +++ b/tests/src/com/android/launcher3/DeviceProfileTest.kt @@ -208,6 +208,12 @@ class DeviceProfileTest { PointF(64f, 83f), PointF(64f, 83f) ).toTypedArray() + allAppsCellSize = listOf( + PointF(64f, 83f), + PointF(64f, 83f), + PointF(64f, 83f), + PointF(64f, 83f) + ).toTypedArray() } } } \ No newline at end of file