Merge "Change size of All Apps bottom sheet" into tm-dev am: 042482e94c

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17154983

Change-Id: Ie248b0bb7789e1d3548b87e87e8374a6b67d3fc2
This commit is contained in:
Thales Lima
2022-03-22 15:45:11 +00:00
committed by Automerger Merge Worker
8 changed files with 89 additions and 13 deletions
+6 -3
View File
@@ -16,14 +16,17 @@
-->
<resources>
<!-- Hotseat -->
<!-- Hotseat -->
<dimen name="spring_loaded_hotseat_top_margin">44dp</dimen>
<!-- Dynamic grid -->
<!-- Dynamic grid -->
<dimen name="dynamic_grid_edge_margin">11.33dp</dimen>
<dimen name="cell_layout_padding">11.33dp</dimen>
<!-- Dragging -->
<!-- Dragging -->
<dimen name="drop_target_top_margin">0dp</dimen>
<dimen name="drop_target_bottom_margin">16dp</dimen>
<!-- AllApps -->
<dimen name="all_apps_bottom_sheet_horizontal_padding">52dp</dimen>
</resources>
+1 -1
View File
@@ -23,7 +23,7 @@
<!-- AllApps -->
<dimen name="all_apps_search_bar_content_overlap">0dp</dimen>
<dimen name="all_apps_bottom_sheet_horizontal_padding">46dp</dimen>
<dimen name="all_apps_bottom_sheet_horizontal_padding">48dp</dimen>
<!-- Fast scroll -->
<dimen name="fastscroll_popup_width">75dp</dimen>
+7
View File
@@ -18,13 +18,20 @@
<!-- Dragging-->
<dimen name="drop_target_top_margin">0dp</dimen>
<dimen name="drop_target_bottom_margin">32dp</dimen>
<!-- Dynamic grid -->
<dimen name="dynamic_grid_edge_margin">21.93dp</dimen>
<dimen name="cell_layout_padding">29.33dp</dimen>
<!-- Hotseat -->
<dimen name="spring_loaded_hotseat_top_margin">64dp</dimen>
<!-- AllApps -->
<dimen name="all_apps_bottom_sheet_horizontal_padding">32dp</dimen>
<!-- Widget picker-->
<dimen name="widget_list_horizontal_margin">49dp</dimen>
<!-- Bottom sheet-->
<dimen name="bottom_sheet_extra_top_padding">0dp</dimen>
</resources>
+4 -1
View File
@@ -16,10 +16,12 @@
<resources>
<!-- AllApps -->
<dimen name="all_apps_bottom_sheet_horizontal_padding">65dp</dimen>
<dimen name="all_apps_bottom_sheet_horizontal_padding">28dp</dimen>
<!-- Dynamic grid -->
<dimen name="dynamic_grid_edge_margin">27.59dp</dimen>
<dimen name="cell_layout_padding">36dp</dimen>
<!-- Dragging -->
<dimen name="drop_target_text_size">20sp</dimen>
<dimen name="dynamic_grid_drop_target_size">72dp</dimen>
@@ -28,6 +30,7 @@
<dimen name="drop_target_button_gap">32dp</dimen>
<dimen name="drop_target_top_margin">32dp</dimen>
<dimen name="drop_target_bottom_margin">32dp</dimen>
<!-- Hotseat -->
<dimen name="spring_loaded_hotseat_top_margin">164dp</dimen>
+19
View File
@@ -241,9 +241,28 @@
if not specified -->
<attr name="borderSpaceTwoPanelLandscapeVertical" format="float" />
<!-- These min cell values are only used if GridDisplayOption#isScalable is true -->
<!-- defaults to minCellHeight, if not specified -->
<attr name="allAppsCellHeight" format="float" />
<!-- defaults to minCellWidth, if not specified -->
<attr name="allAppsCellWidth" format="float" />
<!-- defaults to allAppsCellHeight, if not specified -->
<attr name="allAppsCellHeightLandscape" format="float" />
<!-- defaults to allAppsCellWidth, if not specified -->
<attr name="allAppsCellWidthLandscape" format="float" />
<!-- defaults to allAppsCellHeight, if not specified -->
<attr name="allAppsCellHeightTwoPanelPortrait" format="float" />
<!-- defaults to allAppsCellWidth, if not specified -->
<attr name="allAppsCellWidthTwoPanelPortrait" format="float" />
<!-- defaults to allAppsCellHeight, if not specified -->
<attr name="allAppsCellHeightTwoPanelLandscape" format="float" />
<!-- defaults to allAppsCellWidth, if not specified -->
<attr name="allAppsCellWidthTwoPanelLandscape" format="float" />
<!-- defaults to borderSpace, if not specified -->
<attr name="allAppsBorderSpace" format="float" />
<!-- defaults to allAppsBorderSpace, if not specified -->
<attr name="allAppsBorderSpaceLandscape" format="float" />
<!-- defaults to allAppsBorderSpace, if not specified -->
<attr name="allAppsBorderSpaceTwoPanelPortrait" format="float" />
<!-- defaults to allAppsBorderSpace, if not specified -->
<attr name="allAppsBorderSpaceTwoPanelLandscape" format="float" />
+12 -8
View File
@@ -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));
@@ -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;
@@ -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()
}
}
}