Create attr for padding between icon and text in cells
Bug: 265210314
Test: DeviceProfileDumpTest
Change-Id: I00af790d0c21c35f1cbce1362e63d3ab8259244a
Merged-In: I00af790d0c21c35f1cbce1362e63d3ab8259244a
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
new file mode 100644
index 0000000..52474da
--- /dev/null
+++ b/res/values-land/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+ <style name="CellStyleDefault">
+ <item name="iconDrawablePadding">4dp</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 08561d5..e6f285c 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -142,9 +142,13 @@
<!-- numSearchContainerColumns defaults to numColumns, if not specified -->
<attr name="numSearchContainerColumns" format="integer" />
+ <!-- Support attributes in CellStyle. defaults to CellStyleDefault -->
+ <attr name="cellStyle" format="reference" />
+
<!-- numFolderRows & numFolderColumns defaults to numRows & numColumns, if not specified -->
<attr name="numFolderRows" format="integer" />
<attr name="numFolderColumns" format="integer" />
+ <!-- Support attributes in FolderStyle -->
<attr name="folderStyle" format="reference" />
<!-- numAllAppsColumns defaults to numColumns, if not specified -->
@@ -387,7 +391,7 @@
</declare-styleable>
- <declare-styleable name="FolderDisplayStyle">
+ <declare-styleable name="FolderStyle">
<!-- defaults to minCellHeight if not specified
when GridDisplayOption#isScalable is true. -->
<attr name="folderCellHeight" format="dimension" />
@@ -402,7 +406,6 @@
<attr name="folderTopPadding" format="dimension" />
</declare-styleable>
-
<declare-styleable name="CellLayout">
<attr name="containerType" format="integer">
<enum name="workspace" value="0" />
@@ -411,6 +414,10 @@
</attr>
</declare-styleable>
+ <declare-styleable name="CellStyle">
+ <attr name="iconDrawablePadding" format="dimension" />
+ </declare-styleable>
+
<declare-styleable name="ShadowDrawable">
<attr name="android:src" />
<attr name="android:shadowColor" />
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 7582a30..dfff926 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -293,7 +293,7 @@
<item name="android:windowTranslucentStatus">true</item>
</style>
- <style name="FolderDefaultStyle">
+ <style name="FolderStyleDefault">
<item name="folderTopPadding">24dp</item>
<item name="folderCellHeight">94dp</item>
<item name="folderCellWidth">80dp</item>
@@ -301,4 +301,8 @@
<item name="folderFooterHeight">56dp</item>
</style>
+ <style name="CellStyleDefault">
+ <item name="iconDrawablePadding">7dp</item>
+ </style>
+
</resources>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 8391b91..9f9c6f9 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -376,19 +376,19 @@
if (inv.folderStyle != INVALID_RESOURCE_HANDLE) {
TypedArray folderStyle = context.obtainStyledAttributes(inv.folderStyle,
- R.styleable.FolderDisplayStyle);
+ R.styleable.FolderStyle);
// These are re-set in #updateFolderCellSize if the grid is not scalable
folderCellHeightPx = folderStyle.getDimensionPixelSize(
- R.styleable.FolderDisplayStyle_folderCellHeight, 0);
+ R.styleable.FolderStyle_folderCellHeight, 0);
folderCellWidthPx = folderStyle.getDimensionPixelSize(
- R.styleable.FolderDisplayStyle_folderCellWidth, 0);
+ R.styleable.FolderStyle_folderCellWidth, 0);
folderContentPaddingTop = folderStyle.getDimensionPixelSize(
- R.styleable.FolderDisplayStyle_folderTopPadding, 0);
+ R.styleable.FolderStyle_folderTopPadding, 0);
folderCellLayoutBorderSpacePx = folderStyle.getDimensionPixelSize(
- R.styleable.FolderDisplayStyle_folderBorderSpace, 0);
+ R.styleable.FolderStyle_folderBorderSpace, 0);
folderFooterHeightPx = folderStyle.getDimensionPixelSize(
- R.styleable.FolderDisplayStyle_folderFooterHeight, 0);
+ R.styleable.FolderStyle_folderFooterHeight, 0);
folderStyle.recycle();
} else {
folderCellLayoutBorderSpacePx = 0;
@@ -407,8 +407,17 @@
mWorkspacePageIndicatorOverlapWorkspace =
res.getDimensionPixelSize(R.dimen.workspace_page_indicator_overlap_workspace);
- iconDrawablePaddingOriginalPx =
- res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
+ TypedArray cellStyle;
+ if (inv.cellStyle != INVALID_RESOURCE_HANDLE) {
+ cellStyle = context.obtainStyledAttributes(inv.cellStyle,
+ R.styleable.CellStyle);
+ } else {
+ cellStyle = context.obtainStyledAttributes(R.style.CellStyleDefault,
+ R.styleable.CellStyle);
+ }
+ iconDrawablePaddingOriginalPx = cellStyle.getDimensionPixelSize(
+ R.styleable.CellStyle_iconDrawablePadding, 0);
+ cellStyle.recycle();
dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);
dropTargetBarTopMarginPx = res.getDimensionPixelSize(R.dimen.drop_target_top_margin);
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index ffe81ad..d97eac9 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -143,6 +143,8 @@
public @StyleRes int folderStyle;
+ public @StyleRes int cellStyle;
+
public float[] horizontalMargin;
public PointF[] allAppsCellSize;
@@ -349,6 +351,8 @@
numFolderColumns = closestProfile.numFolderColumns;
folderStyle = closestProfile.folderStyle;
+ cellStyle = closestProfile.cellStyle;
+
isScalable = closestProfile.isScalable;
devicePaddingId = closestProfile.devicePaddingId;
this.deviceType = deviceType;
@@ -783,6 +787,7 @@
private final int numFolderRows;
private final int numFolderColumns;
private final @StyleRes int folderStyle;
+ private final @StyleRes int cellStyle;
private final int numAllAppsColumns;
private final int numDatabaseAllAppsColumns;
@@ -852,6 +857,9 @@
folderStyle = a.getResourceId(R.styleable.GridDisplayOption_folderStyle,
INVALID_RESOURCE_HANDLE);
+ cellStyle = a.getResourceId(R.styleable.GridDisplayOption_cellStyle,
+ R.style.CellStyleDefault);
+
isScalable = a.getBoolean(
R.styleable.GridDisplayOption_isScalable, false);
devicePaddingId = a.getResourceId(
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index 2da5eee..b7d0f28 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -112,7 +112,7 @@
numFolderRows = 3
numFolderColumns = 3
- folderStyle = R.style.FolderDefaultStyle
+ folderStyle = R.style.FolderStyleDefault
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split
@@ -190,7 +190,7 @@
numFolderRows = 3
numFolderColumns = 3
- folderStyle = R.style.FolderDefaultStyle
+ folderStyle = R.style.FolderStyleDefault
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_6_5
@@ -269,7 +269,7 @@
numFolderRows = 3
numFolderColumns = 3
- folderStyle = R.style.FolderDefaultStyle
+ folderStyle = R.style.FolderStyleDefault
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split