Merge "Fixing issue with double tapping PiP." into oc-dev
am: 39d9ae20a6
Change-Id: Ibf0a355d5b171e360599620ce90aa7aee127e835
This commit is contained in:
@@ -27,6 +27,7 @@ import android.content.Intent;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
@@ -254,7 +255,9 @@ public class PipMenuActivityController {
|
||||
public void showMenu(int menuState, Rect stackBounds, Rect movementBounds,
|
||||
boolean allowMenuTimeout) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "showMenu() hasActivity=" + (mToActivityMessenger != null));
|
||||
Log.d(TAG, "showMenu() state=" + menuState
|
||||
+ " hasActivity=" + (mToActivityMessenger != null)
|
||||
+ " callers=\n" + Debug.getCallers(5, " "));
|
||||
}
|
||||
if (mToActivityMessenger != null) {
|
||||
Bundle data = new Bundle();
|
||||
@@ -298,7 +301,9 @@ public class PipMenuActivityController {
|
||||
*/
|
||||
public void hideMenu() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "hideMenu() hasActivity=" + (mToActivityMessenger != null));
|
||||
Log.d(TAG, "hideMenu() state=" + mMenuState
|
||||
+ " hasActivity=" + (mToActivityMessenger != null)
|
||||
+ " callers=\n" + Debug.getCallers(5, " "));
|
||||
}
|
||||
if (mToActivityMessenger != null) {
|
||||
Message m = Message.obtain();
|
||||
@@ -320,13 +325,6 @@ public class PipMenuActivityController {
|
||||
onMenuStateChanged(MENU_STATE_NONE, false /* resize */);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current menu state.
|
||||
*/
|
||||
public int getMenuState() {
|
||||
return mMenuState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the menu actions to the actions provided by the current PiP activity.
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
@@ -54,6 +55,7 @@ import java.io.PrintWriter;
|
||||
public class PipMotionHelper {
|
||||
|
||||
private static final String TAG = "PipMotionHelper";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private static final RectEvaluator RECT_EVALUATOR = new RectEvaluator(new Rect());
|
||||
|
||||
@@ -150,6 +152,10 @@ public class PipMotionHelper {
|
||||
* Resizes the pinned stack back to fullscreen.
|
||||
*/
|
||||
void expandPip(boolean skipAnimation) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "expandPip: skipAnimation=" + skipAnimation
|
||||
+ " callers=\n" + Debug.getCallers(5, " "));
|
||||
}
|
||||
cancelAnimations();
|
||||
mMenuController.hideMenuWithoutResize();
|
||||
mHandler.post(() -> {
|
||||
@@ -171,6 +177,9 @@ public class PipMotionHelper {
|
||||
* Dismisses the pinned stack.
|
||||
*/
|
||||
void dismissPip() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "dismissPip: callers=\n" + Debug.getCallers(5, " "));
|
||||
}
|
||||
cancelAnimations();
|
||||
mMenuController.hideMenuWithoutResize();
|
||||
mHandler.post(() -> {
|
||||
@@ -419,6 +428,10 @@ public class PipMotionHelper {
|
||||
* Directly resizes the PiP to the given {@param bounds}.
|
||||
*/
|
||||
private void resizePipUnchecked(Rect toBounds) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "resizePipUnchecked: toBounds=" + toBounds
|
||||
+ " callers=\n" + Debug.getCallers(5, " "));
|
||||
}
|
||||
if (!toBounds.equals(mBounds)) {
|
||||
mVsyncChoreographer.scheduleAtSfVsync(() -> {
|
||||
try {
|
||||
@@ -435,6 +448,10 @@ public class PipMotionHelper {
|
||||
* Directly resizes the PiP to the given {@param bounds}.
|
||||
*/
|
||||
private void resizeAndAnimatePipUnchecked(Rect toBounds, int duration) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "resizeAndAnimatePipUnchecked: toBounds=" + toBounds
|
||||
+ " duration=" + duration + " callers=\n" + Debug.getCallers(5, " "));
|
||||
}
|
||||
if (!toBounds.equals(mBounds)) {
|
||||
mHandler.post(() -> {
|
||||
try {
|
||||
|
||||
@@ -484,14 +484,15 @@ public class PipTouchHandler {
|
||||
// Try and restore the PiP to the closest edge, using the saved snap fraction
|
||||
// if possible
|
||||
if (resize) {
|
||||
// This is a very special case: when the menu is expanded and visible, navigating to
|
||||
// another activity can trigger auto-enter PiP, and if the revealed activity has a
|
||||
// forced rotation set, then the controller will get updated with the new rotation
|
||||
// of the display. However, at the same time, SystemUI will try to hide the menu by
|
||||
// creating an animation to the normal bounds which are now stale. In such a case
|
||||
// we defer the animation to the normal bounds until after the next
|
||||
// onMovementBoundsChanged() call to get the bounds in the new orientation
|
||||
if (mDeferResizeToNormalBoundsUntilRotation == -1) {
|
||||
// This is a very special case: when the menu is expanded and visible,
|
||||
// navigating to another activity can trigger auto-enter PiP, and if the
|
||||
// revealed activity has a forced rotation set, then the controller will get
|
||||
// updated with the new rotation of the display. However, at the same time,
|
||||
// SystemUI will try to hide the menu by creating an animation to the normal
|
||||
// bounds which are now stale. In such a case we defer the animation to the
|
||||
// normal bounds until after the next onMovementBoundsChanged() call to get the
|
||||
// bounds in the new orientation
|
||||
try {
|
||||
int displayRotation = mPinnedStackController.getDisplayRotation();
|
||||
if (mDisplayRotation != displayRotation) {
|
||||
@@ -510,6 +511,9 @@ public class PipTouchHandler {
|
||||
mSavedSnapFraction = -1f;
|
||||
}
|
||||
} else {
|
||||
// If resizing is not allowed, then the PiP should be frozen until the transition
|
||||
// ends as well
|
||||
setTouchEnabled(false);
|
||||
mSavedSnapFraction = -1f;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user