Loading packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java +35 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { private static final int MSG_RESIZE_ANIMATE = 2; private static final int MSG_OFFSET_ANIMATE = 3; private static final int MSG_FINISH_RESIZE = 4; private static final int MSG_RESIZE_USER = 5; private final Handler mMainHandler; private final Handler mUpdateHandler; Loading Loading @@ -164,6 +165,12 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { } break; } case MSG_RESIZE_USER: { Rect startBounds = (Rect) args.arg2; Rect toBounds = (Rect) args.arg3; userResizePip(startBounds, toBounds); break; } } args.recycle(); return true; Loading Loading @@ -323,6 +330,19 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { mUpdateHandler.sendMessage(mUpdateHandler.obtainMessage(MSG_RESIZE_IMMEDIATE, args)); } /** * Directly perform a scaled matrix transformation on the leash. This will not perform any * {@link WindowContainerTransaction} until {@link #scheduleFinishResizePip} is called. */ public void scheduleUserResizePip(Rect startBounds, Rect toBounds, Consumer<Rect> updateBoundsCallback) { SomeArgs args = SomeArgs.obtain(); args.arg1 = updateBoundsCallback; args.arg2 = startBounds; args.arg3 = toBounds; mUpdateHandler.sendMessage(mUpdateHandler.obtainMessage(MSG_RESIZE_USER, args)); } /** * Finish an intermediate resize operation. This is expected to be called after * {@link #scheduleResizePip}. Loading Loading @@ -395,6 +415,21 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { tx.apply(); } private void userResizePip(Rect startBounds, Rect destinationBounds) { if (Looper.myLooper() != mUpdateHandler.getLooper()) { throw new RuntimeException("Callers should call scheduleUserResizePip() instead of " + "this directly"); } // Could happen when dismissPip if (mToken == null || mLeash == null) { Log.w(TAG, "Abort animation, invalid leash"); return; } final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); mSurfaceTransactionHelper.scale(tx, mLeash, startBounds, destinationBounds); tx.apply(); } private void finishResize(SurfaceControl.Transaction tx, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction) { if (Looper.myLooper() != mUpdateHandler.getLooper()) { Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java +4 −1 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ public class PipResizeGestureHandler { private final Point mMaxSize = new Point(); private final Point mMinSize = new Point(); private final Rect mLastResizeBounds = new Rect(); private final Rect mLastDownBounds = new Rect(); private final Rect mTmpBounds = new Rect(); private final int mDelta; Loading Loading @@ -192,6 +193,7 @@ public class PipResizeGestureHandler { mAllowGesture = isWithinTouchRegion((int) ev.getX(), (int) ev.getY()); if (mAllowGesture) { mDownPoint.set(ev.getX(), ev.getY()); mLastDownBounds.set(mMotionHelper.getBounds()); } } else if (mAllowGesture) { Loading @@ -208,7 +210,8 @@ public class PipResizeGestureHandler { mDownPoint.x, mDownPoint.y, currentPipBounds, mCtrlType, mMinSize.x, mMinSize.y, mMaxSize, true, true)); mPipBoundsHandler.transformBoundsToAspectRatio(mLastResizeBounds); mPipTaskOrganizer.scheduleResizePip(mLastResizeBounds, null); mPipTaskOrganizer.scheduleUserResizePip(mLastDownBounds, mLastResizeBounds, null); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: Loading Loading
packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java +35 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { private static final int MSG_RESIZE_ANIMATE = 2; private static final int MSG_OFFSET_ANIMATE = 3; private static final int MSG_FINISH_RESIZE = 4; private static final int MSG_RESIZE_USER = 5; private final Handler mMainHandler; private final Handler mUpdateHandler; Loading Loading @@ -164,6 +165,12 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { } break; } case MSG_RESIZE_USER: { Rect startBounds = (Rect) args.arg2; Rect toBounds = (Rect) args.arg3; userResizePip(startBounds, toBounds); break; } } args.recycle(); return true; Loading Loading @@ -323,6 +330,19 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { mUpdateHandler.sendMessage(mUpdateHandler.obtainMessage(MSG_RESIZE_IMMEDIATE, args)); } /** * Directly perform a scaled matrix transformation on the leash. This will not perform any * {@link WindowContainerTransaction} until {@link #scheduleFinishResizePip} is called. */ public void scheduleUserResizePip(Rect startBounds, Rect toBounds, Consumer<Rect> updateBoundsCallback) { SomeArgs args = SomeArgs.obtain(); args.arg1 = updateBoundsCallback; args.arg2 = startBounds; args.arg3 = toBounds; mUpdateHandler.sendMessage(mUpdateHandler.obtainMessage(MSG_RESIZE_USER, args)); } /** * Finish an intermediate resize operation. This is expected to be called after * {@link #scheduleResizePip}. Loading Loading @@ -395,6 +415,21 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub { tx.apply(); } private void userResizePip(Rect startBounds, Rect destinationBounds) { if (Looper.myLooper() != mUpdateHandler.getLooper()) { throw new RuntimeException("Callers should call scheduleUserResizePip() instead of " + "this directly"); } // Could happen when dismissPip if (mToken == null || mLeash == null) { Log.w(TAG, "Abort animation, invalid leash"); return; } final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); mSurfaceTransactionHelper.scale(tx, mLeash, startBounds, destinationBounds); tx.apply(); } private void finishResize(SurfaceControl.Transaction tx, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction) { if (Looper.myLooper() != mUpdateHandler.getLooper()) { Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java +4 −1 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ public class PipResizeGestureHandler { private final Point mMaxSize = new Point(); private final Point mMinSize = new Point(); private final Rect mLastResizeBounds = new Rect(); private final Rect mLastDownBounds = new Rect(); private final Rect mTmpBounds = new Rect(); private final int mDelta; Loading Loading @@ -192,6 +193,7 @@ public class PipResizeGestureHandler { mAllowGesture = isWithinTouchRegion((int) ev.getX(), (int) ev.getY()); if (mAllowGesture) { mDownPoint.set(ev.getX(), ev.getY()); mLastDownBounds.set(mMotionHelper.getBounds()); } } else if (mAllowGesture) { Loading @@ -208,7 +210,8 @@ public class PipResizeGestureHandler { mDownPoint.x, mDownPoint.y, currentPipBounds, mCtrlType, mMinSize.x, mMinSize.y, mMaxSize, true, true)); mPipBoundsHandler.transformBoundsToAspectRatio(mLastResizeBounds); mPipTaskOrganizer.scheduleResizePip(mLastResizeBounds, null); mPipTaskOrganizer.scheduleUserResizePip(mLastDownBounds, mLastResizeBounds, null); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: Loading