From 4eb6dc518d39d17d722b93ab0adf1e8846b908d1 Mon Sep 17 00:00:00 2001 From: Adithya R Date: Tue, 7 Nov 2023 19:19:46 +0530 Subject: [PATCH] Launcher3: Use 2 rows for smartspace in 5x7 grid Otherwise it doesn't fit in most cases. Change-Id: I6b842613e17eeeab1bd8e78846362aa80d26f791 --- res/values/attrs.xml | 2 ++ res/xml/device_profiles.xml | 1 + src/com/android/launcher3/DeviceProfile.java | 2 ++ src/com/android/launcher3/InvariantDeviceProfile.java | 10 ++++++++-- src/com/android/launcher3/Workspace.java | 3 ++- src/com/android/launcher3/model/LoaderCursor.java | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 0fbfeedb2b..8a9af90634 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -146,6 +146,8 @@ + + diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml index 9d793996a8..9f492bc6f3 100644 --- a/res/xml/device_profiles.xml +++ b/res/xml/device_profiles.xml @@ -231,6 +231,7 @@ launcher:name="5_by_7" launcher:numRows="7" launcher:numColumns="5" + launcher:numSearchContainerRows="2" launcher:numFolderRows="6" launcher:numFolderColumns="4" launcher:numHotseatIcons="5" diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index ddefa5da66..eca7286260 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -1590,6 +1590,8 @@ public class DeviceProfile { writer.println(prefix + "\tinv.numRows: " + inv.numRows); writer.println(prefix + "\tinv.numColumns: " + inv.numColumns); + writer.println(prefix + "\tinv.numSearchContainerRows: " + + inv.numSearchContainerRows); writer.println(prefix + "\tinv.numSearchContainerColumns: " + inv.numSearchContainerColumns); diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 8f4a068481..58819cad57 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -128,6 +128,7 @@ public class InvariantDeviceProfile implements OnSharedPreferenceChangeListener */ public int numRows; public int numColumns; + public int numSearchContainerRows; public int numSearchContainerColumns; /** @@ -365,6 +366,7 @@ public class InvariantDeviceProfile implements OnSharedPreferenceChangeListener GridOption closestProfile = displayOption.grid; numRows = closestProfile.numRows; numColumns = closestProfile.numColumns; + numSearchContainerRows = closestProfile.numSearchContainerRows; numSearchContainerColumns = closestProfile.numSearchContainerColumns; dbFile = closestProfile.dbFile; defaultLayoutId = closestProfile.defaultLayoutId; @@ -489,8 +491,9 @@ public class InvariantDeviceProfile implements OnSharedPreferenceChangeListener private Object[] toModelState() { return new Object[]{ - numColumns, numRows, numSearchContainerColumns, numDatabaseHotseatIcons, - iconPack, iconBitmapSize, fillResIconDpi, numDatabaseAllAppsColumns, dbFile}; + numColumns, numRows, numSearchContainerRows, numSearchContainerColumns, + numDatabaseHotseatIcons, iconPack, iconBitmapSize, fillResIconDpi, + numDatabaseAllAppsColumns, dbFile}; } private void onConfigChanged(Context context) { @@ -801,6 +804,7 @@ public class InvariantDeviceProfile implements OnSharedPreferenceChangeListener public final String name; public final int numRows; public final int numColumns; + public final int numSearchContainerRows; public final int numSearchContainerColumns; public final int deviceCategory; @@ -834,6 +838,8 @@ public class InvariantDeviceProfile implements OnSharedPreferenceChangeListener name = a.getString(R.styleable.GridDisplayOption_name); numRows = a.getInt(R.styleable.GridDisplayOption_numRows, 0); numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0); + numSearchContainerRows = a.getInt( + R.styleable.GridDisplayOption_numSearchContainerRows, 1); numSearchContainerColumns = a.getInt( R.styleable.GridDisplayOption_numSearchContainerColumns, numColumns); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 1c79f279ab..18c9309bd4 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -607,7 +607,8 @@ public class Workspace extends PagedView } int cellHSpan = mLauncher.getDeviceProfile().inv.numSearchContainerColumns; - CellLayoutLayoutParams lp = new CellLayoutLayoutParams(0, 0, cellHSpan, 1); + int cellVSpan = mLauncher.getDeviceProfile().inv.numSearchContainerRows; + CellLayoutLayoutParams lp = new CellLayoutLayoutParams(0, 0, cellHSpan, cellVSpan); lp.canReorder = false; if (!firstPage.addViewToCellLayout( mFirstPagePinnedItem, 0, R.id.search_container_workspace, lp, true)) { diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java index c321a6816e..2a68ad76ce 100644 --- a/src/com/android/launcher3/model/LoaderCursor.java +++ b/src/com/android/launcher3/model/LoaderCursor.java @@ -541,7 +541,7 @@ public class LoaderCursor extends CursorWrapper { // occupied (if the feature is enabled) in order to account for the search // container. int spanX = mIDP.numSearchContainerColumns; - int spanY = 1; + int spanY = mIDP.numSearchContainerRows; screen.markCells(0, 0, spanX, spanY, true); } mOccupied.put(item.screenId, screen);