Improvements for All Apps on different display sizes
Bug: 262912817
Test: DeviceProfileAlternativeDisplaysDumpTest
Change-Id: I50e980183b4d5c1a46cca8f1c867b866b9eae4b5
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 63970cd..92f6881 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -30,6 +30,4 @@
<dimen name="dynamic_grid_edge_margin">11.33dp</dimen>
<dimen name="cell_layout_padding">11.33dp</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 d69e777..0af0603 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -26,7 +26,6 @@
<!-- AllApps -->
<dimen name="all_apps_search_bar_content_overlap">0dp</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 235631d..6362960 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -22,9 +22,6 @@
<dimen name="dynamic_grid_edge_margin">21.93dp</dimen>
<dimen name="cell_layout_padding">29.33dp</dimen>
-<!-- AllApps -->
- <dimen name="all_apps_bottom_sheet_horizontal_padding">32dp</dimen>
-
<!-- Dragging-->
<dimen name="drop_target_top_margin">0dp</dimen>
<dimen name="drop_target_bottom_margin">32dp</dimen>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 09b2d6f..d7a5881 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -18,9 +18,6 @@
<!-- PagedView -->
<dimen name="min_page_snap_velocity">3400dp</dimen>
-<!-- AllApps -->
- <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>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index e6f285c..26180f3 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -151,6 +151,9 @@
<!-- Support attributes in FolderStyle -->
<attr name="folderStyle" format="reference" />
+ <!-- Support attributes in AllAppsStyle. Defaults to AllAppsStyleDefault -->
+ <attr name="allAppsStyle" format="reference" />
+
<!-- numAllAppsColumns defaults to numColumns, if not specified -->
<attr name="numAllAppsColumns" format="integer" />
<!-- Number of columns to use when extending the all-apps size,
@@ -418,6 +421,10 @@
<attr name="iconDrawablePadding" format="dimension" />
</declare-styleable>
+ <declare-styleable name="AllAppsStyle">
+ <attr name="horizontalPadding" format="dimension" />
+ </declare-styleable>
+
<declare-styleable name="ShadowDrawable">
<attr name="android:src" />
<attr name="android:shadowColor" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 321aef5..a9638f9 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -131,7 +131,6 @@
<dimen name="all_apps_content_fade_in_offset">150dp</dimen>
<dimen name="all_apps_tip_bottom_margin">8dp</dimen>
<dimen name="all_apps_height_extra">6dp</dimen>
- <dimen name="all_apps_bottom_sheet_horizontal_padding">0dp</dimen>
<dimen name="all_apps_paged_view_top_padding">40dp</dimen>
<dimen name="all_apps_icon_drawable_padding">8dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6b57532..a0b5570 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -304,4 +304,8 @@
<item name="iconDrawablePadding">7dp</item>
</style>
+ <style name="AllAppsStyleDefault">
+ <item name="horizontalPadding">16dp</item>
+ </style>
+
</resources>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 9f9c6f9..4dd3acc 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -401,6 +401,7 @@
allAppsBorderSpacePx = new Point(
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics),
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics));
+ setupAllAppsStyle(context);
workspacePageIndicatorHeight = res.getDimensionPixelSize(
R.dimen.workspace_page_indicator_height);
@@ -805,9 +806,6 @@
int cellLayoutHorizontalPadding =
(cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2;
if (isTablet) {
- allAppsLeftRightPadding =
- res.getDimensionPixelSize(R.dimen.all_apps_bottom_sheet_horizontal_padding);
-
int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
+ (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1))
+ allAppsLeftRightPadding * 2;
@@ -818,6 +816,20 @@
}
}
+ private void setupAllAppsStyle(Context context) {
+ TypedArray allAppsStyle;
+ if (inv.allAppsStyle != INVALID_RESOURCE_HANDLE) {
+ allAppsStyle = context.obtainStyledAttributes(inv.allAppsStyle,
+ R.styleable.AllAppsStyle);
+ } else {
+ allAppsStyle = context.obtainStyledAttributes(R.style.AllAppsStyleDefault,
+ R.styleable.AllAppsStyle);
+ }
+ allAppsLeftRightPadding = allAppsStyle.getDimensionPixelSize(
+ R.styleable.AllAppsStyle_horizontalPadding, 0);
+ allAppsStyle.recycle();
+ }
+
/**
* Returns the amount of extra (or unused) vertical space.
*/
@@ -1792,7 +1804,7 @@
* Set the viewScaleProvider for the builder
*
* @param viewScaleProvider The viewScaleProvider to be set for the
- * DeviceProfile
+ * DeviceProfile
* @return This builder
*/
@NonNull
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index d97eac9..604c1b8 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -175,6 +175,7 @@
*/
public int numAllAppsColumns;
public int numDatabaseAllAppsColumns;
+ public @StyleRes int allAppsStyle;
/**
* Do not query directly. see {@link DeviceProfile#isScalableGrid}.
@@ -384,6 +385,8 @@
hotseatBarBottomSpace = displayOption.hotseatBarBottomSpace;
hotseatQsbSpace = displayOption.hotseatQsbSpace;
+ allAppsStyle = closestProfile.allAppsStyle;
+
numAllAppsColumns = closestProfile.numAllAppsColumns;
numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
@@ -789,6 +792,7 @@
private final @StyleRes int folderStyle;
private final @StyleRes int cellStyle;
+ private final @StyleRes int allAppsStyle;
private final int numAllAppsColumns;
private final int numDatabaseAllAppsColumns;
private final int numHotseatIcons;
@@ -824,6 +828,8 @@
demoModeLayoutId = a.getResourceId(
R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
+ allAppsStyle = a.getResourceId(R.styleable.GridDisplayOption_allAppsStyle,
+ R.style.AllAppsStyleDefault);
numAllAppsColumns = a.getInt(
R.styleable.GridDisplayOption_numAllAppsColumns, numColumns);
numDatabaseAllAppsColumns = a.getInt(
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index b7d0f28..c434082 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -118,6 +118,7 @@
horizontalMargin = FloatArray(4) { 22f }
+ allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(
PointF(80f, 104f),
@@ -196,6 +197,7 @@
horizontalMargin = floatArrayOf(54f, 120f, 54f, 54f)
+ allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(
PointF(96f, 142f),
@@ -275,6 +277,7 @@
horizontalMargin = floatArrayOf(21.5f, 21.5f, 22.5f, 30.5f)
+ allAppsStyle = R.style.AllAppsStyleDefault
allAppsCellSize =
listOf(PointF(0f, 0f), PointF(0f, 0f), PointF(68f, 104f), PointF(80f, 104f))
.toTypedArray()