Merge changes I8f0af447,I669919d4 into sc-v2-dev
* changes: PiP: Show the wallpaper as part of the transition. PiP: Implement expand transition.
This commit is contained in:
@@ -423,6 +423,11 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
||||
// Set the exiting state first so if there is fixed rotation later, the running animation
|
||||
// won't be interrupted by alpha animation for existing PiP.
|
||||
mState = State.EXITING_PIP;
|
||||
|
||||
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
||||
mPipTransitionController.startTransition(destinationBounds, wct);
|
||||
return;
|
||||
}
|
||||
mSyncTransactionQueue.queue(wct);
|
||||
mSyncTransactionQueue.runInSync(t -> {
|
||||
// Make sure to grab the latest source hint rect as it could have been
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.wm.shell.pip;
|
||||
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
||||
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
|
||||
|
||||
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
|
||||
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
|
||||
@@ -25,6 +26,7 @@ import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTI
|
||||
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
|
||||
import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;
|
||||
import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
|
||||
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP;
|
||||
|
||||
import android.app.TaskInfo;
|
||||
import android.content.Context;
|
||||
@@ -53,6 +55,7 @@ public class PipTransition extends PipTransitionController {
|
||||
private final int mEnterExitAnimationDuration;
|
||||
private @PipAnimationController.AnimationType int mOneShotAnimationType = ANIM_TYPE_BOUNDS;
|
||||
private Transitions.TransitionFinishCallback mFinishCallback;
|
||||
private Rect mExitDestinationBounds = new Rect();
|
||||
|
||||
public PipTransition(Context context,
|
||||
PipBoundsState pipBoundsState, PipMenuController pipMenuController,
|
||||
@@ -66,23 +69,54 @@ public class PipTransition extends PipTransitionController {
|
||||
.getInteger(R.integer.config_pipResizeAnimationDuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startTransition(Rect destinationBounds, WindowContainerTransaction out) {
|
||||
mExitDestinationBounds.set(destinationBounds);
|
||||
mTransitions.startTransition(TRANSIT_EXIT_PIP, out, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startAnimation(@android.annotation.NonNull IBinder transition,
|
||||
@android.annotation.NonNull TransitionInfo info,
|
||||
@android.annotation.NonNull SurfaceControl.Transaction startTransaction,
|
||||
@android.annotation.NonNull SurfaceControl.Transaction finishTransaction,
|
||||
@android.annotation.NonNull Transitions.TransitionFinishCallback finishCallback) {
|
||||
|
||||
if (info.getType() == TRANSIT_EXIT_PIP && info.getChanges().size() == 1) {
|
||||
final TransitionInfo.Change change = info.getChanges().get(0);
|
||||
mFinishCallback = finishCallback;
|
||||
boolean success = startExpandAnimation(change.getTaskInfo(), change.getLeash(),
|
||||
new Rect(mExitDestinationBounds));
|
||||
mExitDestinationBounds.setEmpty();
|
||||
return success;
|
||||
}
|
||||
|
||||
// Search for an Enter PiP transition (along with a show wallpaper one)
|
||||
TransitionInfo.Change enterPip = null;
|
||||
TransitionInfo.Change wallpaper = null;
|
||||
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
|
||||
final TransitionInfo.Change change = info.getChanges().get(i);
|
||||
if (change.getTaskInfo() != null
|
||||
&& change.getTaskInfo().configuration.windowConfiguration.getWindowingMode()
|
||||
== WINDOWING_MODE_PINNED) {
|
||||
mFinishCallback = finishCallback;
|
||||
return startEnterAnimation(change.getTaskInfo(), change.getLeash(),
|
||||
startTransaction, finishTransaction);
|
||||
enterPip = change;
|
||||
} else if ((change.getFlags() & FLAG_IS_WALLPAPER) != 0) {
|
||||
wallpaper = change;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (enterPip == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show the wallpaper if there is a wallpaper change.
|
||||
if (wallpaper != null) {
|
||||
startTransaction.show(wallpaper.getLeash());
|
||||
startTransaction.setAlpha(wallpaper.getLeash(), 1.f);
|
||||
}
|
||||
|
||||
mFinishCallback = finishCallback;
|
||||
return startEnterAnimation(enterPip.getTaskInfo(), enterPip.getLeash(),
|
||||
startTransaction, finishTransaction);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -109,6 +143,21 @@ public class PipTransition extends PipTransitionController {
|
||||
finishResizeForMenu(destinationBounds);
|
||||
}
|
||||
|
||||
private boolean startExpandAnimation(final TaskInfo taskInfo, final SurfaceControl leash,
|
||||
final Rect destinationBounds) {
|
||||
PipAnimationController.PipTransitionAnimator animator =
|
||||
mPipAnimationController.getAnimator(taskInfo, leash, mPipBoundsState.getBounds(),
|
||||
mPipBoundsState.getBounds(), destinationBounds, null,
|
||||
TRANSITION_DIRECTION_LEAVE_PIP, 0 /* startingAngle */, Surface.ROTATION_0);
|
||||
|
||||
animator.setTransitionDirection(TRANSITION_DIRECTION_LEAVE_PIP)
|
||||
.setPipAnimationCallback(mPipAnimationCallback)
|
||||
.setDuration(mEnterExitAnimationDuration)
|
||||
.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean startEnterAnimation(final TaskInfo taskInfo, final SurfaceControl leash,
|
||||
final SurfaceControl.Transaction startTransaction,
|
||||
final SurfaceControl.Transaction finishTransaction) {
|
||||
@@ -127,7 +176,6 @@ public class PipTransition extends PipTransitionController {
|
||||
0 /* startingAngle */, Surface.ROTATION_0);
|
||||
} else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
|
||||
startTransaction.setAlpha(leash, 0f);
|
||||
startTransaction.apply();
|
||||
animator = mPipAnimationController.getAnimator(taskInfo, leash, destinationBounds,
|
||||
0f, 1f);
|
||||
mOneShotAnimationType = ANIM_TYPE_BOUNDS;
|
||||
@@ -135,6 +183,7 @@ public class PipTransition extends PipTransitionController {
|
||||
throw new RuntimeException("Unrecognized animation type: "
|
||||
+ mOneShotAnimationType);
|
||||
}
|
||||
startTransaction.apply();
|
||||
animator.setTransitionDirection(TRANSITION_DIRECTION_TO_PIP)
|
||||
.setPipAnimationCallback(mPipAnimationCallback)
|
||||
.setDuration(mEnterExitAnimationDuration)
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.SurfaceControl;
|
||||
import android.window.WindowContainerTransaction;
|
||||
|
||||
import com.android.wm.shell.ShellTaskOrganizer;
|
||||
import com.android.wm.shell.transition.Transitions;
|
||||
@@ -46,6 +47,7 @@ public abstract class PipTransitionController implements Transitions.TransitionH
|
||||
protected final PipBoundsState mPipBoundsState;
|
||||
protected final ShellTaskOrganizer mShellTaskOrganizer;
|
||||
protected final PipMenuController mPipMenuController;
|
||||
protected final Transitions mTransitions;
|
||||
private final Handler mMainHandler;
|
||||
private final List<PipTransitionCallback> mPipTransitionCallbacks = new ArrayList<>();
|
||||
|
||||
@@ -98,6 +100,13 @@ public abstract class PipTransitionController implements Transitions.TransitionH
|
||||
SurfaceControl.Transaction tx) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Shell wants to starts a transition/animation.
|
||||
*/
|
||||
public void startTransition(Rect destinationBounds, WindowContainerTransaction out) {
|
||||
// Default implementation does nothing.
|
||||
}
|
||||
|
||||
public PipTransitionController(PipBoundsState pipBoundsState,
|
||||
PipMenuController pipMenuController, PipBoundsAlgorithm pipBoundsAlgorithm,
|
||||
PipAnimationController pipAnimationController, Transitions transitions,
|
||||
@@ -107,6 +116,7 @@ public abstract class PipTransitionController implements Transitions.TransitionH
|
||||
mShellTaskOrganizer = shellTaskOrganizer;
|
||||
mPipBoundsAlgorithm = pipBoundsAlgorithm;
|
||||
mPipAnimationController = pipAnimationController;
|
||||
mTransitions = transitions;
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
|
||||
transitions.addHandler(this);
|
||||
|
||||
@@ -77,6 +77,9 @@ public class Transitions implements RemoteCallable<Transitions> {
|
||||
/** Transition type for launching 2 tasks simultaneously. */
|
||||
public static final int TRANSIT_SPLIT_SCREEN_PAIR_OPEN = TRANSIT_FIRST_CUSTOM + 2;
|
||||
|
||||
/** Transition type for exiting PIP via the Shell, either via Expand or Dismiss. */
|
||||
public static final int TRANSIT_EXIT_PIP = TRANSIT_FIRST_CUSTOM + 3;
|
||||
|
||||
private final WindowOrganizer mOrganizer;
|
||||
private final Context mContext;
|
||||
private final ShellExecutor mMainExecutor;
|
||||
|
||||
Reference in New Issue
Block a user