Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java +10 −5 Original line number Diff line number Diff line Loading @@ -399,11 +399,12 @@ public class PipMenuActivity extends Activity { } private void hideMenu(Runnable animationEndCallback) { hideMenu(animationEndCallback, true /* notifyMenuVisibility */, false /* isDismissing */); hideMenu(animationEndCallback, true /* notifyMenuVisibility */, false /* isDismissing */, true /* animate */); } private void hideMenu(final Runnable animationFinishedRunnable, boolean notifyMenuVisibility, boolean isDismissing) { boolean isDismissing, boolean animate) { if (mMenuState != MENU_STATE_NONE) { cancelDelayedFinish(); if (notifyMenuVisibility) { Loading @@ -419,7 +420,7 @@ public class PipMenuActivity extends Activity { mDismissButton.getAlpha(), 0f); mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim); mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_OUT); mMenuContainerAnimator.setDuration(MENU_FADE_DURATION); mMenuContainerAnimator.setDuration(animate ? MENU_FADE_DURATION : 0); mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { Loading Loading @@ -582,16 +583,20 @@ public class PipMenuActivity extends Activity { hideMenu(() -> { sendEmptyMessage(PipMenuActivityController.MESSAGE_EXPAND_PIP, "Could not notify controller to expand PIP"); }, false /* notifyMenuVisibility */, false /* isDismissing */); }, false /* notifyMenuVisibility */, false /* isDismissing */, true /* animate */); } private void dismissPip() { // Since tapping on the close-button invokes a double-tap wait callback in PipTouchHandler, // we want to disable animating the fadeout animation of the buttons in order to call on // PipTouchHandler#onPipDismiss fast enough. final boolean animate = mMenuState != MENU_STATE_CLOSE; // Do not notify menu visibility when hiding the menu, the controller will do this when it // handles the message hideMenu(() -> { sendEmptyMessage(PipMenuActivityController.MESSAGE_DISMISS_PIP, "Could not notify controller to dismiss PIP"); }, false /* notifyMenuVisibility */, true /* isDismissing */); }, false /* notifyMenuVisibility */, true /* isDismissing */, animate); } private void showSettings() { Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java +14 −14 Original line number Diff line number Diff line Loading @@ -237,7 +237,8 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .spring(FloatProperties.RECT_Y, toBounds.top, mSpringConfig) .withEndActions(() -> mSpringingToTouch = false); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */, false /* dismiss */); } } Loading Loading @@ -334,7 +335,8 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, final float estimatedFlingYEndValue = PhysicsAnimator.estimateFlingEndValue(mBounds.top, velocityY, mFlingConfigY); startBoundsAnimator(xEndValue /* toX */, estimatedFlingYEndValue /* toY */); startBoundsAnimator(xEndValue /* toX */, estimatedFlingYEndValue /* toY */, false /* dismiss */); } /** Loading @@ -346,30 +348,26 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mAnimatedBoundsPhysicsAnimator .spring(FloatProperties.RECT_X, bounds.left, springConfig) .spring(FloatProperties.RECT_Y, bounds.top, springConfig); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */, false /* dismiss */); } /** * Animates the dismissal of the PiP off the edge of the screen. */ void animateDismiss(float velocityX, float velocityY, @Nullable Runnable updateAction) { void animateDismiss() { mAnimatedBounds.set(mBounds); // Animate off the bottom of the screen, then dismiss PIP. mAnimatedBoundsPhysicsAnimator .spring(FloatProperties.RECT_Y, mBounds.bottom + mBounds.height(), velocityY, 0, mSpringConfig) .withEndActions(this::dismissPip); // If we were provided with an update action, run it whenever there's an update. if (updateAction != null) { mAnimatedBoundsPhysicsAnimator.addUpdateListener( (target, values) -> updateAction.run()); } startBoundsAnimator(mBounds.left /* toX */, mBounds.bottom + mBounds.height() /* toY */); startBoundsAnimator(mBounds.left /* toX */, mBounds.bottom + mBounds.height() /* toY */, true /* dismiss */); } /** Loading Loading @@ -440,7 +438,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, * This will also add end actions to the bounds animator that cancel the TimeAnimator and update * the 'real' bounds to equal the final animated bounds. */ private void startBoundsAnimator(float toX, float toY) { private void startBoundsAnimator(float toX, float toY, boolean dismiss) { if (!mSpringingToTouch) { cancelAnimations(); } Loading @@ -456,7 +454,9 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mAnimatedBoundsPhysicsAnimator .withEndActions(() -> { if (!dismiss) { mPipTaskOrganizer.scheduleFinishResizePip(mAnimatedBounds); } mAnimatingToBounds.setEmpty(); }) .addUpdateListener(mResizePipUpdateListener) Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ public class PipTouchHandler { if (topPipActivity.first != null) { MetricsLoggerWrapper.logPictureInPictureDismissByTap(mContext, topPipActivity); } mTouchState.removeDoubleTapTimeoutCallback(); mMotionHelper.dismissPip(); } Loading Loading @@ -297,7 +298,7 @@ public class PipTouchHandler { @Override public void onReleasedInTarget(@NonNull MagnetizedObject.MagneticTarget target) { mHandler.post(() -> { mMotionHelper.animateDismiss(0, 0, null); mMotionHelper.animateDismiss(); hideDismissTarget(); }); Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java +8 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,14 @@ public class PipTouchState { return -1; } /** * Removes the timeout callback if it's in queue. */ public void removeDoubleTapTimeoutCallback() { mIsWaitingForDoubleTap = false; mHandler.removeCallbacks(mDoubleTapTimeoutCallback); } void addMovementToVelocityTracker(MotionEvent event) { if (mVelocityTracker == null) { return; Loading Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java +10 −5 Original line number Diff line number Diff line Loading @@ -399,11 +399,12 @@ public class PipMenuActivity extends Activity { } private void hideMenu(Runnable animationEndCallback) { hideMenu(animationEndCallback, true /* notifyMenuVisibility */, false /* isDismissing */); hideMenu(animationEndCallback, true /* notifyMenuVisibility */, false /* isDismissing */, true /* animate */); } private void hideMenu(final Runnable animationFinishedRunnable, boolean notifyMenuVisibility, boolean isDismissing) { boolean isDismissing, boolean animate) { if (mMenuState != MENU_STATE_NONE) { cancelDelayedFinish(); if (notifyMenuVisibility) { Loading @@ -419,7 +420,7 @@ public class PipMenuActivity extends Activity { mDismissButton.getAlpha(), 0f); mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim); mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_OUT); mMenuContainerAnimator.setDuration(MENU_FADE_DURATION); mMenuContainerAnimator.setDuration(animate ? MENU_FADE_DURATION : 0); mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { Loading Loading @@ -582,16 +583,20 @@ public class PipMenuActivity extends Activity { hideMenu(() -> { sendEmptyMessage(PipMenuActivityController.MESSAGE_EXPAND_PIP, "Could not notify controller to expand PIP"); }, false /* notifyMenuVisibility */, false /* isDismissing */); }, false /* notifyMenuVisibility */, false /* isDismissing */, true /* animate */); } private void dismissPip() { // Since tapping on the close-button invokes a double-tap wait callback in PipTouchHandler, // we want to disable animating the fadeout animation of the buttons in order to call on // PipTouchHandler#onPipDismiss fast enough. final boolean animate = mMenuState != MENU_STATE_CLOSE; // Do not notify menu visibility when hiding the menu, the controller will do this when it // handles the message hideMenu(() -> { sendEmptyMessage(PipMenuActivityController.MESSAGE_DISMISS_PIP, "Could not notify controller to dismiss PIP"); }, false /* notifyMenuVisibility */, true /* isDismissing */); }, false /* notifyMenuVisibility */, true /* isDismissing */, animate); } private void showSettings() { Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java +14 −14 Original line number Diff line number Diff line Loading @@ -237,7 +237,8 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .spring(FloatProperties.RECT_Y, toBounds.top, mSpringConfig) .withEndActions(() -> mSpringingToTouch = false); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */, false /* dismiss */); } } Loading Loading @@ -334,7 +335,8 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, final float estimatedFlingYEndValue = PhysicsAnimator.estimateFlingEndValue(mBounds.top, velocityY, mFlingConfigY); startBoundsAnimator(xEndValue /* toX */, estimatedFlingYEndValue /* toY */); startBoundsAnimator(xEndValue /* toX */, estimatedFlingYEndValue /* toY */, false /* dismiss */); } /** Loading @@ -346,30 +348,26 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mAnimatedBoundsPhysicsAnimator .spring(FloatProperties.RECT_X, bounds.left, springConfig) .spring(FloatProperties.RECT_Y, bounds.top, springConfig); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */, false /* dismiss */); } /** * Animates the dismissal of the PiP off the edge of the screen. */ void animateDismiss(float velocityX, float velocityY, @Nullable Runnable updateAction) { void animateDismiss() { mAnimatedBounds.set(mBounds); // Animate off the bottom of the screen, then dismiss PIP. mAnimatedBoundsPhysicsAnimator .spring(FloatProperties.RECT_Y, mBounds.bottom + mBounds.height(), velocityY, 0, mSpringConfig) .withEndActions(this::dismissPip); // If we were provided with an update action, run it whenever there's an update. if (updateAction != null) { mAnimatedBoundsPhysicsAnimator.addUpdateListener( (target, values) -> updateAction.run()); } startBoundsAnimator(mBounds.left /* toX */, mBounds.bottom + mBounds.height() /* toY */); startBoundsAnimator(mBounds.left /* toX */, mBounds.bottom + mBounds.height() /* toY */, true /* dismiss */); } /** Loading Loading @@ -440,7 +438,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, * This will also add end actions to the bounds animator that cancel the TimeAnimator and update * the 'real' bounds to equal the final animated bounds. */ private void startBoundsAnimator(float toX, float toY) { private void startBoundsAnimator(float toX, float toY, boolean dismiss) { if (!mSpringingToTouch) { cancelAnimations(); } Loading @@ -456,7 +454,9 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mAnimatedBoundsPhysicsAnimator .withEndActions(() -> { if (!dismiss) { mPipTaskOrganizer.scheduleFinishResizePip(mAnimatedBounds); } mAnimatingToBounds.setEmpty(); }) .addUpdateListener(mResizePipUpdateListener) Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ public class PipTouchHandler { if (topPipActivity.first != null) { MetricsLoggerWrapper.logPictureInPictureDismissByTap(mContext, topPipActivity); } mTouchState.removeDoubleTapTimeoutCallback(); mMotionHelper.dismissPip(); } Loading Loading @@ -297,7 +298,7 @@ public class PipTouchHandler { @Override public void onReleasedInTarget(@NonNull MagnetizedObject.MagneticTarget target) { mHandler.post(() -> { mMotionHelper.animateDismiss(0, 0, null); mMotionHelper.animateDismiss(); hideDismissTarget(); }); Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java +8 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,14 @@ public class PipTouchState { return -1; } /** * Removes the timeout callback if it's in queue. */ public void removeDoubleTapTimeoutCallback() { mIsWaitingForDoubleTap = false; mHandler.removeCallbacks(mDoubleTapTimeoutCallback); } void addMovementToVelocityTracker(MotionEvent event) { if (mVelocityTracker == null) { return; Loading