Add running apps icons to taskbar for desktop environment.

This CL adds app icons for launched/running apps to the Launcher
taskbar hotseat. When the activity is closed, the app icon is
removed. The apps that are added to the taskbar on boot are never
removed.

Recall: http://recall/clips/ad6d3cfc-7358-4b37-846e-de843ad3000d

Bug: 183906774
Test: Launch an app and verify the app icon is added on the taskbar.
Close the app and verify the icon is removed from the taskbar.
Test: Switch navigation modes on the emulator and ensure that running
app icons are added to the taskbar after it is reinitialized.
Test: atest NexusLauncherTests:com.android.quickstep.RecentTasksListTest RecentTasksControllerTest

Change-Id: Ieaaf001530b5778871fb7a8d18cdcaa1ccbf0e31
Merged-In: Ieaaf001530b5778871fb7a8d18cdcaa1ccbf0e31
This commit is contained in:
Merissa Tan
2022-01-25 19:46:55 -08:00
committed by Winson Chung
parent f61e7bb4a2
commit 5dbd289f18
10 changed files with 402 additions and 6 deletions

View File

@@ -29,6 +29,7 @@ import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LauncherBindableItemsContainer;
import com.android.quickstep.RecentsModel;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -42,7 +43,7 @@ import java.util.function.Predicate;
* Launcher model Callbacks for rendering taskbar.
*/
public class TaskbarModelCallbacks implements
BgDataModel.Callbacks, LauncherBindableItemsContainer {
BgDataModel.Callbacks, LauncherBindableItemsContainer, RecentsModel.RunningTasksListener {
private final SparseArray<ItemInfo> mHotseatItems = new SparseArray<>();
private List<ItemInfo> mPredictedItems = Collections.emptyList();
@@ -61,6 +62,16 @@ public class TaskbarModelCallbacks implements
public void init(TaskbarControllers controllers) {
mControllers = controllers;
if (mControllers.taskbarRecentAppsController.isEnabled()) {
RecentsModel.INSTANCE.get(mContext).registerRunningTasksListener(this);
}
}
/**
* Unregisters listeners in this class.
*/
public void unregisterListeners() {
RecentsModel.INSTANCE.get(mContext).unregisterRunningTasksListener();
}
@Override
@@ -185,6 +196,8 @@ public class TaskbarModelCallbacks implements
isHotseatEmpty = false;
}
}
hotseatItemInfos = mControllers.taskbarRecentAppsController
.updateHotseatItemInfos(hotseatItemInfos);
mContainer.updateHotseatItems(hotseatItemInfos);
final boolean finalIsHotseatEmpty = isHotseatEmpty;
@@ -195,6 +208,21 @@ public class TaskbarModelCallbacks implements
});
}
@Override
public void onRunningTasksChanged() {
updateRunningApps();
}
/** Called when there's a change in running apps to update the UI. */
public void commitRunningAppsToUI() {
commitItemsToUI();
}
/** Call TaskbarRecentAppsController to update running apps with mHotseatItems. */
public void updateRunningApps() {
mControllers.taskbarRecentAppsController.updateRunningApps(mHotseatItems);
}
@Override
public void bindDeepShortcutMap(HashMap<ComponentKey, Integer> deepShortcutMapCopy) {
mControllers.taskbarPopupController.setDeepShortcutMap(deepShortcutMapCopy);
@@ -203,6 +231,7 @@ public class TaskbarModelCallbacks implements
@Override
public void bindAllApplications(AppInfo[] apps, int flags) {
mControllers.taskbarAllAppsController.setApps(apps, flags);
mControllers.taskbarRecentAppsController.setApps(apps);
}
protected void dumpLogs(String prefix, PrintWriter pw) {