diff --git a/packages/SystemUI/res/drawable/pip_resize_handle.xml b/packages/SystemUI/res/drawable/pip_resize_handle.xml
new file mode 100644
index 0000000000000..0a8cbc429dd89
--- /dev/null
+++ b/packages/SystemUI/res/drawable/pip_resize_handle.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/packages/SystemUI/res/layout/pip_menu_activity.xml b/packages/SystemUI/res/layout/pip_menu_activity.xml
index ee0bd14820bdd..179e8fe4de2a3 100644
--- a/packages/SystemUI/res/layout/pip_menu_activity.xml
+++ b/packages/SystemUI/res/layout/pip_menu_activity.xml
@@ -81,4 +81,13 @@
android:src="@drawable/ic_close_white"
android:background="?android:selectableItemBackgroundBorderless" />
+
+
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java b/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java
index 93605170f22e7..febb6e9b32f58 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java
@@ -194,6 +194,14 @@ public class PipBoundsHandler {
mLastPipComponentName = null;
}
+ /**
+ * Returns ture if there's a valid snap fraction. This is used with {@link EXTRA_IS_FIRST_ENTRY}
+ * to see if this is the first time user has entered PIP for the component.
+ */
+ public boolean hasSaveReentryBounds() {
+ return mReentrySnapFraction != INVALID_SNAP_FRACTION;
+ }
+
public Rect getDisplayBounds() {
return new Rect(0, 0, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight);
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
index e072dd14b0594..461fdef2b7552 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
@@ -29,6 +29,7 @@ import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_CON
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_DISMISS_FRACTION;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_MENU_STATE;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_SHOW_MENU_WITH_DELAY;
+import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_SHOW_RESIZE_HANDLE;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_STACK_BOUNDS;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_WILL_RESIZE_MENU;
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
@@ -119,6 +120,7 @@ public class PipMenuActivity extends Activity {
private LinearLayout mActionsGroup;
private View mSettingsButton;
private View mDismissButton;
+ private View mResizeHandle;
private int mBetweenActionPaddingLand;
private AnimatorSet mMenuContainerAnimator;
@@ -142,7 +144,8 @@ public class PipMenuActivity extends Activity {
data.getParcelable(EXTRA_STACK_BOUNDS),
data.getBoolean(EXTRA_ALLOW_TIMEOUT),
data.getBoolean(EXTRA_WILL_RESIZE_MENU),
- data.getBoolean(EXTRA_SHOW_MENU_WITH_DELAY));
+ data.getBoolean(EXTRA_SHOW_MENU_WITH_DELAY),
+ data.getBoolean(EXTRA_SHOW_RESIZE_HANDLE));
break;
}
case MESSAGE_POKE_MENU:
@@ -212,6 +215,8 @@ public class PipMenuActivity extends Activity {
expandPip();
}
});
+ mResizeHandle = findViewById(R.id.resize_handle);
+ mResizeHandle.setAlpha(0);
mActionsGroup = findViewById(R.id.actions_group);
mBetweenActionPaddingLand = getResources().getDimensionPixelSize(
R.dimen.pip_between_action_padding_land);
@@ -342,7 +347,7 @@ public class PipMenuActivity extends Activity {
}
private void showMenu(int menuState, Rect stackBounds, boolean allowMenuTimeout,
- boolean resizeMenuOnShow, boolean withDelay) {
+ boolean resizeMenuOnShow, boolean withDelay, boolean showResizeHandle) {
mAllowMenuTimeout = allowMenuTimeout;
if (mMenuState != menuState) {
// Disallow touches if the menu needs to resize while showing, and we are transitioning
@@ -363,10 +368,14 @@ public class PipMenuActivity extends Activity {
mSettingsButton.getAlpha(), 1f);
ObjectAnimator dismissAnim = ObjectAnimator.ofFloat(mDismissButton, View.ALPHA,
mDismissButton.getAlpha(), 1f);
+ ObjectAnimator resizeAnim = ObjectAnimator.ofFloat(mResizeHandle, View.ALPHA,
+ mResizeHandle.getAlpha(), menuState == MENU_STATE_CLOSE && showResizeHandle
+ ? 1f : 0f);
if (menuState == MENU_STATE_FULL) {
- mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim);
+ mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim,
+ resizeAnim);
} else {
- mMenuContainerAnimator.playTogether(dismissAnim);
+ mMenuContainerAnimator.playTogether(dismissAnim, resizeAnim);
}
mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_IN);
mMenuContainerAnimator.setDuration(MENU_FADE_DURATION);
@@ -418,7 +427,9 @@ public class PipMenuActivity extends Activity {
mSettingsButton.getAlpha(), 0f);
ObjectAnimator dismissAnim = ObjectAnimator.ofFloat(mDismissButton, View.ALPHA,
mDismissButton.getAlpha(), 0f);
- mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim);
+ ObjectAnimator resizeAnim = ObjectAnimator.ofFloat(mResizeHandle, View.ALPHA,
+ mResizeHandle.getAlpha(), 0f);
+ mMenuContainerAnimator.playTogether(menuAnim, settingsAnim, dismissAnim, resizeAnim);
mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_OUT);
mMenuContainerAnimator.setDuration(animate ? MENU_FADE_DURATION : 0);
mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() {
@@ -463,7 +474,9 @@ public class PipMenuActivity extends Activity {
boolean allowMenuTimeout = intent.getBooleanExtra(EXTRA_ALLOW_TIMEOUT, true);
boolean willResizeMenu = intent.getBooleanExtra(EXTRA_WILL_RESIZE_MENU, false);
boolean withDelay = intent.getBooleanExtra(EXTRA_SHOW_MENU_WITH_DELAY, false);
- showMenu(menuState, stackBounds, allowMenuTimeout, willResizeMenu, withDelay);
+ boolean showResizeHandle = intent.getBooleanExtra(EXTRA_SHOW_RESIZE_HANDLE, false);
+ showMenu(menuState, stackBounds, allowMenuTimeout, willResizeMenu, withDelay,
+ showResizeHandle);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
index 1608f833c1699..36a9a34dce17e 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
@@ -65,6 +65,7 @@ public class PipMenuActivityController {
public static final String EXTRA_DISMISS_FRACTION = "dismiss_fraction";
public static final String EXTRA_MENU_STATE = "menu_state";
public static final String EXTRA_SHOW_MENU_WITH_DELAY = "show_menu_with_delay";
+ public static final String EXTRA_SHOW_RESIZE_HANDLE = "show_resize_handle";
public static final int MESSAGE_MENU_STATE_CHANGED = 100;
public static final int MESSAGE_EXPAND_PIP = 101;
@@ -248,7 +249,7 @@ public class PipMenuActivityController {
// start, then start it
startMenuActivity(MENU_STATE_NONE, null /* stackBounds */,
false /* allowMenuTimeout */, false /* resizeMenuOnShow */,
- false /* withDelay */);
+ false /* withDelay */, false /* showResizeHandle */);
}
}
@@ -257,28 +258,29 @@ public class PipMenuActivityController {
* PiP window transition is finished.
*/
public void showMenuWithDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout,
- boolean willResizeMenu) {
+ boolean willResizeMenu, boolean showResizeHandle) {
showMenuInternal(menuState, stackBounds, allowMenuTimeout, willResizeMenu,
- true /* withDelay */);
+ true /* withDelay */, showResizeHandle);
}
/**
* Shows the menu activity immediately.
*/
public void showMenu(int menuState, Rect stackBounds, boolean allowMenuTimeout,
- boolean willResizeMenu) {
+ boolean willResizeMenu, boolean showResizeHandle) {
showMenuInternal(menuState, stackBounds, allowMenuTimeout, willResizeMenu,
- false /* withDelay */);
+ false /* withDelay */, showResizeHandle);
}
private void showMenuInternal(int menuState, Rect stackBounds, boolean allowMenuTimeout,
- boolean willResizeMenu, boolean withDelay) {
+ boolean willResizeMenu, boolean withDelay, boolean showResizeHandle) {
if (DEBUG) {
Log.d(TAG, "showMenu() state=" + menuState
+ " hasActivity=" + (mToActivityMessenger != null)
+ " allowMenuTimeout=" + allowMenuTimeout
+ " willResizeMenu=" + willResizeMenu
+ " withDelay=" + withDelay
+ + " showResizeHandle=" + showResizeHandle
+ " callers=\n" + Debug.getCallers(5, " "));
}
@@ -291,6 +293,7 @@ public class PipMenuActivityController {
data.putBoolean(EXTRA_ALLOW_TIMEOUT, allowMenuTimeout);
data.putBoolean(EXTRA_WILL_RESIZE_MENU, willResizeMenu);
data.putBoolean(EXTRA_SHOW_MENU_WITH_DELAY, withDelay);
+ data.putBoolean(EXTRA_SHOW_RESIZE_HANDLE, showResizeHandle);
Message m = Message.obtain();
m.what = PipMenuActivity.MESSAGE_SHOW_MENU;
m.obj = data;
@@ -302,7 +305,8 @@ public class PipMenuActivityController {
} else if (!mStartActivityRequested || isStartActivityRequestedElapsed()) {
// If we haven't requested the start activity, or if it previously took too long to
// start, then start it
- startMenuActivity(menuState, stackBounds, allowMenuTimeout, willResizeMenu, withDelay);
+ startMenuActivity(menuState, stackBounds, allowMenuTimeout, willResizeMenu, withDelay,
+ showResizeHandle);
}
}
@@ -405,7 +409,7 @@ public class PipMenuActivityController {
* Starts the menu activity on the top task of the pinned stack.
*/
private void startMenuActivity(int menuState, Rect stackBounds, boolean allowMenuTimeout,
- boolean willResizeMenu, boolean withDelay) {
+ boolean willResizeMenu, boolean withDelay, boolean showResizeHandle) {
try {
StackInfo pinnedStackInfo = ActivityTaskManager.getService().getStackInfo(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
@@ -422,6 +426,7 @@ public class PipMenuActivityController {
intent.putExtra(EXTRA_ALLOW_TIMEOUT, allowMenuTimeout);
intent.putExtra(EXTRA_WILL_RESIZE_MENU, willResizeMenu);
intent.putExtra(EXTRA_SHOW_MENU_WITH_DELAY, withDelay);
+ intent.putExtra(EXTRA_SHOW_RESIZE_HANDLE, showResizeHandle);
ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
options.setLaunchTaskId(
pinnedStackInfo.taskIds[pinnedStackInfo.taskIds.length - 1]);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index 5dbeedb5a1992..ecd80a301d521 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -204,7 +204,7 @@ public class PipTouchHandler {
@Override
public void onPipShowMenu() {
mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
- true /* allowMenuTimeout */, willResizeMenu());
+ true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle());
}
}
@@ -236,7 +236,7 @@ public class PipTouchHandler {
this::updateMovementBounds);
mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler,
() -> mMenuController.showMenuWithDelay(MENU_STATE_FULL, mMotionHelper.getBounds(),
- true /* allowMenuTimeout */, willResizeMenu()));
+ true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle()));
Resources res = context.getResources();
mExpandedShortestEdgeSize = res.getDimensionPixelSize(
@@ -311,6 +311,10 @@ public class PipTouchHandler {
mMagneticTargetAnimator = PhysicsAnimator.getInstance(mTargetView);
}
+ private boolean shouldShowResizeHandle() {
+ return !mPipBoundsHandler.hasSaveReentryBounds();
+ }
+
public void setTouchGesture(PipTouchGesture gesture) {
mGesture = gesture;
}
@@ -323,7 +327,8 @@ public class PipTouchHandler {
// Only show the menu if the user isn't currently interacting with the PiP
if (!mTouchState.isUserInteracting()) {
mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
- false /* allowMenuTimeout */, willResizeMenu());
+ false /* allowMenuTimeout */, willResizeMenu(),
+ shouldShowResizeHandle());
}
}
@@ -359,7 +364,8 @@ public class PipTouchHandler {
if (mShowPipMenuOnAnimationEnd) {
mMenuController.showMenu(MENU_STATE_CLOSE, mMotionHelper.getBounds(),
- true /* allowMenuTimeout */, false /* willResizeMenu */);
+ true /* allowMenuTimeout */, false /* willResizeMenu */,
+ shouldShowResizeHandle());
mShowPipMenuOnAnimationEnd = false;
}
}
@@ -566,7 +572,8 @@ public class PipTouchHandler {
private void onAccessibilityShowMenu() {
mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
- true /* allowMenuTimeout */, willResizeMenu());
+ true /* allowMenuTimeout */, willResizeMenu(),
+ shouldShowResizeHandle());
}
private boolean handleTouchEvent(InputEvent inputEvent) {
@@ -642,7 +649,8 @@ public class PipTouchHandler {
// Let's not enable menu show/hide for a11y services.
if (!mAccessibilityManager.isTouchExplorationEnabled()) {
mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
- false /* allowMenuTimeout */, false /* willResizeMenu */);
+ false /* allowMenuTimeout */, false /* willResizeMenu */,
+ shouldShowResizeHandle());
}
case MotionEvent.ACTION_HOVER_MOVE: {
if (!shouldDeliverToMenu && !mSendingHoverAccessibilityEvents) {
@@ -905,7 +913,8 @@ public class PipTouchHandler {
// If the menu is still visible, then just poke the menu so that
// it will timeout after the user stops touching it
mMenuController.showMenu(mMenuState, mMotionHelper.getBounds(),
- true /* allowMenuTimeout */, willResizeMenu());
+ true /* allowMenuTimeout */, willResizeMenu(),
+ shouldShowResizeHandle());
}
mShouldHideMenuAfterFling = mMenuState == MENU_STATE_NONE;
@@ -922,7 +931,8 @@ public class PipTouchHandler {
// User has stalled long enough for this not to be a drag or a double tap, just
// expand the menu
mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
- true /* allowMenuTimeout */, willResizeMenu());
+ true /* allowMenuTimeout */, willResizeMenu(),
+ shouldShowResizeHandle());
} else {
// Next touch event _may_ be the second tap for the double-tap, schedule a
// fallback runnable to trigger the menu if no touch event occurs before the