Sort grid options in onegrid
We need to make sure that the new grid options are sorted by column
count from greatest to least
Bug: 395086953
Flag: com.android.launcher3.one_grid_specs
Test: manually verified
Change-Id: I94fbf0fe74fa7dfc92afc64be92cdf511b79e763
diff --git a/src/com/android/launcher3/graphics/GridCustomizationsProvider.java b/src/com/android/launcher3/graphics/GridCustomizationsProvider.java
index 80743af..b65e744 100644
--- a/src/com/android/launcher3/graphics/GridCustomizationsProvider.java
+++ b/src/com/android/launcher3/graphics/GridCustomizationsProvider.java
@@ -55,6 +55,8 @@
import java.lang.ref.WeakReference;
import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -177,7 +179,13 @@
KEY_NAME, KEY_GRID_TITLE, KEY_ROWS, KEY_COLS, KEY_PREVIEW_COUNT,
KEY_IS_DEFAULT, KEY_GRID_ICON_ID});
InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(getContext());
- for (GridOption gridOption : idp.parseAllGridOptions(getContext())) {
+ List<GridOption> gridOptionList = idp.parseAllGridOptions(getContext());
+ if (com.android.launcher3.Flags.oneGridSpecs()) {
+ gridOptionList.sort(Comparator
+ .comparingInt((GridOption option) -> option.numColumns)
+ .reversed());
+ }
+ for (GridOption gridOption : gridOptionList) {
cursor.newRow()
.add(KEY_NAME, gridOption.name)
.add(KEY_GRID_TITLE, gridOption.gridTitle)