Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit daf306e4 authored by Winson Chung's avatar Winson Chung Committed by Automerger Merge Worker
Browse files

Merge "Only handle resize touches if starting gesture within resize area" into...

Merge "Only handle resize touches if starting gesture within resize area" into rvc-dev am: dccddad3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12039361

Change-Id: I425e42beefb7f2c3d6d33d7fb3bb81c84a5bb622
parents 8ea17a21 dccddad3
Loading
Loading
Loading
Loading
+20 −3
Original line number Original line Diff line number Diff line
@@ -55,7 +55,9 @@ import com.android.systemui.pip.PipBoundsHandler;
import com.android.systemui.pip.PipTaskOrganizer;
import com.android.systemui.pip.PipTaskOrganizer;
import com.android.systemui.util.DeviceConfigProxy;
import com.android.systemui.util.DeviceConfigProxy;


import java.io.PrintWriter;
import java.util.concurrent.Executor;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.function.Supplier;


/**
/**
@@ -94,7 +96,7 @@ public class PipResizeGestureHandler {
    private final Rect mTmpBottomLeftCorner = new Rect();
    private final Rect mTmpBottomLeftCorner = new Rect();
    private final Rect mTmpBottomRightCorner = new Rect();
    private final Rect mTmpBottomRightCorner = new Rect();
    private final Rect mDisplayBounds = new Rect();
    private final Rect mDisplayBounds = new Rect();
    private final Supplier<Rect> mMovementBoundsSupplier;
    private final Function<Rect, Rect> mMovementBoundsSupplier;
    private final Runnable mUpdateMovementBoundsRunnable;
    private final Runnable mUpdateMovementBoundsRunnable;


    private int mDelta;
    private int mDelta;
@@ -113,7 +115,7 @@ public class PipResizeGestureHandler {


    public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
    public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
            PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
            PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
            PipTaskOrganizer pipTaskOrganizer, Supplier<Rect> movementBoundsSupplier,
            PipTaskOrganizer pipTaskOrganizer, Function<Rect, Rect> movementBoundsSupplier,
            Runnable updateMovementBoundsRunnable, SysUiState sysUiState) {
            Runnable updateMovementBoundsRunnable, SysUiState sysUiState) {
        mContext = context;
        mContext = context;
        mDisplayId = context.getDisplayId();
        mDisplayId = context.getDisplayId();
@@ -244,10 +246,15 @@ public class PipResizeGestureHandler {
        return mTmpRegion.contains(x, y);
        return mTmpRegion.contains(x, y);
    }
    }


    public boolean willStartResizeGesture(MotionEvent ev) {
        return mEnableUserResize && isInValidSysUiState()
                && isWithinTouchRegion((int) ev.getRawX(), (int) ev.getRawY());
    }

    private void setCtrlType(int x, int y) {
    private void setCtrlType(int x, int y) {
        final Rect currentPipBounds = mMotionHelper.getBounds();
        final Rect currentPipBounds = mMotionHelper.getBounds();


        Rect movementBounds = mMovementBoundsSupplier.get();
        Rect movementBounds = mMovementBoundsSupplier.apply(currentPipBounds);
        mDisplayBounds.set(movementBounds.left,
        mDisplayBounds.set(movementBounds.left,
                movementBounds.top,
                movementBounds.top,
                movementBounds.right + currentPipBounds.width(),
                movementBounds.right + currentPipBounds.width(),
@@ -353,6 +360,16 @@ public class PipResizeGestureHandler {
        mMinSize.set(minX, minY);
        mMinSize.set(minX, minY);
    }
    }


    public void dump(PrintWriter pw, String prefix) {
        final String innerPrefix = prefix + "  ";
        pw.println(prefix + TAG);
        pw.println(innerPrefix + "mAllowGesture=" + mAllowGesture);
        pw.println(innerPrefix + "mIsAttached=" + mIsAttached);
        pw.println(innerPrefix + "mIsEnabled=" + mIsEnabled);
        pw.println(innerPrefix + "mEnableUserResize=" + mEnableUserResize);
        pw.println(innerPrefix + "mThresholdCrossed=" + mThresholdCrossed);
    }

    class SysUiInputEventReceiver extends BatchedInputEventReceiver {
    class SysUiInputEventReceiver extends BatchedInputEventReceiver {
        SysUiInputEventReceiver(InputChannel channel, Looper looper) {
        SysUiInputEventReceiver(InputChannel channel, Looper looper) {
            super(channel, looper, Choreographer.getSfInstance());
            super(channel, looper, Choreographer.getSfInstance());
+13 −7
Original line number Original line Diff line number Diff line
@@ -644,12 +644,12 @@ public class PipTouchHandler {
        }
        }


        MotionEvent ev = (MotionEvent) inputEvent;
        MotionEvent ev = (MotionEvent) inputEvent;
        if (!mTouchState.isDragging()
        if (ev.getActionMasked() == MotionEvent.ACTION_DOWN
                && !mMagnetizedPip.getObjectStuckToTarget()
                && mPipResizeGestureHandler.willStartResizeGesture(ev)) {
                && !mMotionHelper.isAnimating()
            // Initialize the touch state for the gesture, but immediately reset to invalidate the
                && mPipResizeGestureHandler.isWithinTouchRegion(
            // gesture
                        (int) ev.getRawX(), (int) ev.getRawY())) {
            mTouchState.onTouchEvent(ev);
            mTouchState.onTouchEvent(ev);
            mTouchState.reset();
            return true;
            return true;
        }
        }


@@ -1032,8 +1032,11 @@ public class PipTouchHandler {
                isMenuExpanded  && willResizeMenu() ? mExpandedShortestEdgeSize : 0);
                isMenuExpanded  && willResizeMenu() ? mExpandedShortestEdgeSize : 0);
    }
    }


    private Rect getMovementBounds() {
    private Rect getMovementBounds(Rect curBounds) {
        return mMovementBounds;
        Rect movementBounds = new Rect();
        mSnapAlgorithm.getMovementBounds(curBounds, mInsetBounds,
                movementBounds, mIsImeShowing ? mImeHeight : 0);
        return movementBounds;
    }
    }


    /**
    /**
@@ -1065,6 +1068,9 @@ public class PipTouchHandler {
        pw.println(innerPrefix + "mMovementBoundsExtraOffsets=" + mMovementBoundsExtraOffsets);
        pw.println(innerPrefix + "mMovementBoundsExtraOffsets=" + mMovementBoundsExtraOffsets);
        mTouchState.dump(pw, innerPrefix);
        mTouchState.dump(pw, innerPrefix);
        mMotionHelper.dump(pw, innerPrefix);
        mMotionHelper.dump(pw, innerPrefix);
        if (mPipResizeGestureHandler != null) {
            mPipResizeGestureHandler.dump(pw, innerPrefix);
        }
    }
    }


}
}