Merge "Change size of All Apps bottom sheet" into tm-dev
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 6c5be91..daca048 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -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>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 501ead6..73edc6f 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -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>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 33da4a1..eb5c751 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -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>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index b4c8837..3ec211a 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -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>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 4ed31f8..c96a228 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -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" />
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 96e0913..009ee27 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -624,14 +624,15 @@
+ 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 @@
* 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 @@
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 9dd1493..219ed9e 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -128,6 +128,7 @@
public float[] horizontalMargin;
+ public PointF[] allAppsCellSize;
public float[] allAppsIconSize;
public float[] allAppsIconTextSize;
public PointF[] allAppsBorderSpaces;
@@ -357,6 +358,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 75ad21d..d1e91ed 100644
--- a/tests/src/com/android/launcher3/DeviceProfileTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileTest.kt
@@ -208,6 +208,12 @@
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