Fixing workspace screens not including page 0

Instead of maintaining a workspace screen array, calculating it from
the current set of items as needed.

Bug: 122262946
Bug: 119500058
Change-Id: I85bb0e55a4442ab9bcac390a601da0cb2583c26a
This commit is contained in:
Sunny Goyal committed 2019-01-07 12:14:06 -08:00
1 parent e0c927a50b
commit c3f4dc6c6a
4 files changed
+31 -34

No files matched your search

@@ -27,6 +27,7 @@ import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.DumpTargetWrapper;
import com.android.launcher3.model.nano.LauncherDumpProto;
@@ -37,6 +38,7 @@ import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.IntSparseArrayMap;
import com.google.protobuf.nano.MessageNano;
@@ -80,11 +82,6 @@ public class BgDataModel {
*/
public final IntSparseArrayMap<FolderInfo> folders = new IntSparseArrayMap<>();
/**
* Ordered list of workspace screens ids.
*/
public final IntArray workspaceScreens = new IntArray();
/**
* Map of ShortcutKey to the number of times it is pinned.
*/
@@ -118,11 +115,26 @@ public class BgDataModel {
appWidgets.clear();
folders.clear();
itemsIdMap.clear();
workspaceScreens.clear();
pinnedShortcutCounts.clear();
deepShortcutMap.clear();
}
/**
* Creates an array of valid workspace screens based on current items in the model.
*/
public synchronized IntArray collectWorkspaceScreens() {
IntSet screenSet = new IntSet();
for (ItemInfo item: itemsIdMap) {
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
screenSet.add(item.screenId);
}
}
if (FeatureFlags.QSB_ON_FIRST_SCREEN.get() || screenSet.isEmpty()) {
screenSet.add(Workspace.FIRST_SCREEN_ID);
}
return screenSet.getArray();
}
public synchronized void dump(String prefix, FileDescriptor fd, PrintWriter writer,
String[] args) {
if (Arrays.asList(args).contains("--proto")) {
@@ -130,11 +142,6 @@ public class BgDataModel {
return;
}
writer.println(prefix + "Data Model:");
writer.print(prefix + " ---- workspace screens: ");
for (int i = 0; i < workspaceScreens.size(); i++) {
writer.print(" " + workspaceScreens.get(i));
}
writer.println();
writer.println(prefix + " ---- workspace items ");
for (int i = 0; i < workspaceItems.size(); i++) {
writer.println(prefix + '\t' + workspaceItems.get(i).toString());
@@ -167,6 +174,7 @@ public class BgDataModel {
// Add top parent nodes. (L1)
DumpTargetWrapper hotseat = new DumpTargetWrapper(ContainerType.HOTSEAT, 0);
IntSparseArrayMap<DumpTargetWrapper> workspaces = new IntSparseArrayMap<>();
IntArray workspaceScreens = collectWorkspaceScreens();
for (int i = 0; i < workspaceScreens.size(); i++) {
workspaces.put(workspaceScreens.get(i),
new DumpTargetWrapper(ContainerType.WORKSPACE, i));