mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
Merge "Support multiple tasks in recentsaninmation onTaskAppeared" into sc-v2-dev
This commit is contained in:
@@ -122,6 +122,7 @@ import com.android.systemui.shared.system.TaskStackChangeListeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -976,12 +977,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
}
|
||||
|
||||
/** @return Whether this was the task we were waiting to appear, and thus handled it. */
|
||||
protected boolean handleTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
|
||||
protected boolean handleTaskAppeared(RemoteAnimationTargetCompat[] appearedTaskTarget) {
|
||||
if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
|
||||
return false;
|
||||
}
|
||||
if (mStateCallback.hasStates(STATE_START_NEW_TASK)
|
||||
&& appearedTaskTarget.taskId == mGestureState.getLastStartedTaskId()) {
|
||||
boolean hasStartedTaskBefore = Arrays.stream(appearedTaskTarget).anyMatch(
|
||||
targetCompat -> targetCompat.taskId == mGestureState.getLastStartedTaskId());
|
||||
if (mStateCallback.hasStates(STATE_START_NEW_TASK) && hasStartedTaskBefore) {
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
@@ -1866,9 +1868,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
|
||||
public void onTasksAppeared(RemoteAnimationTargetCompat[] appearedTaskTargets) {
|
||||
if (mRecentsAnimationController != null) {
|
||||
if (handleTaskAppeared(appearedTaskTarget)) {
|
||||
if (handleTaskAppeared(appearedTaskTargets)) {
|
||||
mRecentsAnimationController.finish(false /* toRecents */,
|
||||
null /* onFinishComplete */);
|
||||
mActivityInterface.onLaunchTaskSuccess();
|
||||
|
||||
@@ -147,7 +147,7 @@ public class FallbackSwipeHandler extends
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
|
||||
protected boolean handleTaskAppeared(RemoteAnimationTargetCompat[] appearedTaskTarget) {
|
||||
if (mActiveAnimationFactory != null
|
||||
&& mActiveAnimationFactory.handleHomeTaskAppeared(appearedTaskTarget)) {
|
||||
mActiveAnimationFactory = null;
|
||||
@@ -260,7 +260,8 @@ public class FallbackSwipeHandler extends
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handleHomeTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
|
||||
public boolean handleHomeTaskAppeared(RemoteAnimationTargetCompat[] appearedTaskTargets) {
|
||||
RemoteAnimationTargetCompat appearedTaskTarget = appearedTaskTargets[0];
|
||||
if (appearedTaskTarget.activityType == ACTIVITY_TYPE_HOME) {
|
||||
RemoteAnimationTargets targets = new RemoteAnimationTargets(
|
||||
new RemoteAnimationTargetCompat[] {appearedTaskTarget},
|
||||
|
||||
@@ -136,10 +136,10 @@ public class RecentsAnimationCallbacks implements
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void onTaskAppeared(RemoteAnimationTargetCompat app) {
|
||||
public void onTasksAppeared(RemoteAnimationTargetCompat[] apps) {
|
||||
Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> {
|
||||
for (RecentsAnimationListener listener : getListeners()) {
|
||||
listener.onTaskAppeared(app);
|
||||
listener.onTasksAppeared(apps);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -177,6 +177,6 @@ public class RecentsAnimationCallbacks implements
|
||||
/**
|
||||
* Callback made when a task started from the recents is ready for an app transition.
|
||||
*/
|
||||
default void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {}
|
||||
default void onTasksAppeared(RemoteAnimationTargetCompat[] appearedTaskTarget) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,13 +85,21 @@ public class RemoteTargetGluer {
|
||||
|
||||
/**
|
||||
* Similar to {@link #assignTargets(RemoteAnimationTargets)}, except this matches the
|
||||
* apps in targets.apps to that of the split screened tasks. If split screen is active, then
|
||||
* {@link #mRemoteTargetHandles} index 0 will be the left/top task, index one right/bottom
|
||||
* apps in targets.apps to that of the _active_ split screened tasks.
|
||||
* See {@link #assignTargetsForSplitScreen(RemoteAnimationTargets, int[])}
|
||||
*/
|
||||
public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets) {
|
||||
int[] splitIds = LauncherSplitScreenListener.INSTANCE.getNoCreate()
|
||||
.getRunningSplitTaskIds();
|
||||
return assignTargetsForSplitScreen(targets, splitIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the provided splitIDs to the {@link #mRemoteTargetHandles}, with index 0 will beint
|
||||
* the left/top task, index 1 right/bottom
|
||||
*/
|
||||
public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets,
|
||||
int[] splitIds) {
|
||||
RemoteAnimationTargetCompat primaryTaskTarget;
|
||||
RemoteAnimationTargetCompat secondaryTaskTarget;
|
||||
if (mRemoteTargetHandles.length == 1) {
|
||||
|
||||
@@ -147,16 +147,16 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
|
||||
public void onTasksAppeared(RemoteAnimationTargetCompat[] appearedTaskTargets) {
|
||||
RemoteAnimationTargetCompat appearedTaskTarget = appearedTaskTargets[0];
|
||||
BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface();
|
||||
if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode()
|
||||
&& activityInterface.getCreatedActivity() != null) {
|
||||
RecentsView recentsView =
|
||||
activityInterface.getCreatedActivity().getOverviewPanel();
|
||||
if (recentsView != null) {
|
||||
RemoteAnimationTargetCompat[] apps = new RemoteAnimationTargetCompat[1];
|
||||
apps[0] = appearedTaskTarget;
|
||||
recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, apps,
|
||||
recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId,
|
||||
appearedTaskTargets,
|
||||
new RemoteAnimationTargetCompat[0] /* wallpaper */,
|
||||
new RemoteAnimationTargetCompat[0] /* nonApps */);
|
||||
return;
|
||||
|
||||
@@ -177,8 +177,8 @@ public final class TaskViewUtils {
|
||||
} else {
|
||||
RemoteTargetGluer gluer = new RemoteTargetGluer(v.getContext(),
|
||||
recentsView.getSizeStrategy(), targets);
|
||||
if (recentsViewHandles != null && recentsViewHandles.length > 1) {
|
||||
remoteTargetHandles = gluer.assignTargetsForSplitScreen(targets);
|
||||
if (v.containsMultipleTasks()) {
|
||||
remoteTargetHandles = gluer.assignTargetsForSplitScreen(targets, v.getTaskIds());
|
||||
} else {
|
||||
remoteTargetHandles = gluer.assignTargets(targets);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public class SplitSelectStateController {
|
||||
private Task mInitialTask;
|
||||
private Task mSecondTask;
|
||||
private Rect mInitialBounds;
|
||||
private boolean mRecentsAnimationRunning;
|
||||
|
||||
public SplitSelectStateController(Handler handler, SystemUiProxy systemUiProxy) {
|
||||
mHandler = handler;
|
||||
@@ -113,6 +114,10 @@ public class SplitSelectStateController {
|
||||
return mStagePosition;
|
||||
}
|
||||
|
||||
public void setRecentsAnimationRunning(boolean running) {
|
||||
this.mRecentsAnimationRunning = running;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires Shell Transitions
|
||||
*/
|
||||
@@ -172,7 +177,9 @@ public class SplitSelectStateController {
|
||||
public void onAnimationCancelled() {
|
||||
postAsyncCallback(mHandler, () -> {
|
||||
if (mSuccessCallback != null) {
|
||||
mSuccessCallback.accept(false);
|
||||
// Launching legacy tasks while recents animation is running will always cause
|
||||
// onAnimationCancelled to be called (should be fixed w/ shell transitions?)
|
||||
mSuccessCallback.accept(mRecentsAnimationRunning);
|
||||
}
|
||||
resetState();
|
||||
});
|
||||
@@ -187,6 +194,7 @@ public class SplitSelectStateController {
|
||||
mSecondTask = null;
|
||||
mStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
|
||||
mInitialBounds = null;
|
||||
mRecentsAnimationRunning = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1874,6 +1874,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
remoteTargetHandle.getTransformParams().setTargetSet(null);
|
||||
remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(true);
|
||||
});
|
||||
mSplitSelectStateController.resetState();
|
||||
|
||||
// These are relatively expensive and don't need to be done this frame (RecentsView isn't
|
||||
// visible anyway), so defer by a frame to get off the critical path, e.g. app to home.
|
||||
@@ -4333,6 +4334,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
public void setRecentsAnimationTargets(RecentsAnimationController recentsAnimationController,
|
||||
RecentsAnimationTargets recentsAnimationTargets) {
|
||||
mRecentsAnimationController = recentsAnimationController;
|
||||
mSplitSelectStateController.setRecentsAnimationRunning(true);
|
||||
if (recentsAnimationTargets == null || recentsAnimationTargets.apps.length == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -4432,6 +4434,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
// taps on QSB (3) user goes back to Overview and launch the most recent task.
|
||||
setCurrentTask(-1);
|
||||
mRecentsAnimationController = null;
|
||||
mSplitSelectStateController.setRecentsAnimationRunning(false);
|
||||
executeSideTaskLaunchCallback();
|
||||
}
|
||||
|
||||
|
||||
@@ -558,6 +558,10 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
return mTaskIdContainer;
|
||||
}
|
||||
|
||||
public boolean containsMultipleTasks() {
|
||||
return mTaskIdContainer[1] != -1;
|
||||
}
|
||||
|
||||
public TaskThumbnailView getThumbnail() {
|
||||
return mSnapshotView;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user