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

Commit b922da84 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Fix bimanual gesture preview trail" into jb-mr1-dev

parents b85df9d5 f117f777
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -573,6 +573,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
    private void endBatchInput() {
        synchronized (sAggregratedPointers) {
            mGestureStrokeWithPreviewTrail.appendAllBatchPoints(sAggregratedPointers);
            mGestureStrokeWithPreviewTrail.reset();
            if (getActivePointerTrackerCount() == 1) {
                if (DEBUG_LISTENER) {
                    Log.d(TAG, "onEndBatchInput: batchPoints="
+19 −21
Original line number Diff line number Diff line
@@ -33,15 +33,10 @@ final class GesturePreviewTrail {
    private final ResizableIntArray mYCoordinates = new ResizableIntArray(DEFAULT_CAPACITY);
    private final ResizableIntArray mEventTimes = new ResizableIntArray(DEFAULT_CAPACITY);
    private int mCurrentStrokeId = -1;
    private long mCurrentDownTime;
    // The wall time of the zero value in {@link #mEventTimes}
    private long mCurrentTimeBase;
    private int mTrailStartIndex;

    private final static Xfermode PORTER_DUFF_MODE_SRC =
            new PorterDuffXfermode(PorterDuff.Mode.SRC);

    // Use this value as imaginary zero because x-coordinates may be zero.
    private static final int DOWN_EVENT_MARKER = -128;

    static final class Params {
        public final int mTrailColor;
        public final float mTrailStartWidth;
@@ -69,6 +64,9 @@ final class GesturePreviewTrail {
        }
    }

    // Use this value as imaginary zero because x-coordinates may be zero.
    private static final int DOWN_EVENT_MARKER = -128;

    private static int markAsDownEvent(final int xCoord) {
        return DOWN_EVENT_MARKER - xCoord;
    }
@@ -83,26 +81,23 @@ final class GesturePreviewTrail {
    }

    public void addStroke(final GestureStrokeWithPreviewTrail stroke, final long downTime) {
        final int strokeId = stroke.getGestureStrokeId();
        final boolean isNewStroke = strokeId != mCurrentStrokeId;
        final int trailSize = mEventTimes.getLength();
        stroke.appendPreviewStroke(mEventTimes, mXCoordinates, mYCoordinates);
        final int newTrailSize = mEventTimes.getLength();
        if (stroke.getGestureStrokePreviewSize() == 0) {
        if (mEventTimes.getLength() == trailSize) {
            return;
        }
        if (isNewStroke) {
            final int elapsedTime = (int)(downTime - mCurrentDownTime);
        final int[] eventTimes = mEventTimes.getPrimitiveArray();
        final int strokeId = stroke.getGestureStrokeId();
        if (strokeId != mCurrentStrokeId) {
            final int elapsedTime = (int)(downTime - mCurrentTimeBase);
            for (int i = mTrailStartIndex; i < trailSize; i++) {
                // Decay the previous strokes' event times.
                eventTimes[i] -= elapsedTime;
            }

            if (newTrailSize > trailSize) {
            final int[] xCoords = mXCoordinates.getPrimitiveArray();
                xCoords[trailSize] = markAsDownEvent(xCoords[trailSize]);
            }
            mCurrentDownTime = downTime;
            final int downIndex = trailSize;
            xCoords[downIndex] = markAsDownEvent(xCoords[downIndex]);
            mCurrentTimeBase = downTime - eventTimes[downIndex];
            mCurrentStrokeId = strokeId;
        }
    }
@@ -123,6 +118,9 @@ final class GesturePreviewTrail {
                / params.mTrailLingerDuration, 0.0f);
    }

    private final static Xfermode PORTER_DUFF_MODE_SRC =
            new PorterDuffXfermode(PorterDuff.Mode.SRC);

    /**
     * Draw gesture preview trail
     * @param canvas The canvas to draw the gesture preview trail
@@ -139,7 +137,7 @@ final class GesturePreviewTrail {
        final int[] eventTimes = mEventTimes.getPrimitiveArray();
        final int[] xCoords = mXCoordinates.getPrimitiveArray();
        final int[] yCoords = mYCoordinates.getPrimitiveArray();
        final int sinceDown = (int)(SystemClock.uptimeMillis() - mCurrentDownTime);
        final int sinceDown = (int)(SystemClock.uptimeMillis() - mCurrentTimeBase);
        int startIndex;
        for (startIndex = mTrailStartIndex; startIndex < trailSize; startIndex++) {
            final int elapsedTime = sinceDown - eventTimes[startIndex];
+0 −1
Original line number Diff line number Diff line
@@ -158,7 +158,6 @@ public class PreviewPlacerView extends RelativeLayout {

        final Paint textPaint = new Paint();
        textPaint.setAntiAlias(true);
        textPaint.setStyle(Paint.Style.FILL);
        textPaint.setTextAlign(Align.CENTER);
        textPaint.setTextSize(gestureFloatingPreviewTextSize);
        mTextPaint = textPaint;