Move split functions from RecentsView to SplitSelectStateController

* Moving things out of RecentsView to avoid
dependency on a non-testable class
* Also helping prevent bloating RecentsView.java

Bug: 266482558
Test: Single Chrome instance in recents. Initiate split
with Chrome from workspace, tap on Chrome again in Taskbar,
ensure no crash.

Change-Id: I99ec704479ffaa860f4d80c2cb9f54182f31f41a
This commit is contained in:
Vinit Nayak committed 2023-02-17 17:28:08 -08:00
1 parent a75105ef03
commit c97bb4600f
5 files changed
+68 -69

No files matched your search

@@ -576,9 +576,9 @@ public class QuickstepLauncher extends Launcher {
RecentsView recentsView = getOverviewPanel();
// Check if there is already an instance of this app running, if so, initiate the split
// using that.
recentsView.findLastActiveTaskAndRunCallback(
mSplitSelectStateController.findLastActiveTaskAndRunCallback(
splitSelectSource.intent.getComponent(),
(Consumer<Task>) foundTask -> {
foundTask -> {
splitSelectSource.alreadyRunningTaskId = foundTask == null
? INVALID_TASK_ID
: foundTask.key.id;
@@ -592,8 +592,7 @@ public class QuickstepLauncher extends Launcher {
}
/** TODO(b/266482558) Migrate into SplitSelectStateController or someplace split specific. */
private void startSplitToHome(
SplitSelectSource source) {
private void startSplitToHome(SplitSelectSource source) {
AbstractFloatingView.closeAllOpenViews(this);
int splitPlaceholderSize = getResources().getDimensionPixelSize(
R.dimen.split_placeholder_size);
@@ -601,14 +600,14 @@ public class QuickstepLauncher extends Launcher {
R.dimen.split_placeholder_inset);
Rect tempRect = new Rect();
SplitSelectStateController controller = getSplitSelectStateController();
controller.setInitialTaskSelect(source.intent, source.position.stagePosition,
source.itemInfo, source.splitEvent, source.alreadyRunningTaskId);
mSplitSelectStateController.setInitialTaskSelect(source.intent,
source.position.stagePosition, source.itemInfo, source.splitEvent,
source.alreadyRunningTaskId);
RecentsView recentsView = getOverviewPanel();
recentsView.getPagedOrientationHandler().getInitialSplitPlaceholderBounds(
splitPlaceholderSize, splitPlaceholderInset, getDeviceProfile(),
controller.getActiveSplitStagePosition(), tempRect);
mSplitSelectStateController.getActiveSplitStagePosition(), tempRect);
PendingAnimation anim = new PendingAnimation(TABLET_HOME_TO_SPLIT.getDuration());
RectF startingTaskRect = new RectF();
@@ -617,12 +616,12 @@ public class QuickstepLauncher extends Launcher {
floatingTaskView.setAlpha(1);
floatingTaskView.addStagingAnimation(anim, startingTaskRect, tempRect,
false /* fadeWithThumbnail */, true /* isStagedTask */);
controller.setFirstFloatingTaskView(floatingTaskView);
mSplitSelectStateController.setFirstFloatingTaskView(floatingTaskView);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
getDragLayer().removeView(floatingTaskView);
controller.resetState();
mSplitSelectStateController.resetState();
}
});
anim.buildAnim().start();
@@ -1153,14 +1152,12 @@ public class QuickstepLauncher extends Launcher {
// Launcher to first restore into Overview state, wait for the relevant tasks and icons to
// load in, and then proceed to OverviewSplitSelect.
if (isInState(OVERVIEW_SPLIT_SELECT)) {
SplitSelectStateController splitSelectStateController =
((RecentsView) getOverviewPanel()).getSplitSelectController();
// Launcher will restart in Overview and then transition to OverviewSplitSelect.
outState.putIBinder(PENDING_SPLIT_SELECT_INFO, ObjectWrapper.wrap(
new PendingSplitSelectInfo(
splitSelectStateController.getInitialTaskId(),
splitSelectStateController.getActiveSplitStagePosition(),
splitSelectStateController.getSplitEvent())
mSplitSelectStateController.getInitialTaskId(),
mSplitSelectStateController.getActiveSplitStagePosition(),
mSplitSelectStateController.getSplitEvent())
));
outState.putInt(RUNTIME_STATE, OVERVIEW.ordinal);
}