From 6c666fb1961da4e8ee3b1705efe0c6d6fb63ad0c Mon Sep 17 00:00:00 2001 From: alexmang Date: Fri, 24 Jul 2020 21:13:24 -0700 Subject: [PATCH] Add a feature flag to expand smartspace to three rows In order to experiment with presenting more predicted content to the workspace I have added a flag to expand smartspace to two rows. This CL does not include any app relocation. If an app lives in a space the expanded smartspace will occupy, it will be removed from workspace. Change-Id: I38354dc81a34a495828cf7a69ddb04cc137e2e4e --- src/com/android/launcher3/Workspace.java | 9 ++++++++- src/com/android/launcher3/config/FeatureFlags.java | 4 ++++ src/com/android/launcher3/model/LoaderCursor.java | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 98328cf8af..254f9cdabd 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -139,6 +139,10 @@ public class Workspace extends PagedView public static final int DEFAULT_PAGE = 0; + private static final int DEFAULT_SMARTSPACE_HEIGHT = 1; + + private static final int EXPANDED_SMARTSPACE_HEIGHT = 2; + private LayoutTransition mLayoutTransition; @Thunk final WallpaperManager mWallpaperManager; @@ -507,7 +511,10 @@ public class Workspace extends PagedView .inflate(R.layout.search_container_workspace, firstPage, false); } - CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), 1); + int cellVSpan = FeatureFlags.EXPANDED_SMARTSPACE.get() + ? EXPANDED_SMARTSPACE_HEIGHT : DEFAULT_SMARTSPACE_HEIGHT; + CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), + cellVSpan); lp.canReorder = false; if (!firstPage.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true)) { Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout"); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 58b0a87468..7e27dade46 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -185,6 +185,10 @@ public final class FeatureFlags { "ENABLE_MINIMAL_DEVICE", true, "Allow user to toggle minimal device mode in launcher."); + public static final BooleanFlag EXPANDED_SMARTSPACE = new DeviceFlag( + "EXPANDED_SMARTSPACE", false, "Expands smartspace height to two rows. " + + "Any apps occupying the first row will be removed from workspace."); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) { diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java index a27ac2391d..532834eeb8 100644 --- a/src/com/android/launcher3/model/LoaderCursor.java +++ b/src/com/android/launcher3/model/LoaderCursor.java @@ -445,7 +445,8 @@ public class LoaderCursor extends CursorWrapper { if (item.screenId == Workspace.FIRST_SCREEN_ID) { // Mark the first row as occupied (if the feature is enabled) // in order to account for the QSB. - screen.markCells(0, 0, countX + 1, 1, FeatureFlags.QSB_ON_FIRST_SCREEN); + int spanY = FeatureFlags.EXPANDED_SMARTSPACE.get() ? 2 : 1; + screen.markCells(0, 0, countX + 1, spanY, FeatureFlags.QSB_ON_FIRST_SCREEN); } occupied.put(item.screenId, screen); }