Load and draw Recent/Running tasks that aren't in Hotseat

- Re-support GroupTask as a tag on TaskbarView BubbleTextViews
- Can tap to launch (startActivityFromRecents) or drag and drop
- Move divider when enable_recents_in_taskbar is true

Behavior:
- While in Desktop mode, all open tasks show up in TaskbarView,
  either in the Hotseat section or the Running apps section
  past the divider. Each one also has a running line indicator.
- While in Fullscreen mode, up to 2 Recent apps that are not
  part of Hotseat will be added to the right of the divider.

Flag: com.android.launcher3.enable_recents_in_taskbar
Test: TaskbarRecentAppsControllerTest
Bug: 315354060
Change-Id: I2e2870cca434b51f276a701860edb32069109159
This commit is contained in:
Tony Wickham
2024-05-23 22:30:46 +00:00
parent 7c7c90528d
commit c5995c8f6d
8 changed files with 399 additions and 50 deletions
@@ -70,6 +70,8 @@ import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiTranslateDelegate;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.views.IconButtonView;
import com.android.quickstep.util.GroupTask;
import com.android.systemui.shared.recents.model.Task;
import java.io.PrintWriter;
import java.util.Set;
@@ -519,21 +521,31 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
for (View iconView : getIconViews()) {
if (iconView instanceof BubbleTextView btv) {
btv.updateRunningState(
getRunningAppState(btv.getTargetPackageName(), runningPackages,
minimizedPackages));
getRunningAppState(btv, runningPackages, minimizedPackages));
}
}
}
private BubbleTextView.RunningAppState getRunningAppState(
String packageName,
BubbleTextView btv,
Set<String> runningPackages,
Set<String> minimizedPackages) {
if (minimizedPackages.contains(packageName)) {
return BubbleTextView.RunningAppState.MINIMIZED;
Object tag = btv.getTag();
if (tag instanceof ItemInfo itemInfo) {
if (minimizedPackages.contains(itemInfo.getTargetPackage())) {
return BubbleTextView.RunningAppState.MINIMIZED;
}
if (runningPackages.contains(itemInfo.getTargetPackage())) {
return BubbleTextView.RunningAppState.RUNNING;
}
}
if (runningPackages.contains(packageName)) {
return BubbleTextView.RunningAppState.RUNNING;
if (tag instanceof GroupTask groupTask && !groupTask.hasMultipleTasks()) {
if (minimizedPackages.contains(groupTask.task1.key.getPackageName())) {
return BubbleTextView.RunningAppState.MINIMIZED;
}
if (runningPackages.contains(groupTask.task1.key.getPackageName())) {
return BubbleTextView.RunningAppState.RUNNING;
}
}
return BubbleTextView.RunningAppState.NOT_RUNNING;
}
@@ -873,6 +885,22 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
mModelCallbacks.commitRunningAppsToUI();
}
/**
* To be called when the given Task is updated, so that we can tell TaskbarView to also update.
* @param task The Task whose e.g. icon changed.
*/
public void onTaskUpdated(Task task) {
// Find the icon view(s) that changed.
for (View view : mTaskbarView.getIconViews()) {
if (view instanceof BubbleTextView btv
&& view.getTag() instanceof GroupTask groupTask) {
if (groupTask.containsTask(task.key.id)) {
mTaskbarView.applyGroupTaskToBubbleTextView(btv, groupTask);
}
}
}
}
@Override
public void dumpLogs(String prefix, PrintWriter pw) {
pw.println(prefix + "TaskbarViewController:");
@@ -892,5 +920,4 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
mModelCallbacks.dumpLogs(prefix + "\t", pw);
}
}