From ff16a5912d54ebcc374836689fe6444e353f7c0c Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Thu, 8 May 2025 03:34:15 +0000 Subject: [PATCH] Use dimen for GridSize_minDeviceWidth/Height Makes the grid size format more flexible, as it allows the min width and height to be easily defined either as px, or dp (which may be preferable for upcoming desktop grids - I noticed that scaling display size may end up with too tightly packed grid when using pixel sizes to select the correct grid size). Test: Existing tests Bug: 375643744 Flag: EXEMPT cleanup Change-Id: I09b772ece177fe0539a1ff641ff2391e88d9e289 --- res/values/attrs.xml | 4 ++-- res/xml/spec_col_count_3_row.xml | 10 +++++----- src/com/android/launcher3/InvariantDeviceProfile.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 0a1efc1635..6a37816504 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -177,8 +177,8 @@ - - + + diff --git a/res/xml/spec_col_count_3_row.xml b/res/xml/spec_col_count_3_row.xml index bbde54297f..e0ef5c1915 100644 --- a/res/xml/spec_col_count_3_row.xml +++ b/res/xml/spec_col_count_3_row.xml @@ -19,15 +19,15 @@ launcher:numGridRows="3" launcher:dbFile="launcher_7_by_3.db" launcher:defaultLayoutId="@xml/default_workspace_7x3" - launcher:minDeviceWidthPx="0" - launcher:minDeviceHeightPx="0" + launcher:minDeviceWidth="0px" + launcher:minDeviceHeight="0px" /> - \ No newline at end of file + diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index f963913db1..9991c8c5ee 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -1209,8 +1209,8 @@ public class InvariantDeviceProfile { mNumRows = (int) a.getFloat(R.styleable.GridSize_numGridRows, 0); mNumColumns = (int) a.getFloat(R.styleable.GridSize_numGridColumns, 0); - mMinDeviceWidthPx = a.getFloat(R.styleable.GridSize_minDeviceWidthPx, 0); - mMinDeviceHeightPx = a.getFloat(R.styleable.GridSize_minDeviceHeightPx, 0); + mMinDeviceWidthPx = a.getDimensionPixelSize(R.styleable.GridSize_minDeviceWidth, 0); + mMinDeviceHeightPx = a.getDimensionPixelSize(R.styleable.GridSize_minDeviceHeight, 0); mDbFile = a.getString(R.styleable.GridSize_dbFile); mDefaultLayoutId = a.getResourceId( R.styleable.GridSize_defaultLayoutId, 0);