Update taskbar to add extra hotseat items instead of recent apps

Removes recents-related code including the divider between it and
hotseat.

Test: manually on device

Fixes: 184366189
Bug: 184789479
Bug: 171917176
Change-Id: I7776c98659ded70f53a49befddcd23c8353c6440
This commit is contained in:
Tony Wickham
2021-04-07 15:24:10 -07:00
parent b87f3cdc1c
commit be282e9bc8
8 changed files with 5 additions and 344 deletions

View File

@@ -25,7 +25,6 @@ import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTR
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.ActivityOptions;
import android.content.ComponentName;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
@@ -56,9 +55,6 @@ import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.WindowManagerWrapper;
import java.util.ArrayList;
import java.util.List;
/**
* Interfaces with Launcher/WindowManager/SystemUI to determine what to show in TaskbarView.
*/
@@ -76,17 +72,11 @@ public class TaskbarController {
private final TaskbarStateHandler mTaskbarStateHandler;
private final TaskbarAnimationController mTaskbarAnimationController;
private final TaskbarHotseatController mHotseatController;
private final TaskbarRecentsController mRecentsController;
private final TaskbarDragController mDragController;
// Initialized in init().
private WindowManager.LayoutParams mWindowLayoutParams;
// Contains all loaded Tasks, not yet deduped from Hotseat items.
private List<Task> mLatestLoadedRecentTasks;
// Contains all loaded Hotseat items.
private ItemInfo[] mLatestLoadedHotseatItems;
private @Nullable Animator mAnimator;
private boolean mIsAnimatingToLauncher;
@@ -106,8 +96,6 @@ public class TaskbarController {
createTaskbarAnimationControllerCallbacks());
mHotseatController = new TaskbarHotseatController(mLauncher,
createTaskbarHotseatControllerCallbacks());
mRecentsController = new TaskbarRecentsController(mLauncher,
createTaskbarRecentsControllerCallbacks());
mDragController = new TaskbarDragController(mLauncher);
}
@@ -220,24 +208,6 @@ public class TaskbarController {
@Override
public void updateHotseatItems(ItemInfo[] hotseatItemInfos) {
mTaskbarViewInApp.updateHotseatItems(hotseatItemInfos);
mLatestLoadedHotseatItems = hotseatItemInfos;
dedupeAndUpdateRecentItems();
}
};
}
private TaskbarRecentsControllerCallbacks createTaskbarRecentsControllerCallbacks() {
return new TaskbarRecentsControllerCallbacks() {
@Override
public void updateRecentItems(ArrayList<Task> recentTasks) {
mLatestLoadedRecentTasks = recentTasks;
dedupeAndUpdateRecentItems();
}
@Override
public void updateRecentTaskAtIndex(int taskIndex, Task task) {
mTaskbarViewInApp.updateRecentTaskAtIndex(taskIndex, task);
mTaskbarViewOnHome.updateRecentTaskAtIndex(taskIndex, task);
}
};
}
@@ -246,16 +216,13 @@ public class TaskbarController {
* Initializes the Taskbar, including adding it to the screen.
*/
public void init() {
mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons(),
mRecentsController.getNumRecentIcons());
mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons(),
mRecentsController.getNumRecentIcons());
mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons());
mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons());
mTaskbarContainerView.init(mTaskbarViewInApp);
addToWindowManager();
mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks());
mTaskbarAnimationController.init();
mHotseatController.init();
mRecentsController.init();
setWhichTaskbarViewIsVisible(mLauncher.hasBeenResumed()
? mTaskbarViewOnHome
@@ -292,7 +259,6 @@ public class TaskbarController {
mTaskbarStateHandler.setTaskbarCallbacks(null);
mTaskbarAnimationController.cleanup();
mHotseatController.cleanup();
mRecentsController.cleanup();
setWhichTaskbarViewIsVisible(null);
}
@@ -425,53 +391,6 @@ public class TaskbarController {
return mTaskbarViewInApp.isDraggingItem() || mTaskbarViewOnHome.isDraggingItem();
}
private void dedupeAndUpdateRecentItems() {
if (mLatestLoadedRecentTasks == null || mLatestLoadedHotseatItems == null) {
return;
}
final int numRecentIcons = mRecentsController.getNumRecentIcons();
// From most recent to least recently opened.
List<Task> dedupedTasksInDescendingOrder = new ArrayList<>();
for (int i = mLatestLoadedRecentTasks.size() - 1; i >= 0; i--) {
Task task = mLatestLoadedRecentTasks.get(i);
boolean isTaskInHotseat = false;
for (ItemInfo hotseatItem : mLatestLoadedHotseatItems) {
if (hotseatItem == null) {
continue;
}
ComponentName hotseatActivity = hotseatItem.getTargetComponent();
if (hotseatActivity != null && task.key.sourceComponent.getPackageName()
.equals(hotseatActivity.getPackageName())) {
isTaskInHotseat = true;
break;
}
}
if (!isTaskInHotseat) {
dedupedTasksInDescendingOrder.add(task);
if (dedupedTasksInDescendingOrder.size() == numRecentIcons) {
break;
}
}
}
// TaskbarView expects an array of all the recent tasks to show, in the order to show them.
// So we create an array of the proper size, then fill it in such that the most recent items
// are at the end. If there aren't enough elements to fill the array, leave them null.
Task[] tasksArray = new Task[numRecentIcons];
for (int i = 0; i < tasksArray.length; i++) {
Task task = i >= dedupedTasksInDescendingOrder.size()
? null
: dedupedTasksInDescendingOrder.get(i);
tasksArray[tasksArray.length - 1 - i] = task;
}
mTaskbarViewInApp.updateRecentTasks(tasksArray);
mTaskbarViewOnHome.updateRecentTasks(tasksArray);
mRecentsController.loadIconsForTasks(tasksArray);
}
/**
* @return Whether the given View is in the same window as Taskbar.
*/
@@ -573,12 +492,4 @@ public class TaskbarController {
protected interface TaskbarHotseatControllerCallbacks {
void updateHotseatItems(ItemInfo[] hotseatItemInfos);
}
/**
* Contains methods that TaskbarRecentsController can call to interface with TaskbarController.
*/
protected interface TaskbarRecentsControllerCallbacks {
void updateRecentItems(ArrayList<Task> recentTasks);
void updateRecentTaskAtIndex(int taskIndex, Task task);
}
}