Moving predicted items to ItemIdMap instead of extraItems

> This allows the whole workspace model to be contained in itemIdMap instead of spread across multiple data containers
> Deprecating extraItems, all non-workspace data should use separate repositories
> Design: http://go/launchermodel-re-arch?#heading=h.5y8n4r164d5s

Bug: 390572144
Test: atest PredictionUpdateTaskTest
Flag: EXEMPT refactor
Change-Id: I886d0a8d5bbbf9f5c2054d4a2442bf03f9c4eab5
This commit is contained in:
Sunny Goyal committed 2025-05-05 15:52:37 -07:00
1 parent cf29edfa2f
commit aef6c7932e
31 files changed
+419 -228

No files matched your search

@@ -15,6 +15,7 @@
*/
package com.android.launcher3.taskbar;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
@@ -28,10 +29,9 @@ import androidx.annotation.UiThread;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.celllayout.CellInfo;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.PredictedContainerInfo;
import com.android.launcher3.taskbar.TaskbarView.TaskbarLayoutParams;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.IntSparseArrayMap;
@@ -79,18 +79,14 @@ public class TaskbarModelCallbacks implements
}
@Override
public void bindCompleteModel(IntSparseArrayMap<ItemInfo> itemIdMap,
List<FixedContainerItems> extraItems, StringCache stringCache, boolean isBindingSync) {
public void bindCompleteModel(IntSparseArrayMap<ItemInfo> itemIdMap, boolean isBindingSync) {
mHotseatItems.clear();
mPredictedItems = Collections.emptyList();
mPredictedItems = itemIdMap.get(CONTAINER_HOTSEAT_PREDICTION)
instanceof PredictedContainerInfo pci ? pci.getContents() : Collections.emptyList();
handleItemsAdded(itemIdMap);
for (FixedContainerItems item: extraItems) {
if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION) {
mPredictedItems = item.items;
} else if (item.containerId == Favorites.CONTAINER_ALL_APPS_PREDICTION) {
mControllers.taskbarAllAppsController.setPredictedApps(item.items);
}
if (itemIdMap.get(CONTAINER_ALL_APPS_PREDICTION) instanceof PredictedContainerInfo pci) {
mControllers.taskbarAllAppsController.setPredictedApps(pci.getContents());
}
commitItemsToUI();
}
@@ -114,12 +110,23 @@ public class TaskbarModelCallbacks implements
}
@Override
public void bindItemsUpdated(Set<ItemInfo> updates) {
public void bindItemsUpdated(@NonNull Set<ItemInfo> updates) {
Set<ItemInfo> itemsToRebind = updateContainerItems(updates, mContext);
boolean removed = handleItemsRemoved(ItemInfoMatcher.ofItems(itemsToRebind));
boolean added = handleItemsAdded(itemsToRebind);
if (removed || added) {
boolean predictionsUpdated = false;
for (ItemInfo update: updates) {
if (update instanceof PredictedContainerInfo pci) {
if (pci.id == Favorites.CONTAINER_HOTSEAT_PREDICTION) {
mPredictedItems = pci.getContents();
predictionsUpdated = true;
} else if (pci.id == CONTAINER_ALL_APPS_PREDICTION) {
mControllers.taskbarAllAppsController.setPredictedApps(pci.getContents());
}
}
}
if (removed || added || predictionsUpdated) {
commitItemsToUI();
}
}
@@ -165,16 +172,6 @@ public class TaskbarModelCallbacks implements
return modified;
}
@Override
public void bindExtraContainerItems(FixedContainerItems item) {
if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION) {
mPredictedItems = item.items;
commitItemsToUI();
} else if (item.containerId == Favorites.CONTAINER_ALL_APPS_PREDICTION) {
mControllers.taskbarAllAppsController.setPredictedApps(item.items);
}
}
private void commitItemsToUI() {
ItemInfo[] hotseatItemInfos =
new ItemInfo[mContext.getDeviceProfile().numShownHotseatIcons];