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

Commit 8adc4dd9 authored by Gavin Williams's avatar Gavin Williams Committed by Android (Google) Code Review
Browse files

Merge "Autoclick: Center indicator ring around the mouse" into main

parents 6cce84e0 d438db7b
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -928,13 +928,18 @@ public class AutoclickController extends BaseEventStreamTransformation {
            boolean moved = detectMovement(event);
            cacheLastEvent(event, policyFlags, mLastMotionEvent == null || moved /* useAsAnchor */);

            if (moved) {
                rescheduleClick(mDelay);

            if (Flags.enableAutoclickIndicator()) {
                // Give the indicator the latest mouse coordinates for when the indicator is ready
                // to redraw.
                final int pointerIndex = event.getActionIndex();
                mAutoclickIndicatorView.setCoordination(
                        event.getX(pointerIndex), event.getY(pointerIndex));
            }

            if (moved) {
                rescheduleClick(mDelay);

                if (Flags.enableAutoclickIndicator()) {
                    mAutoclickIndicatorScheduler.update();
                }
            }
+15 −9
Original line number Diff line number Diff line
@@ -53,9 +53,13 @@ public class AutoclickIndicatorView extends View {

    private final RectF mRingRect;

    // x and y coordinates of the visual indicator.
    private float mX;
    private float mY;
    // x and y coordinates of the mouse.
    private float mMouseX;
    private float mMouseY;

    // x and y coordinates of the visual indicator, set when drawing of the indicator begins.
    private float mSnapshotX;
    private float mSnapshotY;

    // Current sweep angle of the animated ring.
    private float mSweepAngle;
@@ -114,10 +118,10 @@ public class AutoclickIndicatorView extends View {

        if (showIndicator) {
            mRingRect.set(
                    /* left= */ mX - mRadius,
                    /* top= */ mY - mRadius,
                    /* right= */ mX + mRadius,
                    /* bottom= */ mY + mRadius);
                    /* left= */ mSnapshotX - mRadius,
                    /* top= */ mSnapshotY - mRadius,
                    /* right= */ mSnapshotX + mRadius,
                    /* bottom= */ mSnapshotY + mRadius);
            canvas.drawArc(mRingRect, /* startAngle= */ -90, mSweepAngle, false, mPaint);
        }
    }
@@ -134,8 +138,8 @@ public class AutoclickIndicatorView extends View {
    }

    public void setCoordination(float x, float y) {
        mX = x;
        mY = y;
        mMouseX = x;
        mMouseY = y;
    }

    public void setRadius(int radius) {
@@ -148,6 +152,8 @@ public class AutoclickIndicatorView extends View {
    }

    public void redrawIndicator() {
        mSnapshotX = mMouseX;
        mSnapshotY = mMouseY;
        showIndicator = true;
        invalidate();
        mAnimator.start();