Merge "Cleanup quick switch logic" into ub-launcher3-rvc-dev
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK;
|
||||
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
@@ -110,10 +111,6 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
|
||||
public static final int STATE_RECENTS_SCROLLING_FINISHED =
|
||||
getFlagForIndex("STATE_RECENTS_SCROLLING_FINISHED");
|
||||
|
||||
// Called when the new task appeared from quick switching.
|
||||
public static final int STATE_TASK_APPEARED_DURING_SWITCH =
|
||||
getFlagForIndex("STATE_TASK_APPEARED_DURING_SWITCH");
|
||||
|
||||
// Needed to interact with the current activity
|
||||
private final Intent mHomeIntent;
|
||||
private final Intent mOverviewIntent;
|
||||
@@ -123,9 +120,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
|
||||
|
||||
private ActivityManager.RunningTaskInfo mRunningTask;
|
||||
private GestureEndTarget mEndTarget;
|
||||
private RemoteAnimationTargetCompat mAnimationTarget;
|
||||
// TODO: This can be removed once we stop finishing the animation when starting a new task
|
||||
private int mFinishingRecentsAnimationTaskId = -1;
|
||||
private RemoteAnimationTargetCompat mLastAppearedTaskTarget;
|
||||
|
||||
public GestureState(OverviewComponentObserver componentObserver, int gestureId) {
|
||||
mHomeIntent = componentObserver.getHomeIntent();
|
||||
@@ -143,7 +138,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
|
||||
mGestureId = other.mGestureId;
|
||||
mRunningTask = other.mRunningTask;
|
||||
mEndTarget = other.mEndTarget;
|
||||
mFinishingRecentsAnimationTaskId = other.mFinishingRecentsAnimationTaskId;
|
||||
mLastAppearedTaskTarget = other.mLastAppearedTaskTarget;
|
||||
}
|
||||
|
||||
public GestureState() {
|
||||
@@ -225,6 +220,20 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
|
||||
mRunningTask = runningTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the last task that appeared during this gesture.
|
||||
*/
|
||||
public void updateLastAppearedTaskTarget(RemoteAnimationTargetCompat lastAppearedTaskTarget) {
|
||||
mLastAppearedTaskTarget = lastAppearedTaskTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id of the task that appeared during this gesture.
|
||||
*/
|
||||
public int getLastAppearedTaskId() {
|
||||
return mLastAppearedTaskTarget != null ? mLastAppearedTaskTarget.taskId : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the end target for this gesture (if known).
|
||||
*/
|
||||
@@ -232,14 +241,6 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
|
||||
return mEndTarget;
|
||||
}
|
||||
|
||||
public void setAnimationTarget(RemoteAnimationTargetCompat target) {
|
||||
mAnimationTarget = target;
|
||||
}
|
||||
|
||||
public RemoteAnimationTargetCompat getAnimationTarget() {
|
||||
return mAnimationTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the end target of this gesture and immediately notifies the state changes.
|
||||
*/
|
||||
@@ -259,30 +260,9 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id for the task that was about to be launched following the finish of the recents
|
||||
* animation. Only defined between when the finish-recents call was made and the launch
|
||||
* activity call is made.
|
||||
*/
|
||||
public int getFinishingRecentsAnimationTaskId() {
|
||||
return mFinishingRecentsAnimationTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id for the task will be launched after the recents animation is finished. Once the
|
||||
* animation has finished then the id will be reset to -1.
|
||||
*/
|
||||
public void setFinishingRecentsAnimationTaskId(int taskId) {
|
||||
mFinishingRecentsAnimationTaskId = taskId;
|
||||
mStateCallback.runOnceAtState(STATE_RECENTS_ANIMATION_FINISHED, () -> {
|
||||
mFinishingRecentsAnimationTaskId = -1;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the current gesture is still running a recents animation to a state in the
|
||||
* Launcher or Recents activity.
|
||||
* Updates the running task for the gesture to be the given {@param runningTask}.
|
||||
*/
|
||||
public boolean isRunningAnimationToLauncher() {
|
||||
return isRecentsAnimationRunning() && mEndTarget != null && mEndTarget.isLauncher;
|
||||
@@ -314,18 +294,12 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
|
||||
mStateCallback.setState(STATE_RECENTS_ANIMATION_ENDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskAppeared(RemoteAnimationTargetCompat app) {
|
||||
mAnimationTarget = app;
|
||||
mStateCallback.setState(STATE_TASK_APPEARED_DURING_SWITCH);
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println("GestureState:");
|
||||
pw.println(" gestureID=" + mGestureId);
|
||||
pw.println(" runningTask=" + mRunningTask);
|
||||
pw.println(" endTarget=" + mEndTarget);
|
||||
pw.println(" finishingRecentsAnimationTaskId=" + mFinishingRecentsAnimationTaskId);
|
||||
pw.println(" lastAppearedTaskTarget=" + mLastAppearedTaskTarget);
|
||||
pw.println(" isRecentsAnimationRunning=" + isRecentsAnimationRunning());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,6 @@ public class RecentsAnimationCallbacks implements
|
||||
/**
|
||||
* Callback made when a task started from the recents is ready for an app transition.
|
||||
*/
|
||||
default void onTaskAppeared(RemoteAnimationTargetCompat app) {}
|
||||
default void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.quickstep;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_INITIALIZED;
|
||||
import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_STARTED;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
@@ -28,6 +29,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
|
||||
|
||||
public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAnimationListener {
|
||||
|
||||
@@ -36,6 +38,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
private RecentsAnimationTargets mTargets;
|
||||
// Temporary until we can hook into gesture state events
|
||||
private GestureState mLastGestureState;
|
||||
private RemoteAnimationTargetCompat mLastAppearedTaskTarget;
|
||||
|
||||
/**
|
||||
* Preloads the recents animation.
|
||||
@@ -79,6 +82,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
}
|
||||
mController = controller;
|
||||
mTargets = targets;
|
||||
mLastAppearedTaskTarget = mTargets.findTask(mLastGestureState.getRunningTaskId());
|
||||
mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,6 +101,20 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
public void onRecentsAnimationFinished(RecentsAnimationController controller) {
|
||||
cleanUpRecentsAnimation(null /* canceledThumbnail */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
|
||||
if (mController != null) {
|
||||
if (mLastAppearedTaskTarget == null
|
||||
|| appearedTaskTarget.taskId != mLastAppearedTaskTarget.taskId) {
|
||||
if (mLastAppearedTaskTarget != null) {
|
||||
mController.removeTaskTarget(mLastAppearedTaskTarget);
|
||||
}
|
||||
mLastAppearedTaskTarget = appearedTaskTarget;
|
||||
mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
mCallbacks.addListener(gestureState);
|
||||
mCallbacks.addListener(listener);
|
||||
@@ -112,6 +131,9 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
mCallbacks.removeListener(mLastGestureState);
|
||||
mLastGestureState = gestureState;
|
||||
mCallbacks.addListener(gestureState);
|
||||
gestureState.setState(STATE_RECENTS_ANIMATION_INITIALIZED
|
||||
| STATE_RECENTS_ANIMATION_STARTED);
|
||||
gestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
|
||||
return mCallbacks;
|
||||
}
|
||||
|
||||
@@ -171,6 +193,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
mCallbacks = null;
|
||||
mTargets = null;
|
||||
mLastGestureState = null;
|
||||
mLastAppearedTaskTarget = null;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
|
||||
Reference in New Issue
Block a user