Merge "Animate when removing PiP" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
20dc060dc5
@@ -21,7 +21,6 @@ import android.animation.Animator;
|
|||||||
import android.animation.RectEvaluator;
|
import android.animation.RectEvaluator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
|
||||||
@@ -56,13 +55,15 @@ public class PipAnimationController {
|
|||||||
public static final int TRANSITION_DIRECTION_TO_PIP = 2;
|
public static final int TRANSITION_DIRECTION_TO_PIP = 2;
|
||||||
public static final int TRANSITION_DIRECTION_TO_FULLSCREEN = 3;
|
public static final int TRANSITION_DIRECTION_TO_FULLSCREEN = 3;
|
||||||
public static final int TRANSITION_DIRECTION_TO_SPLIT_SCREEN = 4;
|
public static final int TRANSITION_DIRECTION_TO_SPLIT_SCREEN = 4;
|
||||||
|
public static final int TRANSITION_DIRECTION_REMOVE_STACK = 5;
|
||||||
|
|
||||||
@IntDef(prefix = { "TRANSITION_DIRECTION_" }, value = {
|
@IntDef(prefix = { "TRANSITION_DIRECTION_" }, value = {
|
||||||
TRANSITION_DIRECTION_NONE,
|
TRANSITION_DIRECTION_NONE,
|
||||||
TRANSITION_DIRECTION_SAME,
|
TRANSITION_DIRECTION_SAME,
|
||||||
TRANSITION_DIRECTION_TO_PIP,
|
TRANSITION_DIRECTION_TO_PIP,
|
||||||
TRANSITION_DIRECTION_TO_FULLSCREEN,
|
TRANSITION_DIRECTION_TO_FULLSCREEN,
|
||||||
TRANSITION_DIRECTION_TO_SPLIT_SCREEN
|
TRANSITION_DIRECTION_TO_SPLIT_SCREEN,
|
||||||
|
TRANSITION_DIRECTION_REMOVE_STACK
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface TransitionDirection {}
|
public @interface TransitionDirection {}
|
||||||
@@ -88,7 +89,7 @@ public class PipAnimationController {
|
|||||||
});
|
});
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PipAnimationController(Context context, PipSurfaceTransactionHelper helper) {
|
PipAnimationController(PipSurfaceTransactionHelper helper) {
|
||||||
mSurfaceTransactionHelper = helper;
|
mSurfaceTransactionHelper = helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,6 +339,10 @@ public class PipAnimationController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onStartTransaction(SurfaceControl leash, SurfaceControl.Transaction tx) {
|
void onStartTransaction(SurfaceControl leash, SurfaceControl.Transaction tx) {
|
||||||
|
if (getTransitionDirection() == TRANSITION_DIRECTION_REMOVE_STACK) {
|
||||||
|
// while removing the pip stack, no extra work needs to be done here.
|
||||||
|
return;
|
||||||
|
}
|
||||||
getSurfaceTransactionHelper()
|
getSurfaceTransactionHelper()
|
||||||
.resetScale(tx, leash, getDestinationBounds())
|
.resetScale(tx, leash, getDestinationBounds())
|
||||||
.crop(tx, leash, getDestinationBounds())
|
.crop(tx, leash, getDestinationBounds())
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
|||||||
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_ALPHA;
|
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_ALPHA;
|
||||||
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
|
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
|
||||||
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
|
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
|
||||||
|
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_REMOVE_STACK;
|
||||||
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
|
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
|
||||||
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
|
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
|
||||||
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
|
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
|
||||||
@@ -337,7 +338,19 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
|||||||
+ " mInPip=" + mInPip + " mExitingPip=" + mExitingPip + " mToken=" + mToken);
|
+ " mInPip=" + mInPip + " mExitingPip=" + mExitingPip + " mToken=" + mToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getUpdateHandler().post(() -> {
|
|
||||||
|
// removePipImmediately is expected when the following animation finishes.
|
||||||
|
mUpdateHandler.post(() -> mPipAnimationController
|
||||||
|
.getAnimator(mLeash, mLastReportedBounds, 1f, 0f)
|
||||||
|
.setTransitionDirection(TRANSITION_DIRECTION_REMOVE_STACK)
|
||||||
|
.setPipAnimationCallback(mPipAnimationCallback)
|
||||||
|
.setDuration(mEnterExitAnimationDuration)
|
||||||
|
.start());
|
||||||
|
mInitialState.remove(mToken.asBinder());
|
||||||
|
mExitingPip = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removePipImmediately() {
|
||||||
try {
|
try {
|
||||||
// Reset the task bounds first to ensure the activity configuration is reset as well
|
// Reset the task bounds first to ensure the activity configuration is reset as well
|
||||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
@@ -349,9 +362,6 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Failed to remove PiP", e);
|
Log.e(TAG, "Failed to remove PiP", e);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
mInitialState.remove(mToken.asBinder());
|
|
||||||
mExitingPip = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -803,7 +813,10 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
|||||||
+ "directly");
|
+ "directly");
|
||||||
}
|
}
|
||||||
mLastReportedBounds.set(destinationBounds);
|
mLastReportedBounds.set(destinationBounds);
|
||||||
if (isInPipDirection(direction) && type == ANIM_TYPE_ALPHA) {
|
if (direction == TRANSITION_DIRECTION_REMOVE_STACK) {
|
||||||
|
removePipImmediately();
|
||||||
|
return;
|
||||||
|
} else if (isInPipDirection(direction) && type == ANIM_TYPE_ALPHA) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ public class PipAnimationControllerTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mPipAnimationController = new PipAnimationController(
|
mPipAnimationController = new PipAnimationController(
|
||||||
mContext, new PipSurfaceTransactionHelper(mContext,
|
new PipSurfaceTransactionHelper(mContext, mock(ConfigurationController.class)));
|
||||||
mock(ConfigurationController.class)));
|
|
||||||
mLeash = new SurfaceControl.Builder()
|
mLeash = new SurfaceControl.Builder()
|
||||||
.setContainerLayer()
|
.setContainerLayer()
|
||||||
.setName("FakeLeash")
|
.setName("FakeLeash")
|
||||||
|
|||||||
Reference in New Issue
Block a user