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

Commit 862a301b authored by Michael Wright's avatar Michael Wright Committed by Android (Google) Code Review
Browse files

Merge "Paint current points a different color in PointerLocation"

parents f35f56a1 76936eb9
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
        // Trace of previous points.
        private float[] mTraceX = new float[32];
        private float[] mTraceY = new float[32];
        private boolean[] mTraceCurrent = new boolean[32];
        private int mTraceCount;
        
        // True if the pointer is down.
@@ -76,7 +77,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
            mTraceCount = 0;
        }
        
        public void addTrace(float x, float y) {
        public void addTrace(float x, float y, boolean current) {
            int traceCapacity = mTraceX.length;
            if (mTraceCount == traceCapacity) {
                traceCapacity *= 2;
@@ -87,10 +88,15 @@ public class PointerLocationView extends View implements InputDeviceListener {
                float[] newTraceY = new float[traceCapacity];
                System.arraycopy(mTraceY, 0, newTraceY, 0, mTraceCount);
                mTraceY = newTraceY;

                boolean[] newTraceCurrent = new boolean[traceCapacity];
                System.arraycopy(mTraceCurrent, 0, newTraceCurrent, 0, mTraceCount);
                mTraceCurrent= newTraceCurrent;
            }
            
            mTraceX[mTraceCount] = x;
            mTraceY[mTraceCount] = y;
            mTraceCurrent[mTraceCount] = current;
            mTraceCount += 1;
        }
    }
@@ -106,6 +112,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
    private final Paint mTextBackgroundPaint;
    private final Paint mTextLevelPaint;
    private final Paint mPaint;
    private final Paint mCurrentPointPaint;
    private final Paint mTargetPaint;
    private final Paint mPathPaint;
    private final FontMetricsInt mTextMetrics = new FontMetricsInt();
@@ -147,6 +154,11 @@ public class PointerLocationView extends View implements InputDeviceListener {
        mPaint.setARGB(255, 255, 255, 255);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(2);
        mCurrentPointPaint = new Paint();
        mCurrentPointPaint.setAntiAlias(true);
        mCurrentPointPaint.setARGB(255, 255, 0, 0);
        mCurrentPointPaint.setStyle(Paint.Style.STROKE);
        mCurrentPointPaint.setStrokeWidth(2);
        mTargetPaint = new Paint();
        mTargetPaint.setAntiAlias(false);
        mTargetPaint.setARGB(255, 0, 0, 192);
@@ -294,7 +306,8 @@ public class PointerLocationView extends View implements InputDeviceListener {
                }
                if (haveLast) {
                    canvas.drawLine(lastX, lastY, x, y, mPathPaint);
                    canvas.drawPoint(lastX, lastY, mPaint);
                    final Paint paint = ps.mTraceCurrent[i] ? mCurrentPointPaint : mPaint;
                    canvas.drawPoint(lastX, lastY, paint);
                    drawn = true;
                }
                lastX = x;
@@ -574,7 +587,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
                    logCoords("Pointer", action, i, coords, id, event);
                }
                if (ps != null) {
                    ps.addTrace(coords.x, coords.y);
                    ps.addTrace(coords.x, coords.y, false);
                }
            }
        }
@@ -587,7 +600,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
                logCoords("Pointer", action, i, coords, id, event);
            }
            if (ps != null) {
                ps.addTrace(coords.x, coords.y);
                ps.addTrace(coords.x, coords.y, true);
                ps.mXVelocity = mVelocity.getXVelocity(id);
                ps.mYVelocity = mVelocity.getYVelocity(id);
                mVelocity.getEstimator(id, ps.mEstimator);
@@ -626,7 +639,7 @@ public class PointerLocationView extends View implements InputDeviceListener {
                if (mActivePointerId == id) {
                    mActivePointerId = event.getPointerId(index == 0 ? 1 : 0);
                }
                ps.addTrace(Float.NaN, Float.NaN);
                ps.addTrace(Float.NaN, Float.NaN, false);
            }
        }