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

Commit 4ddf1e47 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Remove unused gesture preview trail code

Change-Id: I2aa77675628a4b1655b30852c950f5daae6f0a92
parent c7588446
Loading
Loading
Loading
Loading
+7 −30
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import com.android.inputmethod.latin.ResizableIntArray;
public final class GestureStrokeWithPreviewPoints extends GestureStroke {
    public static final int PREVIEW_CAPACITY = 256;

    private static final boolean ENABLE_INTERPOLATION = true;

    private final ResizableIntArray mPreviewEventTimes = new ResizableIntArray(PREVIEW_CAPACITY);
    private final ResizableIntArray mPreviewXCoordinates = new ResizableIntArray(PREVIEW_CAPACITY);
    private final ResizableIntArray mPreviewYCoordinates = new ResizableIntArray(PREVIEW_CAPACITY);
@@ -32,18 +30,15 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
    private final HermiteInterpolator mInterpolator = new HermiteInterpolator();
    private int mLastInterpolatedPreviewIndex;

    private int mMinPreviewSamplingDistanceSquared;
    private int mLastX;
    private int mLastY;
    private double mMinPreviewSamplingDistance;
    private double mDistanceFromLastSample;

    // TODO: Move these constants to resource.
    // The minimum linear distance between sample points for preview in keyWidth unit.
    private static final float MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH = 0.1f;
    // The minimum trail distance between sample points for preview in keyWidth unit when using
    // interpolation.
    private static final float MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH_WITH_INTERPOLATION = 0.2f;
    private static final float MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH = 0.2f;
    // The angular threshold to use interpolation in radian. PI/12 is 15 degree.
    private static final double INTERPOLATION_ANGULAR_THRESHOLD = Math.PI / 12.0d;
    private static final int MAX_INTERPOLATION_PARTITION = 4;
@@ -70,16 +65,11 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
    @Override
    public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
        super.setKeyboardGeometry(keyWidth, keyboardHeight);
        final float samplingRatioToKeyWidth = ENABLE_INTERPOLATION
                ? MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH_WITH_INTERPOLATION
                : MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
        final float samplingRatioToKeyWidth = MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
        mMinPreviewSamplingDistance = keyWidth * samplingRatioToKeyWidth;
        mMinPreviewSamplingDistanceSquared = (int)(
                mMinPreviewSamplingDistance * mMinPreviewSamplingDistance);
    }

    private boolean needsSampling(final int x, final int y, final boolean isMajorEvent) {
        if (ENABLE_INTERPOLATION) {
        mDistanceFromLastSample += Math.hypot(x - mLastX, y - mLastY);
        mLastX = x;
        mLastY = y;
@@ -90,16 +80,6 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
        return false;
    }

        final int dx = x - mLastX;
        final int dy = y - mLastY;
        if (isMajorEvent || dx * dx + dy * dy >= mMinPreviewSamplingDistanceSquared) {
            mLastX = x;
            mLastY = y;
            return true;
        }
        return false;
    }

    @Override
    public boolean addPointOnKeyboard(final int x, final int y, final int time,
            final boolean isMajorEvent) {
@@ -140,9 +120,6 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
    public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex,
            final ResizableIntArray eventTimes, final ResizableIntArray xCoords,
            final ResizableIntArray yCoords) {
        if (!ENABLE_INTERPOLATION) {
            return lastInterpolatedIndex;
        }
        final int size = mPreviewEventTimes.getLength();
        final int[] pt = mPreviewEventTimes.getPrimitiveArray();
        final int[] px = mPreviewXCoordinates.getPrimitiveArray();