From d852d6569352427959be4141b289191372d4c568 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Tue, 17 Jan 2023 14:01:13 +0000 Subject: [PATCH] Create attr for padding between icon and text in cells Bug: 265210314 Test: DeviceProfileDumpTest Change-Id: I00af790d0c21c35f1cbce1362e63d3ab8259244a Merged-In: I00af790d0c21c35f1cbce1362e63d3ab8259244a --- res/values-land/styles.xml | 21 ++++++++++++++++ res/values/attrs.xml | 11 ++++++-- res/values/styles.xml | 6 ++++- src/com/android/launcher3/DeviceProfile.java | 25 +++++++++++++------ .../launcher3/InvariantDeviceProfile.java | 8 ++++++ .../launcher3/DeviceProfileBaseTest.kt | 6 ++--- 6 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 res/values-land/styles.xml diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml new file mode 100644 index 0000000000..52474dac52 --- /dev/null +++ b/res/values-land/styles.xml @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 08561d5d51..e6f285ca32 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -142,9 +142,13 @@ + + + + @@ -387,7 +391,7 @@ - + @@ -402,7 +406,6 @@ - @@ -411,6 +414,10 @@ + + + + diff --git a/res/values/styles.xml b/res/values/styles.xml index 7582a30435..dfff92692f 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -293,7 +293,7 @@ true - + + diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 8391b91c43..9f9c6f9937 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -376,19 +376,19 @@ public class DeviceProfile { 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 @@ public class DeviceProfile { 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 ffe81ad2aa..d97eac94fb 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -143,6 +143,8 @@ public class InvariantDeviceProfile { public @StyleRes int folderStyle; + public @StyleRes int cellStyle; + public float[] horizontalMargin; public PointF[] allAppsCellSize; @@ -349,6 +351,8 @@ public class InvariantDeviceProfile { numFolderColumns = closestProfile.numFolderColumns; folderStyle = closestProfile.folderStyle; + cellStyle = closestProfile.cellStyle; + isScalable = closestProfile.isScalable; devicePaddingId = closestProfile.devicePaddingId; this.deviceType = deviceType; @@ -783,6 +787,7 @@ public class InvariantDeviceProfile { 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 @@ public class InvariantDeviceProfile { 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 2da5eeebab..b7d0f2856f 100644 --- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt +++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt @@ -112,7 +112,7 @@ abstract class DeviceProfileBaseTest { numFolderRows = 3 numFolderColumns = 3 - folderStyle = R.style.FolderDefaultStyle + folderStyle = R.style.FolderStyleDefault inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split @@ -190,7 +190,7 @@ abstract class DeviceProfileBaseTest { numFolderRows = 3 numFolderColumns = 3 - folderStyle = R.style.FolderDefaultStyle + folderStyle = R.style.FolderStyleDefault inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_6_5 @@ -269,7 +269,7 @@ abstract class DeviceProfileBaseTest { numFolderRows = 3 numFolderColumns = 3 - folderStyle = R.style.FolderDefaultStyle + folderStyle = R.style.FolderStyleDefault inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split