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

Commit b204d4f1 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 2136 into donut

* changes:
  First pass at cleaning up the gestures code.
parents aa983388 c5347279
Loading
Loading
Loading
Loading
+35.3 KiB

File added.

No diff preview for this file type.

core/res/res/raw/lattin_lowercase

deleted100644 → 0
+0 −60

File deleted.

Preview size limit exceeded, changes collapsed.

+17 −18
Original line number Diff line number Diff line
@@ -34,13 +34,11 @@ import java.util.ArrayList;
 */

public class Gesture implements Parcelable {

    private static final long GESTURE_ID_BASE = System.currentTimeMillis();

    private static final int BITMAP_RENDERING_WIDTH = 2;

    private static final boolean BITMAP_RENDERING_ANTIALIAS = true;

    private static final boolean BITMAP_RENDERING_DITHER = true;

    private static int sGestureCount = 0;
@@ -50,7 +48,7 @@ public class Gesture implements Parcelable {
    // the same as its instance ID
    private long mGestureID;

    private ArrayList<GestureStroke> mStrokes = new ArrayList<GestureStroke>();
    private final ArrayList<GestureStroke> mStrokes = new ArrayList<GestureStroke>();

    public Gesture() {
        mGestureID = GESTURE_ID_BASE + sGestureCount++;
@@ -93,12 +91,13 @@ public class Gesture implements Parcelable {
     */
    public float getLength() {
        int len = 0;
        ArrayList<GestureStroke> strokes = mStrokes;
        int count = strokes.size();
        final ArrayList<GestureStroke> strokes = mStrokes;
        final int count = strokes.size();

        for (int i = 0; i < count; i++) {
            GestureStroke stroke = strokes.get(i);
            len += stroke.length;
            len += strokes.get(i).length;
        }

        return len;
    }

@@ -131,11 +130,11 @@ public class Gesture implements Parcelable {
     * @param canvas
     */
    void draw(Canvas canvas, Paint paint) {
        ArrayList<GestureStroke> strokes = mStrokes;
        int count = strokes.size();
        final ArrayList<GestureStroke> strokes = mStrokes;
        final int count = strokes.size();

        for (int i = 0; i < count; i++) {
            GestureStroke stroke = strokes.get(i);
            stroke.draw(canvas, paint);
            strokes.get(i).draw(canvas, paint);
        }
    }

@@ -150,7 +149,6 @@ public class Gesture implements Parcelable {
     * @return the bitmap
     */
    public Bitmap toBitmap(int width, int height, int edge, int numSample, int color) {
        RectF bbx = getBoundingBox();
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.translate(edge, edge);
@@ -162,11 +160,12 @@ public class Gesture implements Parcelable {
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setStrokeWidth(BITMAP_RENDERING_WIDTH);
        ArrayList<GestureStroke> strokes = mStrokes;
        int count = strokes.size();

        final ArrayList<GestureStroke> strokes = mStrokes;
        final int count = strokes.size();

        for (int i = 0; i < count; i++) {
            GestureStroke stroke = strokes.get(i);
            Path path = stroke.toPath(width - 2 * edge, height - 2 * edge, numSample);
            Path path = strokes.get(i).toPath(width - 2 * edge, height - 2 * edge, numSample);
            canvas.drawPath(path, paint);
        }

@@ -183,7 +182,6 @@ public class Gesture implements Parcelable {
     * @return the bitmap
     */
    public Bitmap toBitmap(int width, int height, int edge, int color) {
        RectF bbx = getBoundingBox();
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.translate(edge, edge);
@@ -232,7 +230,8 @@ public class Gesture implements Parcelable {
    public void createFromString(String str) {
        int startIndex = 0;
        int endIndex;
        while ((endIndex = str.indexOf(GestureConstants.STRING_GESTURE_DELIIMITER, startIndex + 1)) != -1) {
        while ((endIndex =
                str.indexOf(GestureConstants.STRING_GESTURE_DELIIMITER, startIndex + 1)) != -1) {
            String token = str.substring(startIndex, endIndex);
            if (startIndex > 0) { // stroke tokens
                addStroke(GestureStroke.createFromString(token));
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.gesture;


public interface GestureActionListener {
    public void onGesturePerformed(GestureOverlay overlay, Gesture gesture);
}
+1 −0
Original line number Diff line number Diff line
@@ -28,4 +28,5 @@ interface GestureConstants {
    static final int STROKE_STRING_BUFFER_SIZE = 1024;
    static final int STROKE_POINT_BUFFER_SIZE = 100; // number of points
    static final int IO_BUFFER_SIZE = 8 * 1024; // 8K
    String LOG_TAG = "GestureLibrary";
}
Loading