Merge "Differentiate user resize and system expand" into rvc-dev
This commit is contained in:
@@ -339,18 +339,18 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPipTransitionFinished(ComponentName activity, int direction) {
|
public void onPipTransitionFinished(ComponentName activity, int direction) {
|
||||||
onPipTransitionFinishedOrCanceled();
|
onPipTransitionFinishedOrCanceled(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPipTransitionCanceled(ComponentName activity, int direction) {
|
public void onPipTransitionCanceled(ComponentName activity, int direction) {
|
||||||
onPipTransitionFinishedOrCanceled();
|
onPipTransitionFinishedOrCanceled(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPipTransitionFinishedOrCanceled() {
|
private void onPipTransitionFinishedOrCanceled(int direction) {
|
||||||
// Re-enable touches after the animation completes
|
// Re-enable touches after the animation completes
|
||||||
mTouchHandler.setTouchEnabled(true);
|
mTouchHandler.setTouchEnabled(true);
|
||||||
mTouchHandler.onPinnedStackAnimationEnded();
|
mTouchHandler.onPinnedStackAnimationEnded(direction);
|
||||||
mMenuController.onPinnedStackAnimationEnded();
|
mMenuController.onPinnedStackAnimationEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -129,9 +130,7 @@ public class PipMenuActivity extends Activity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler(Looper.getMainLooper()) {
|
||||||
private Messenger mToControllerMessenger;
|
|
||||||
private Messenger mMessenger = new Messenger(new Handler() {
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
@@ -174,7 +173,9 @@ public class PipMenuActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
private Messenger mToControllerMessenger;
|
||||||
|
private Messenger mMessenger = new Messenger(mHandler);
|
||||||
|
|
||||||
private final Runnable mFinishRunnable = new Runnable() {
|
private final Runnable mFinishRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.graphics.Rect;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -122,7 +123,7 @@ public class PipMenuActivityController {
|
|||||||
private boolean mStartActivityRequested;
|
private boolean mStartActivityRequested;
|
||||||
private long mStartActivityRequestedTime;
|
private long mStartActivityRequestedTime;
|
||||||
private Messenger mToActivityMessenger;
|
private Messenger mToActivityMessenger;
|
||||||
private Handler mHandler = new Handler() {
|
private Handler mHandler = new Handler(Looper.getMainLooper()) {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
@@ -133,15 +134,15 @@ public class PipMenuActivityController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MESSAGE_EXPAND_PIP: {
|
case MESSAGE_EXPAND_PIP: {
|
||||||
mListeners.forEach(l -> l.onPipExpand());
|
mListeners.forEach(Listener::onPipExpand);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MESSAGE_DISMISS_PIP: {
|
case MESSAGE_DISMISS_PIP: {
|
||||||
mListeners.forEach(l -> l.onPipDismiss());
|
mListeners.forEach(Listener::onPipDismiss);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MESSAGE_SHOW_MENU: {
|
case MESSAGE_SHOW_MENU: {
|
||||||
mListeners.forEach(l -> l.onPipShowMenu());
|
mListeners.forEach(Listener::onPipShowMenu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
|
case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
|
||||||
@@ -259,6 +260,8 @@ public class PipMenuActivityController {
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "showMenu() state=" + menuState
|
Log.d(TAG, "showMenu() state=" + menuState
|
||||||
+ " hasActivity=" + (mToActivityMessenger != null)
|
+ " hasActivity=" + (mToActivityMessenger != null)
|
||||||
|
+ " allowMenuTimeout=" + allowMenuTimeout
|
||||||
|
+ " willResizeMenu=" + willResizeMenu
|
||||||
+ " callers=\n" + Debug.getCallers(5, " "));
|
+ " callers=\n" + Debug.getCallers(5, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public class PipResizeGestureHandler {
|
|||||||
|
|
||||||
private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
|
private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
|
||||||
private final PipBoundsHandler mPipBoundsHandler;
|
private final PipBoundsHandler mPipBoundsHandler;
|
||||||
private final PipTouchHandler mPipTouchHandler;
|
|
||||||
private final PipMotionHelper mMotionHelper;
|
private final PipMotionHelper mMotionHelper;
|
||||||
private final int mDisplayId;
|
private final int mDisplayId;
|
||||||
private final Executor mMainExecutor;
|
private final Executor mMainExecutor;
|
||||||
@@ -70,10 +69,10 @@ public class PipResizeGestureHandler {
|
|||||||
private final Rect mTmpBounds = new Rect();
|
private final Rect mTmpBounds = new Rect();
|
||||||
private final int mDelta;
|
private final int mDelta;
|
||||||
|
|
||||||
private boolean mAllowGesture = false;
|
private boolean mAllowGesture;
|
||||||
private boolean mIsAttached;
|
private boolean mIsAttached;
|
||||||
private boolean mIsEnabled;
|
private boolean mIsEnabled;
|
||||||
private boolean mEnablePipResize;
|
private boolean mEnableUserResize;
|
||||||
|
|
||||||
private InputMonitor mInputMonitor;
|
private InputMonitor mInputMonitor;
|
||||||
private InputEventReceiver mInputEventReceiver;
|
private InputEventReceiver mInputEventReceiver;
|
||||||
@@ -82,21 +81,20 @@ public class PipResizeGestureHandler {
|
|||||||
private int mCtrlType;
|
private int mCtrlType;
|
||||||
|
|
||||||
public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
|
public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
|
||||||
PipTouchHandler pipTouchHandler, PipMotionHelper motionHelper,
|
PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
|
||||||
DeviceConfigProxy deviceConfig, PipTaskOrganizer pipTaskOrganizer) {
|
PipTaskOrganizer pipTaskOrganizer) {
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
context.getDisplay().getMetrics(mDisplayMetrics);
|
context.getDisplay().getMetrics(mDisplayMetrics);
|
||||||
mDisplayId = context.getDisplayId();
|
mDisplayId = context.getDisplayId();
|
||||||
mMainExecutor = context.getMainExecutor();
|
mMainExecutor = context.getMainExecutor();
|
||||||
mPipBoundsHandler = pipBoundsHandler;
|
mPipBoundsHandler = pipBoundsHandler;
|
||||||
mPipTouchHandler = pipTouchHandler;
|
|
||||||
mMotionHelper = motionHelper;
|
mMotionHelper = motionHelper;
|
||||||
mPipTaskOrganizer = pipTaskOrganizer;
|
mPipTaskOrganizer = pipTaskOrganizer;
|
||||||
|
|
||||||
context.getDisplay().getRealSize(mMaxSize);
|
context.getDisplay().getRealSize(mMaxSize);
|
||||||
mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size);
|
mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size);
|
||||||
|
|
||||||
mEnablePipResize = DeviceConfig.getBoolean(
|
mEnableUserResize = DeviceConfig.getBoolean(
|
||||||
DeviceConfig.NAMESPACE_SYSTEMUI,
|
DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
PIP_USER_RESIZE,
|
PIP_USER_RESIZE,
|
||||||
/* defaultValue = */ true);
|
/* defaultValue = */ true);
|
||||||
@@ -105,7 +103,7 @@ public class PipResizeGestureHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void onPropertiesChanged(DeviceConfig.Properties properties) {
|
public void onPropertiesChanged(DeviceConfig.Properties properties) {
|
||||||
if (properties.getKeyset().contains(PIP_USER_RESIZE)) {
|
if (properties.getKeyset().contains(PIP_USER_RESIZE)) {
|
||||||
mEnablePipResize = properties.getBoolean(
|
mEnableUserResize = properties.getBoolean(
|
||||||
PIP_USER_RESIZE, /* defaultValue = */ true);
|
PIP_USER_RESIZE, /* defaultValue = */ true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,7 +132,7 @@ public class PipResizeGestureHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateIsEnabled() {
|
private void updateIsEnabled() {
|
||||||
boolean isEnabled = mIsAttached && mEnablePipResize;
|
boolean isEnabled = mIsAttached && mEnableUserResize;
|
||||||
if (isEnabled == mIsEnabled) {
|
if (isEnabled == mIsEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.pip.phone;
|
package com.android.systemui.pip.phone;
|
||||||
|
|
||||||
|
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
|
||||||
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
|
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
|
||||||
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
|
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
|
||||||
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
|
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
|
||||||
@@ -56,6 +57,7 @@ import androidx.dynamicanimation.animation.SpringForce;
|
|||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.os.logging.MetricsLoggerWrapper;
|
import com.android.internal.os.logging.MetricsLoggerWrapper;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.pip.PipAnimationController;
|
||||||
import com.android.systemui.pip.PipBoundsHandler;
|
import com.android.systemui.pip.PipBoundsHandler;
|
||||||
import com.android.systemui.pip.PipSnapAlgorithm;
|
import com.android.systemui.pip.PipSnapAlgorithm;
|
||||||
import com.android.systemui.pip.PipTaskOrganizer;
|
import com.android.systemui.pip.PipTaskOrganizer;
|
||||||
@@ -229,7 +231,7 @@ public class PipTouchHandler {
|
|||||||
mMotionHelper = new PipMotionHelper(mContext, activityTaskManager, pipTaskOrganizer,
|
mMotionHelper = new PipMotionHelper(mContext, activityTaskManager, pipTaskOrganizer,
|
||||||
mMenuController, mSnapAlgorithm, mFlingAnimationUtils, floatingContentCoordinator);
|
mMenuController, mSnapAlgorithm, mFlingAnimationUtils, floatingContentCoordinator);
|
||||||
mPipResizeGestureHandler =
|
mPipResizeGestureHandler =
|
||||||
new PipResizeGestureHandler(context, pipBoundsHandler, this, mMotionHelper,
|
new PipResizeGestureHandler(context, pipBoundsHandler, mMotionHelper,
|
||||||
deviceConfig, pipTaskOrganizer);
|
deviceConfig, pipTaskOrganizer);
|
||||||
mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler,
|
mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler,
|
||||||
() -> mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
|
() -> mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
|
||||||
@@ -343,11 +345,16 @@ public class PipTouchHandler {
|
|||||||
mPipResizeGestureHandler.onActivityUnpinned();
|
mPipResizeGestureHandler.onActivityUnpinned();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPinnedStackAnimationEnded() {
|
public void onPinnedStackAnimationEnded(
|
||||||
|
@PipAnimationController.TransitionDirection int direction) {
|
||||||
// Always synchronize the motion helper bounds once PiP animations finish
|
// Always synchronize the motion helper bounds once PiP animations finish
|
||||||
mMotionHelper.synchronizePinnedStackBounds();
|
mMotionHelper.synchronizePinnedStackBounds();
|
||||||
updateMovementBounds();
|
updateMovementBounds();
|
||||||
|
if (direction == TRANSITION_DIRECTION_TO_PIP) {
|
||||||
|
// updates mResizedBounds only if it's an entering PiP animation
|
||||||
|
// mResized should be otherwise updated in setMenuState.
|
||||||
mResizedBounds.set(mMotionHelper.getBounds());
|
mResizedBounds.set(mMotionHelper.getBounds());
|
||||||
|
}
|
||||||
|
|
||||||
if (mShowPipMenuOnAnimationEnd) {
|
if (mShowPipMenuOnAnimationEnd) {
|
||||||
mMenuController.showMenu(MENU_STATE_CLOSE, mMotionHelper.getBounds(),
|
mMenuController.showMenu(MENU_STATE_CLOSE, mMotionHelper.getBounds(),
|
||||||
|
|||||||
Reference in New Issue
Block a user