summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-05-21 16:23:21 -0700
committerRomain Guy <romainguy@android.com>2009-05-21 18:12:56 -0700
commitdb567c390bd56c05614eaa83c02dbb99f97ad9cc (patch)
tree86399406ca7a53c3d902b3863bf7a944cb7c5c3f
parent384bfa270cdcb5dc3bc9ec396b783e25eb2d9b4d (diff)
downloadframeworks_base-db567c390bd56c05614eaa83c02dbb99f97ad9cc.zip
frameworks_base-db567c390bd56c05614eaa83c02dbb99f97ad9cc.tar.gz
frameworks_base-db567c390bd56c05614eaa83c02dbb99f97ad9cc.tar.bz2
Move the Gestures API to the framework in android.gesture.
-rw-r--r--api/current.xml1091
-rwxr-xr-xcore/java/android/gesture/Gesture.java (renamed from tests/sketch/src/com/android/gesture/Gesture.java)28
-rw-r--r--core/java/android/gesture/GestureConstants.java (renamed from tests/sketch/src/com/android/gesture/GestureConstants.java)5
-rw-r--r--core/java/android/gesture/GestureLibrary.java (renamed from tests/sketch/src/com/android/gesture/GestureLibrary.java)6
-rwxr-xr-xcore/java/android/gesture/GestureOverlayView.java (renamed from tests/sketch/src/com/android/gesture/GestureOverlay.java)65
-rw-r--r--core/java/android/gesture/GesturePoint.java (renamed from tests/sketch/src/com/android/gesture/GesturePoint.java)2
-rw-r--r--core/java/android/gesture/GestureStroke.java (renamed from tests/sketch/src/com/android/gesture/GestureStroke.java)34
-rwxr-xr-xcore/java/android/gesture/GestureUtilities.java (renamed from tests/sketch/src/com/android/gesture/GestureUtilities.java)4
-rwxr-xr-xcore/java/android/gesture/Instance.java (renamed from tests/sketch/src/com/android/gesture/Instance.java)2
-rw-r--r--core/java/android/gesture/InstanceLearner.java (renamed from tests/sketch/src/com/android/gesture/InstanceLearner.java)24
-rwxr-xr-xcore/java/android/gesture/Learner.java (renamed from tests/sketch/src/com/android/gesture/Learner.java)2
-rw-r--r--core/java/android/gesture/LetterRecognizer.java (renamed from tests/sketch/src/com/android/gesture/LetterRecognizer.java)197
-rw-r--r--core/java/android/gesture/OrientedBoundingBox.java (renamed from tests/sketch/src/com/android/gesture/OrientedBoundingBox.java)7
-rwxr-xr-xcore/java/android/gesture/Prediction.java (renamed from tests/sketch/src/com/android/gesture/Prediction.java)2
-rw-r--r--core/java/android/gesture/TouchThroughGestureListener.java (renamed from tests/sketch/src/com/android/gesture/TouchThroughGesturing.java)80
-rw-r--r--core/res/res/raw/latin_lowercasebin36186 -> 28494 bytes
-rwxr-xr-xtests/sketch/AndroidManifest.xml4
-rw-r--r--tests/sketch/src/com/android/gesture/GestureActionListener.java21
-rwxr-xr-xtests/sketch/src/com/android/gesture/GestureListener.java30
-rw-r--r--tests/sketch/src/com/android/gesture/example/ContactListGestureOverlay.java27
-rw-r--r--tests/sketch/src/com/android/gesture/example/GestureEntry.java21
-rwxr-xr-xtests/sketch/src/com/android/gesture/example/GestureLibViewer.java10
-rw-r--r--tests/sketch/tools/Converter.java10
23 files changed, 1369 insertions, 303 deletions
diff --git a/api/current.xml b/api/current.xml
index 5bbf352..085d8b1 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -46164,6 +46164,1097 @@
</method>
</class>
</package>
+<package name="android.gesture"
+>
+<class name="Gesture"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<constructor name="Gesture"
+ type="android.gesture.Gesture"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="addStroke"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="stroke" type="android.gesture.GestureStroke">
+</parameter>
+</method>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getBoundingBox"
+ return="android.graphics.RectF"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getID"
+ return="long"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getLength"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getStrokes"
+ return="java.util.ArrayList&lt;android.gesture.GestureStroke&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getStrokesCount"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="toBitmap"
+ return="android.graphics.Bitmap"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="width" type="int">
+</parameter>
+<parameter name="height" type="int">
+</parameter>
+<parameter name="edge" type="int">
+</parameter>
+<parameter name="numSample" type="int">
+</parameter>
+<parameter name="color" type="int">
+</parameter>
+</method>
+<method name="toBitmap"
+ return="android.graphics.Bitmap"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="width" type="int">
+</parameter>
+<parameter name="height" type="int">
+</parameter>
+<parameter name="edge" type="int">
+</parameter>
+<parameter name="color" type="int">
+</parameter>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="out" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.Creator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="GestureLibrary"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="GestureLibrary"
+ type="android.gesture.GestureLibrary"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="path" type="java.lang.String">
+</parameter>
+</constructor>
+<method name="addGesture"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="entryName" type="java.lang.String">
+</parameter>
+<parameter name="gesture" type="android.gesture.Gesture">
+</parameter>
+</method>
+<method name="getGestureEntries"
+ return="java.util.Set&lt;java.lang.String&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getGestures"
+ return="java.util.ArrayList&lt;android.gesture.Gesture&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="entryName" type="java.lang.String">
+</parameter>
+</method>
+<method name="getOrientationStyle"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSequenceType"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="load"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="recognize"
+ return="java.util.ArrayList&lt;android.gesture.Prediction&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="gesture" type="android.gesture.Gesture">
+</parameter>
+</method>
+<method name="removeEntry"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="entryName" type="java.lang.String">
+</parameter>
+</method>
+<method name="removeGesture"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="entryName" type="java.lang.String">
+</parameter>
+<parameter name="gesture" type="android.gesture.Gesture">
+</parameter>
+</method>
+<method name="save"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="setOrientationStyle"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="style" type="int">
+</parameter>
+</method>
+<method name="setSequenceType"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="type" type="int">
+</parameter>
+</method>
+<field name="ORIENTATION_INVARIANT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ORIENTATION_SENSITIVE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SEQUENCE_INVARIANT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SEQUENCE_SENSITIVE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="GestureOverlayView"
+ extends="android.view.View"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="GestureOverlayView"
+ type="android.gesture.GestureOverlayView"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+</constructor>
+<constructor name="GestureOverlayView"
+ type="android.gesture.GestureOverlayView"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="attrs" type="android.util.AttributeSet">
+</parameter>
+</constructor>
+<method name="addOnGestureListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.gesture.GestureOverlayView.OnGestureListener">
+</parameter>
+</method>
+<method name="cancelFadingOut"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="clear"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fadeOut" type="boolean">
+</parameter>
+</method>
+<method name="getCurrentGesture"
+ return="android.gesture.Gesture"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getCurrentStroke"
+ return="java.util.ArrayList&lt;android.gesture.GesturePoint&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getGestureColor"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getUncertainGestureColor"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="removeOnGestureListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.gesture.GestureOverlayView.OnGestureListener">
+</parameter>
+</method>
+<method name="setCurrentGesture"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="gesture" type="android.gesture.Gesture">
+</parameter>
+</method>
+<method name="setGestureColor"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="color" type="int">
+</parameter>
+</method>
+<method name="setGestureDrawingColor"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="color" type="int">
+</parameter>
+</method>
+<method name="setUncertainGestureColor"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="color" type="int">
+</parameter>
+</method>
+<field name="DEFAULT_GESTURE_COLOR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-256"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="DEFAULT_UNCERTAIN_GESTURE_COLOR"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<interface name="GestureOverlayView.OnGestureListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onGesture"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overlay" type="android.gesture.GestureOverlayView">
+</parameter>
+<parameter name="event" type="android.view.MotionEvent">
+</parameter>
+</method>
+<method name="onGestureEnded"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overlay" type="android.gesture.GestureOverlayView">
+</parameter>
+<parameter name="event" type="android.view.MotionEvent">
+</parameter>
+</method>
+<method name="onGestureStarted"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overlay" type="android.gesture.GestureOverlayView">
+</parameter>
+<parameter name="event" type="android.view.MotionEvent">
+</parameter>
+</method>
+</interface>
+<class name="GesturePoint"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="GesturePoint"
+ type="android.gesture.GesturePoint"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="x" type="float">
+</parameter>
+<parameter name="y" type="float">
+</parameter>
+<parameter name="t" type="long">
+</parameter>
+</constructor>
+<field name="timestamp"
+ type="long"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="x"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="y"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="GestureStroke"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="GestureStroke"
+ type="android.gesture.GestureStroke"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="points" type="java.util.ArrayList&lt;android.gesture.GesturePoint&gt;">
+</parameter>
+</constructor>
+<method name="clearPath"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="computeOrientedBoundingBox"
+ return="android.gesture.OrientedBoundingBox"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="toPath"
+ return="android.graphics.Path"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="width" type="float">
+</parameter>
+<parameter name="height" type="float">
+</parameter>
+<parameter name="numSample" type="int">
+</parameter>
+</method>
+<field name="boundingBox"
+ type="android.graphics.RectF"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="length"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="points"
+ type="float[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="LetterRecognizer"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="getLetterRecognizer"
+ return="android.gesture.LetterRecognizer"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="type" type="int">
+</parameter>
+</method>
+<method name="recognize"
+ return="java.util.ArrayList&lt;android.gesture.Prediction&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="gesture" type="android.gesture.Gesture">
+</parameter>
+</method>
+<field name="RECOGNIZER_LATIN_LOWERCASE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="OrientedBoundingBox"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<field name="centerX"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="centerY"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="height"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="orientation"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="squareness"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="width"
+ type="float"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="Prediction"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<field name="name"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="score"
+ type="double"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="TouchThroughGestureListener"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.gesture.GestureOverlayView.OnGestureListener">
+</implements>
+<constructor name="TouchThroughGestureListener"
+ type="android.gesture.TouchThroughGestureListener"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="model" type="android.view.View">
+</parameter>
+</constructor>
+<constructor name="TouchThroughGestureListener"
+ type="android.gesture.TouchThroughGestureListener"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="model" type="android.view.View">
+</parameter>
+<parameter name="stealEvents" type="boolean">
+</parameter>
+</constructor>
+<method name="addOnGestureActionListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.gesture.TouchThroughGestureListener.OnGesturePerformedListener">
+</parameter>
+</method>
+<method name="isGesturing"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="onGesture"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overlay" type="android.gesture.GestureOverlayView">
+</parameter>
+<parameter name="event" type="android.view.MotionEvent">
+</parameter>
+</method>
+<method name="onGestureEnded"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overlay" type="android.gesture.GestureOverlayView">
+</parameter>
+<parameter name="event" type="android.view.MotionEvent">
+</parameter>
+</method>
+<method name="onGestureStarted"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overlay" type="android.gesture.GestureOverlayView">
+</parameter>
+<parameter name="event" type="android.view.MotionEvent">
+</parameter>
+</method>
+<method name="removeOnGestureActionListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.gesture.TouchThroughGestureListener.OnGesturePerformedListener">
+</parameter>
+</method>
+<method name="setGestureType"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="type" type="int">
+</parameter>
+</method>
+<field name="MULTIPLE_STROKE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SINGLE_STROKE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<interface name="TouchThroughGestureListener.OnGesturePerformedListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onGesturePerformed"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="overlay" type="android.gesture.GestureOverlayView">
+</parameter>
+<parameter name="gesture" type="android.gesture.Gesture">
+</parameter>
+</method>
+</interface>
+</package>
<package name="android.graphics"
>
<class name="AvoidXfermode"
diff --git a/tests/sketch/src/com/android/gesture/Gesture.java b/core/java/android/gesture/Gesture.java
index d5dcc65..14530a1 100755
--- a/tests/sketch/src/com/android/gesture/Gesture.java
+++ b/core/java/android/gesture/Gesture.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -32,8 +32,6 @@ import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
-import static com.android.gesture.GestureConstants.LOG_TAG;
-
/**
* A gesture can have a single or multiple strokes
*/
@@ -242,26 +240,6 @@ public class Gesture implements Parcelable {
return gesture;
}
- /**
- * Convert the gesture to string
- */
- @Override
- public String toString() {
- final StringBuilder str = new StringBuilder();
- str.append(mGestureID);
-
- final ArrayList<GestureStroke> strokes = mStrokes;
- final int count = strokes.size();
-
- for (int i = 0; i < count; i++) {
- final GestureStroke stroke = strokes.get(i);
- str.append(GestureConstants.STRING_GESTURE_DELIIMITER);
- str.append(stroke.toString());
- }
-
- return str.toString();
- }
-
public static final Parcelable.Creator<Gesture> CREATOR = new Parcelable.Creator<Gesture>() {
public Gesture createFromParcel(Parcel in) {
Gesture gesture = null;
@@ -273,7 +251,7 @@ public class Gesture implements Parcelable {
try {
gesture = deserialize(inStream);
} catch (IOException e) {
- Log.e(LOG_TAG, "Error reading Gesture from parcel:", e);
+ Log.e(GestureConstants.LOG_TAG, "Error reading Gesture from parcel:", e);
} finally {
GestureUtilities.closeStream(inStream);
}
@@ -302,7 +280,7 @@ public class Gesture implements Parcelable {
serialize(outStream);
result = true;
} catch (IOException e) {
- Log.e(LOG_TAG, "Error writing Gesture to parcel:", e);
+ Log.e(GestureConstants.LOG_TAG, "Error writing Gesture to parcel:", e);
} finally {
GestureUtilities.closeStream(outStream);
GestureUtilities.closeStream(byteStream);
diff --git a/tests/sketch/src/com/android/gesture/GestureConstants.java b/core/java/android/gesture/GestureConstants.java
index c0f2f3d..230db0c 100644
--- a/tests/sketch/src/com/android/gesture/GestureConstants.java
+++ b/core/java/android/gesture/GestureConstants.java
@@ -14,12 +14,9 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
interface GestureConstants {
- static final String STRING_GESTURE_DELIIMITER = "#";
- static final String STRING_STROKE_DELIIMITER = ",";
-
static final int STROKE_STRING_BUFFER_SIZE = 1024;
static final int STROKE_POINT_BUFFER_SIZE = 100; // number of points
diff --git a/tests/sketch/src/com/android/gesture/GestureLibrary.java b/core/java/android/gesture/GestureLibrary.java
index 7b5480c..1cf192e 100644
--- a/tests/sketch/src/com/android/gesture/GestureLibrary.java
+++ b/core/java/android/gesture/GestureLibrary.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.util.Log;
import android.os.SystemClock;
@@ -32,7 +32,7 @@ import java.util.HashMap;
import java.util.Set;
import java.util.Map;
-import static com.android.gesture.GestureConstants.LOG_TAG;
+import static android.gesture.GestureConstants.LOG_TAG;
/**
* GestureLibrary maintains gesture examples and makes predictions on a new
@@ -190,7 +190,7 @@ public class GestureLibrary {
*
* @param entryName the entry name
*/
- public void removeEntireEntry(String entryName) {
+ public void removeEntry(String entryName) {
mNamedGestures.remove(entryName);
mClassifier.removeInstances(entryName);
mChanged = true;
diff --git a/tests/sketch/src/com/android/gesture/GestureOverlay.java b/core/java/android/gesture/GestureOverlayView.java
index 454cecb..bffd12e 100755
--- a/tests/sketch/src/com/android/gesture/GestureOverlay.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.content.Context;
import android.graphics.Bitmap;
@@ -23,6 +23,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
+import android.graphics.Color;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -35,7 +36,7 @@ import java.util.ArrayList;
* widgets. The view can also be opaque.
*/
-public class GestureOverlay extends View {
+public class GestureOverlayView extends View {
static final float TOUCH_TOLERANCE = 3;
// TODO: Move all these values into XML attributes
@@ -52,20 +53,22 @@ public class GestureOverlay extends View {
private static final boolean DITHER_FLAG = true;
public static final int DEFAULT_GESTURE_COLOR = 0xFFFFFF00;
+ public static final int DEFAULT_UNCERTAIN_GESTURE_COLOR = Color.argb(60, 255, 255, 0);
private static final int REFRESH_RANGE = 10;
private static final BlurMaskFilter BLUR_MASK_FILTER =
new BlurMaskFilter(1, BlurMaskFilter.Blur.NORMAL);
-
- // double buffering
private Paint mGesturePaint;
private final Paint mBitmapPaint = new Paint(Paint.DITHER_FLAG);
private Bitmap mBitmap; // with transparent background
private Canvas mBitmapCanvas;
+ private int mCertainGestureColor = DEFAULT_GESTURE_COLOR;
+ private int mUncertainGestureColor = DEFAULT_UNCERTAIN_GESTURE_COLOR;
+
// for rendering immediate ink feedback
private Rect mInvalidRect = new Rect();
@@ -81,7 +84,7 @@ public class GestureOverlay extends View {
private Gesture mCurrentGesture = null;
// TODO: Make this a list of WeakReferences
- private final ArrayList<GestureListener> mGestureListeners = new ArrayList<GestureListener>();
+ private final ArrayList<OnGestureListener> mOnGestureListeners = new ArrayList<OnGestureListener>();
private ArrayList<GesturePoint> mPointBuffer = null;
// fading out effect
@@ -107,12 +110,12 @@ public class GestureOverlay extends View {
}
};
- public GestureOverlay(Context context) {
+ public GestureOverlayView(Context context) {
super(context);
init();
}
- public GestureOverlay(Context context, AttributeSet attrs) {
+ public GestureOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
@@ -130,7 +133,7 @@ public class GestureOverlay extends View {
*
* @param color
*/
- public void setGestureColor(int color) {
+ public void setGestureDrawingColor(int color) {
mGesturePaint.setColor(color);
if (mCurrentGesture != null) {
mBitmap.eraseColor(TRANSPARENT_BACKGROUND);
@@ -138,6 +141,22 @@ public class GestureOverlay extends View {
}
}
+ public void setGestureColor(int color) {
+ mCertainGestureColor = color;
+ }
+
+ public void setUncertainGestureColor(int color) {
+ mUncertainGestureColor = color;
+ }
+
+ public int getUncertainGestureColor() {
+ return mUncertainGestureColor;
+ }
+
+ public int getGestureColor() {
+ return mCertainGestureColor;
+ }
+
/**
* Set the gesture to be shown in the view
*
@@ -199,12 +218,12 @@ public class GestureOverlay extends View {
}
}
- public void addGestureListener(GestureListener listener) {
- mGestureListeners.add(listener);
+ public void addOnGestureListener(OnGestureListener listener) {
+ mOnGestureListeners.add(listener);
}
- public void removeGestureListener(GestureListener listener) {
- mGestureListeners.remove(listener);
+ public void removeOnGestureListener(OnGestureListener listener) {
+ mOnGestureListeners.remove(listener);
}
@Override
@@ -281,11 +300,11 @@ public class GestureOverlay extends View {
private Rect touchStart(MotionEvent event) {
// pass the event to handlers
- final ArrayList<GestureListener> listeners = mGestureListeners;
+ final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
final int count = listeners.size();
for (int i = 0; i < count; i++) {
- GestureListener listener = listeners.get(i);
- listener.onStartGesture(this, event);
+ OnGestureListener listener = listeners.get(i);
+ listener.onGestureStarted(this, event);
}
// if there is fading out going on, stop it.
@@ -358,7 +377,7 @@ public class GestureOverlay extends View {
mPointBuffer.add(new GesturePoint(x, y, event.getEventTime()));
// pass the event to handlers
- final ArrayList<GestureListener> listeners = mGestureListeners;
+ final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
final int count = listeners.size();
for (int i = 0; i < count; i++) {
listeners.get(i).onGesture(this, event);
@@ -377,14 +396,24 @@ public class GestureOverlay extends View {
mGesturePaint.setMaskFilter(null);
// pass the event to handlers
- final ArrayList<GestureListener> listeners = mGestureListeners;
+ final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
final int count = listeners.size();
for (int i = 0; i < count; i++) {
- listeners.get(i).onFinishGesture(this, event);
+ listeners.get(i).onGestureEnded(this, event);
}
mPath = null;
mPointBuffer = null;
}
+ /**
+ * An interface for processing gesture events
+ */
+ public static interface OnGestureListener {
+ public void onGestureStarted(GestureOverlayView overlay, MotionEvent event);
+
+ public void onGesture(GestureOverlayView overlay, MotionEvent event);
+
+ public void onGestureEnded(GestureOverlayView overlay, MotionEvent event);
+ }
}
diff --git a/tests/sketch/src/com/android/gesture/GesturePoint.java b/core/java/android/gesture/GesturePoint.java
index 560f893..3698011 100644
--- a/tests/sketch/src/com/android/gesture/GesturePoint.java
+++ b/core/java/android/gesture/GesturePoint.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import java.io.DataInputStream;
import java.io.IOException;
diff --git a/tests/sketch/src/com/android/gesture/GestureStroke.java b/core/java/android/gesture/GestureStroke.java
index 79b42fe..5160a76 100644
--- a/tests/sketch/src/com/android/gesture/GestureStroke.java
+++ b/core/java/android/gesture/GestureStroke.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.graphics.Canvas;
import android.graphics.Matrix;
@@ -126,16 +126,16 @@ public class GestureStroke {
* @param width the width of the bounding box of the target path
* @param height the height of the bounding box of the target path
* @param numSample the number of points needed
+ *
* @return the path
*/
public Path toPath(float width, float height, int numSample) {
final float[] pts = GestureUtilities.temporalSampling(this, numSample);
final RectF rect = boundingBox;
- final float scale = height / rect.height();
final Matrix matrix = new Matrix();
matrix.setTranslate(-rect.left, -rect.top);
- matrix.postScale(scale, scale);
+ matrix.postScale(width / rect.width(), height / rect.height());
matrix.mapPoints(pts);
float mX = 0;
@@ -156,7 +156,8 @@ public class GestureStroke {
} else {
float dx = Math.abs(x - mX);
float dy = Math.abs(y - mY);
- if (dx >= GestureOverlay.TOUCH_TOLERANCE || dy >= GestureOverlay.TOUCH_TOLERANCE) {
+ if (dx >= GestureOverlayView.TOUCH_TOLERANCE ||
+ dy >= GestureOverlayView.TOUCH_TOLERANCE) {
path.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
mX = x;
mY = y;
@@ -198,29 +199,10 @@ public class GestureStroke {
}
/**
- * Convert the stroke to string
- */
- @Override
- public String toString() {
- final StringBuilder str = new StringBuilder(GestureConstants.STROKE_STRING_BUFFER_SIZE);
- final float[] pts = points;
- final long[] times = timestamps;
- final int count = points.length;
-
- for (int i = 0; i < count; i += 2) {
- str.append(pts[i]).append(GestureConstants.STRING_STROKE_DELIIMITER);
- str.append(pts[i + 1]).append(GestureConstants.STRING_STROKE_DELIIMITER);
- str.append(times[i / 2]).append(GestureConstants.STRING_STROKE_DELIIMITER);
- }
-
- return str.toString();
- }
-
- /**
- * Invalidate the cached path that is used for rendering the stroke
+ * Invalidate the cached path that is used to render the stroke
*/
- public void invalidate() {
- mCachedPath = null;
+ public void clearPath() {
+ if (mCachedPath != null) mCachedPath.rewind();
}
/**
diff --git a/tests/sketch/src/com/android/gesture/GestureUtilities.java b/core/java/android/gesture/GestureUtilities.java
index 6d73c2d..e47856c 100755
--- a/tests/sketch/src/com/android/gesture/GestureUtilities.java
+++ b/core/java/android/gesture/GestureUtilities.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.graphics.RectF;
import android.graphics.Matrix;
@@ -25,7 +25,7 @@ import java.util.Arrays;
import java.io.Closeable;
import java.io.IOException;
-import static com.android.gesture.GestureConstants.*;
+import static android.gesture.GestureConstants.*;
final class GestureUtilities {
private static final int TEMPORAL_SAMPLING_RATE = 16;
diff --git a/tests/sketch/src/com/android/gesture/Instance.java b/core/java/android/gesture/Instance.java
index 502a0fa..7922fab 100755
--- a/tests/sketch/src/com/android/gesture/Instance.java
+++ b/core/java/android/gesture/Instance.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.graphics.Matrix;
diff --git a/tests/sketch/src/com/android/gesture/InstanceLearner.java b/core/java/android/gesture/InstanceLearner.java
index 4495256..1739cdc 100644
--- a/tests/sketch/src/com/android/gesture/InstanceLearner.java
+++ b/core/java/android/gesture/InstanceLearner.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.util.Config;
import android.util.Log;
+import static android.gesture.GestureConstants.*;
import java.util.ArrayList;
import java.util.Collections;
@@ -30,9 +31,6 @@ import java.util.TreeMap;
*/
class InstanceLearner extends Learner {
-
- private static final String LOGTAG = "InstanceLearner";
-
@Override
ArrayList<Prediction> classify(int gestureType, float[] vector) {
ArrayList<Prediction> predictions = new ArrayList<Prediction>();
@@ -63,19 +61,15 @@ class InstanceLearner extends Learner {
}
double sum = 0;
- Iterator<String> lableIterator = label2score.keySet().iterator();
- while (lableIterator.hasNext()) {
- String name = lableIterator.next();
+ for (String name : label2score.keySet()) {
double score = label2score.get(name);
sum += score;
predictions.add(new Prediction(name, score));
}
// normalize
- Iterator<Prediction> predictionIterator = predictions.iterator();
- while (predictionIterator.hasNext()) {
- Prediction name = predictionIterator.next();
- name.score /= sum;
+ for (Prediction prediction : predictions) {
+ prediction.score /= sum;
}
Collections.sort(predictions, new Comparator<Prediction>() {
@@ -92,14 +86,6 @@ class InstanceLearner extends Learner {
}
});
- if (Config.DEBUG) {
- predictionIterator = predictions.iterator();
- while (predictionIterator.hasNext()) {
- Prediction name = predictionIterator.next();
- Log.v(LOGTAG, "prediction [" + name.name + " = " + name.score + "]");
- }
- }
-
return predictions;
}
}
diff --git a/tests/sketch/src/com/android/gesture/Learner.java b/core/java/android/gesture/Learner.java
index 15b2053..feacde5 100755
--- a/tests/sketch/src/com/android/gesture/Learner.java
+++ b/core/java/android/gesture/Learner.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import java.util.ArrayList;
diff --git a/tests/sketch/src/com/android/gesture/LetterRecognizer.java b/core/java/android/gesture/LetterRecognizer.java
index 07a5f31..4476746 100644
--- a/tests/sketch/src/com/android/gesture/LetterRecognizer.java
+++ b/core/java/android/gesture/LetterRecognizer.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.content.Context;
import android.content.res.Resources;
@@ -28,10 +28,13 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
-import static com.android.gesture.GestureConstants.LOG_TAG;
+import static android.gesture.GestureConstants.LOG_TAG;
public class LetterRecognizer {
- public final static int LATIN_LOWERCASE = 0;
+ public final static int RECOGNIZER_LATIN_LOWERCASE = 0;
+ static final String GESTURE_FILE_NAME = "letters.gestures";
+
+ private final static int ADJUST_RANGE = 3;
private SigmoidUnit[] mHiddenLayer;
private SigmoidUnit[] mOutputLayer;
@@ -40,59 +43,57 @@ public class LetterRecognizer {
private final int mPatchSize;
- static final String GESTURE_FILE_NAME = "letters.gestures";
+ private GestureLibrary mGestureLibrary;
- private GestureLibrary mGestureLibrary;
- private final static int ADJUST_RANGE = 3;
-
private static class SigmoidUnit {
final float[] mWeights;
+ private boolean mComputed;
+ private float mResult;
+
SigmoidUnit(float[] weights) {
mWeights = weights;
}
private float compute(float[] inputs) {
- float sum = 0;
+ if (!mComputed) {
+ float sum = 0;
- final int count = inputs.length;
- final float[] weights = mWeights;
+ final int count = inputs.length;
+ final float[] weights = mWeights;
- for (int i = 0; i < count; i++) {
- sum += inputs[i] * weights[i];
- }
- sum += weights[weights.length - 1];
+ for (int i = 0; i < count; i++) {
+ sum += inputs[i] * weights[i];
+ }
+ sum += weights[weights.length - 1];
- return 1.0f / (float) (1 + Math.exp(-sum));
+ mResult = 1.0f / (float) (1 + Math.exp(-sum));
+ mComputed = true;
+ }
+ return mResult;
}
}
- private LetterRecognizer(int numOfInput, int numOfHidden, String[] classes) {
- mPatchSize = (int)Math.sqrt(numOfInput);
- mHiddenLayer = new SigmoidUnit[numOfHidden];
- mClasses = classes;
- mOutputLayer = new SigmoidUnit[classes.length];
- }
-
- public void save() {
- mGestureLibrary.save();
- }
-
public static LetterRecognizer getLetterRecognizer(Context context, int type) {
switch (type) {
- case LATIN_LOWERCASE: {
+ case RECOGNIZER_LATIN_LOWERCASE: {
return createFromResource(context, com.android.internal.R.raw.latin_lowercase);
}
}
return null;
}
+ private LetterRecognizer(int numOfInput, int numOfHidden, String[] classes) {
+ mPatchSize = (int) Math.sqrt(numOfInput);
+ mHiddenLayer = new SigmoidUnit[numOfHidden];
+ mClasses = classes;
+ mOutputLayer = new SigmoidUnit[classes.length];
+ }
+
public ArrayList<Prediction> recognize(Gesture gesture) {
float[] query = GestureUtilities.spatialSampling(gesture, mPatchSize);
ArrayList<Prediction> predictions = classify(query);
- if (mGestureLibrary != null) {
- adjustPrediction(gesture, predictions);
- }
+ adjustPrediction(gesture, predictions);
return predictions;
}
@@ -153,38 +154,14 @@ public class LetterRecognizer {
in = new DataInputStream(new BufferedInputStream(resources.openRawResource(resourceID),
GestureConstants.IO_BUFFER_SIZE));
- final int iCount = in.readInt();
- final int hCount = in.readInt();
- final int oCount = in.readInt();
+ final int version = in.readShort();
- final String[] classes = new String[oCount];
- for (int i = 0; i < classes.length; i++) {
- classes[i] = in.readUTF();
- }
-
- classifier = new LetterRecognizer(iCount, hCount, classes);
- SigmoidUnit[] hiddenLayer = new SigmoidUnit[hCount];
- SigmoidUnit[] outputLayer = new SigmoidUnit[oCount];
-
- for (int i = 0; i < hCount; i++) {
- float[] weights = new float[iCount + 1];
- for (int j = 0; j <= iCount; j++) {
- weights[j] = in.readFloat();
- }
- hiddenLayer[i] = new SigmoidUnit(weights);
- }
-
- for (int i = 0; i < oCount; i++) {
- float[] weights = new float[hCount + 1];
- for (int j = 0; j <= hCount; j++) {
- weights[j] = in.readFloat();
- }
- outputLayer[i] = new SigmoidUnit(weights);
+ switch (version) {
+ case 1:
+ classifier = readV1(in);
+ break;
}
- classifier.mHiddenLayer = hiddenLayer;
- classifier.mOutputLayer = outputLayer;
-
} catch (IOException e) {
Log.d(LOG_TAG, "Failed to load handwriting data:", e);
} finally {
@@ -193,9 +170,65 @@ public class LetterRecognizer {
return classifier;
}
-
- public void enablePersonalization(boolean enable) {
- if (enable) {
+
+ private static LetterRecognizer readV1(DataInputStream in) throws IOException {
+
+ final int iCount = in.readInt();
+ final int hCount = in.readInt();
+ final int oCount = in.readInt();
+
+ final String[] classes = new String[oCount];
+ for (int i = 0; i < classes.length; i++) {
+ classes[i] = in.readUTF();
+ }
+
+ final LetterRecognizer classifier = new LetterRecognizer(iCount, hCount, classes);
+ final SigmoidUnit[] hiddenLayer = new SigmoidUnit[hCount];
+ final SigmoidUnit[] outputLayer = new SigmoidUnit[oCount];
+
+ for (int i = 0; i < hCount; i++) {
+ final float[] weights = new float[iCount + 1];
+ for (int j = 0; j <= iCount; j++) {
+ weights[j] = in.readFloat();
+ }
+ hiddenLayer[i] = new SigmoidUnit(weights);
+ }
+
+ for (int i = 0; i < oCount; i++) {
+ final float[] weights = new float[hCount + 1];
+ for (int j = 0; j <= hCount; j++) {
+ weights[j] = in.readFloat();
+ }
+ outputLayer[i] = new SigmoidUnit(weights);
+ }
+
+ classifier.mHiddenLayer = hiddenLayer;
+ classifier.mOutputLayer = outputLayer;
+
+ return classifier;
+ }
+
+ /**
+ * TODO: Publish this API once we figure out where we should save the personzlied
+ * gestures, and how to do so across all apps
+ *
+ * @hide
+ */
+ public boolean save() {
+ if (mGestureLibrary != null) {
+ return mGestureLibrary.save();
+ }
+ return false;
+ }
+
+ /**
+ * TODO: Publish this API once we figure out where we should save the personzlied
+ * gestures, and how to do so across all apps
+ *
+ * @hide
+ */
+ public void setPersonalizationEnabled(boolean enabled) {
+ if (enabled) {
mGestureLibrary = new GestureLibrary(GESTURE_FILE_NAME);
mGestureLibrary.setSequenceType(GestureLibrary.SEQUENCE_INVARIANT);
mGestureLibrary.load();
@@ -204,24 +237,36 @@ public class LetterRecognizer {
}
}
+ /**
+ * TODO: Publish this API once we figure out where we should save the personzlied
+ * gestures, and how to do so across all apps
+ *
+ * @hide
+ */
public void addExample(String letter, Gesture example) {
- mGestureLibrary.addGesture(letter, example);
+ if (mGestureLibrary != null) {
+ mGestureLibrary.addGesture(letter, example);
+ }
}
private void adjustPrediction(Gesture query, ArrayList<Prediction> predictions) {
- ArrayList<Prediction> results = mGestureLibrary.recognize(query);
- HashMap<String, Prediction> topNList = new HashMap<String, Prediction>();
- for (int j = 0; j < ADJUST_RANGE; j++) {
- Prediction prediction = predictions.remove(0);
- topNList.put(prediction.name, prediction);
- }
- int count = results.size();
- for (int j = count - 1; j >= 0 && !topNList.isEmpty(); j--) {
- Prediction item = results.get(j);
- Prediction original = topNList.get(item.name);
- if (original != null) {
- predictions.add(0, original);
- topNList.remove(item.name);
+ if (mGestureLibrary != null) {
+ final ArrayList<Prediction> results = mGestureLibrary.recognize(query);
+ final HashMap<String, Prediction> topNList = new HashMap<String, Prediction>();
+
+ for (int j = 0; j < ADJUST_RANGE; j++) {
+ Prediction prediction = predictions.remove(0);
+ topNList.put(prediction.name, prediction);
+ }
+
+ final int count = results.size();
+ for (int j = count - 1; j >= 0 && !topNList.isEmpty(); j--) {
+ final Prediction item = results.get(j);
+ final Prediction original = topNList.get(item.name);
+ if (original != null) {
+ predictions.add(0, original);
+ topNList.remove(item.name);
+ }
}
}
}
diff --git a/tests/sketch/src/com/android/gesture/OrientedBoundingBox.java b/core/java/android/gesture/OrientedBoundingBox.java
index a07d125..f1335ee 100644
--- a/tests/sketch/src/com/android/gesture/OrientedBoundingBox.java
+++ b/core/java/android/gesture/OrientedBoundingBox.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
import android.graphics.Matrix;
import android.graphics.Path;
@@ -47,6 +47,11 @@ public class OrientedBoundingBox {
}
}
+ /**
+ * Currently used for debugging purpose only.
+ *
+ * @hide
+ */
public Path toPath() {
Path path = new Path();
float[] point = new float[2];
diff --git a/tests/sketch/src/com/android/gesture/Prediction.java b/core/java/android/gesture/Prediction.java
index 92d3ba4..ce6ad57 100755
--- a/tests/sketch/src/com/android/gesture/Prediction.java
+++ b/core/java/android/gesture/Prediction.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
public class Prediction {
public final String name;
diff --git a/tests/sketch/src/com/android/gesture/TouchThroughGesturing.java b/core/java/android/gesture/TouchThroughGestureListener.java
index fc878c8..7621ddf 100644
--- a/tests/sketch/src/com/android/gesture/TouchThroughGesturing.java
+++ b/core/java/android/gesture/TouchThroughGestureListener.java
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package com.android.gesture;
+package android.gesture;
-import android.graphics.Color;
import android.view.MotionEvent;
import android.view.View;
import java.util.ArrayList;
+import java.lang.ref.WeakReference;
/**
* TouchThroughGesturing implements the interaction behavior that allows a user
@@ -28,19 +28,15 @@ import java.util.ArrayList;
* still allows a user to perform basic interactions (clicking, scrolling and panning)
* with the underlying widget.
*/
-
-public class TouchThroughGesturing implements GestureListener {
+public class TouchThroughGestureListener implements GestureOverlayView.OnGestureListener {
public static final int SINGLE_STROKE = 0;
public static final int MULTIPLE_STROKE = 1;
+ // TODO: Add properties for all these
private static final float STROKE_LENGTH_THRESHOLD = 30;
private static final float SQUARENESS_THRESHOLD = 0.275f;
private static final float ANGLE_THRESHOLD = 40;
- private static final boolean STEAL_EVENTS = false;
-
- public static final int DEFAULT_UNCERTAIN_GESTURE_COLOR = Color.argb(60, 255, 255, 0);
-
private boolean mIsGesturing = false;
private float mTotalLength;
@@ -48,18 +44,23 @@ public class TouchThroughGesturing implements GestureListener {
private float mX;
private float mY;
- // TODO: Use WeakReference?
- private View mModel;
+ private WeakReference<View> mModel;
private int mGestureType = SINGLE_STROKE;
- private int mUncertainGestureColor = DEFAULT_UNCERTAIN_GESTURE_COLOR;
// TODO: Use WeakReferences
- private final ArrayList<GestureActionListener> mActionListeners =
- new ArrayList<GestureActionListener>();
+ private final ArrayList<OnGesturePerformedListener> mPerformedListeners =
+ new ArrayList<OnGesturePerformedListener>();
+
+ private boolean mStealEvents = false;
+
+ public TouchThroughGestureListener(View model) {
+ this(model, false);
+ }
- public TouchThroughGesturing(View model) {
- mModel = model;
+ public TouchThroughGestureListener(View model, boolean stealEvents) {
+ mModel = new WeakReference<View>(model);
+ mStealEvents = stealEvents;
}
/**
@@ -70,11 +71,7 @@ public class TouchThroughGesturing implements GestureListener {
mGestureType = type;
}
- public void setUncertainGestureColor(int color) {
- mUncertainGestureColor = color;
- }
-
- public void onStartGesture(GestureOverlay overlay, MotionEvent event) {
+ public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) {
if (mGestureType == MULTIPLE_STROKE) {
overlay.cancelFadingOut();
}
@@ -86,16 +83,21 @@ public class TouchThroughGesturing implements GestureListener {
if (mGestureType == SINGLE_STROKE || overlay.getCurrentGesture() == null
|| overlay.getCurrentGesture().getStrokesCount() == 0) {
- overlay.setGestureColor(mUncertainGestureColor);
+ overlay.setGestureDrawingColor(overlay.getUncertainGestureColor());
}
- mModel.dispatchTouchEvent(event);
+ dispatchEventToModel(event);
+ }
+
+ private void dispatchEventToModel(MotionEvent event) {
+ View v = mModel.get();
+ if (v != null) v.dispatchTouchEvent(event);
}
- public void onGesture(GestureOverlay overlay, MotionEvent event) {
+ public void onGesture(GestureOverlayView overlay, MotionEvent event) {
//noinspection PointlessBooleanExpression
- if (!STEAL_EVENTS) {
- mModel.dispatchTouchEvent(event);
+ if (!mStealEvents) {
+ dispatchEventToModel(event);
}
if (mIsGesturing) {
@@ -107,7 +109,7 @@ public class TouchThroughGesturing implements GestureListener {
final float dx = x - mX;
final float dy = y - mY;
- mTotalLength += (float)Math.sqrt(dx * dx + dy * dy);
+ mTotalLength += (float) Math.sqrt(dx * dx + dy * dy);
mX = x;
mY = y;
@@ -120,8 +122,8 @@ public class TouchThroughGesturing implements GestureListener {
}
if (box.squareness > SQUARENESS_THRESHOLD || angle < ANGLE_THRESHOLD) {
mIsGesturing = true;
- overlay.setGestureColor(GestureOverlay.DEFAULT_GESTURE_COLOR);
- if (STEAL_EVENTS) {
+ overlay.setGestureDrawingColor(overlay.getGestureColor());
+ if (mStealEvents) {
event = MotionEvent.obtain(event.getDownTime(), System.currentTimeMillis(),
MotionEvent.ACTION_UP, x, y, event.getPressure(), event.getSize(),
event.getMetaState(), event.getXPrecision(), event.getYPrecision(),
@@ -130,36 +132,40 @@ public class TouchThroughGesturing implements GestureListener {
}
}
- if (STEAL_EVENTS) {
- mModel.dispatchTouchEvent(event);
+ if (mStealEvents) {
+ dispatchEventToModel(event);
}
}
- public void onFinishGesture(GestureOverlay overlay, MotionEvent event) {
+ public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
if (mIsGesturing) {
overlay.clear(true);
- final ArrayList<GestureActionListener> listeners = mActionListeners;
+ final ArrayList<OnGesturePerformedListener> listeners = mPerformedListeners;
final int count = listeners.size();
for (int i = 0; i < count; i++) {
listeners.get(i).onGesturePerformed(overlay, overlay.getCurrentGesture());
}
} else {
- mModel.dispatchTouchEvent(event);
+ dispatchEventToModel(event);
overlay.clear(false);
}
}
- public void addGestureActionListener(GestureActionListener listener) {
- mActionListeners.add(listener);
+ public void addOnGestureActionListener(OnGesturePerformedListener listener) {
+ mPerformedListeners.add(listener);
}
- public void removeGestureActionListener(GestureActionListener listener) {
- mActionListeners.remove(listener);
+ public void removeOnGestureActionListener(OnGesturePerformedListener listener) {
+ mPerformedListeners.remove(listener);
}
public boolean isGesturing() {
return mIsGesturing;
}
+
+ public static interface OnGesturePerformedListener {
+ public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture);
+ }
}
diff --git a/core/res/res/raw/latin_lowercase b/core/res/res/raw/latin_lowercase
index 9c747d6..5c38b91 100644
--- a/core/res/res/raw/latin_lowercase
+++ b/core/res/res/raw/latin_lowercase
Binary files differ
diff --git a/tests/sketch/AndroidManifest.xml b/tests/sketch/AndroidManifest.xml
index 78df234..fbf3a09 100755
--- a/tests/sketch/AndroidManifest.xml
+++ b/tests/sketch/AndroidManifest.xml
@@ -14,9 +14,7 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.gesture.example"
- android:versionCode="1"
- android:versionName="1.0.0">
+ package="com.android.gesture.example">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_SDCARD" />
diff --git a/tests/sketch/src/com/android/gesture/GestureActionListener.java b/tests/sketch/src/com/android/gesture/GestureActionListener.java
deleted file mode 100644
index c9c5232..0000000
--- a/tests/sketch/src/com/android/gesture/GestureActionListener.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2008-2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gesture;
-
-public interface GestureActionListener {
- public void onGesturePerformed(GestureOverlay overlay, Gesture gesture);
-}
diff --git a/tests/sketch/src/com/android/gesture/GestureListener.java b/tests/sketch/src/com/android/gesture/GestureListener.java
deleted file mode 100755
index 9b50714..0000000
--- a/tests/sketch/src/com/android/gesture/GestureListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2008-2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gesture;
-
-import android.view.MotionEvent;
-
-/**
- * An interface for processing gesture events
- */
-public interface GestureListener {
- public void onStartGesture(GestureOverlay overlay, MotionEvent event);
-
- public void onGesture(GestureOverlay overlay, MotionEvent event);
-
- public void onFinishGesture(GestureOverlay overlay, MotionEvent event);
-}
diff --git a/tests/sketch/src/com/android/gesture/example/ContactListGestureOverlay.java b/tests/sketch/src/com/android/gesture/example/ContactListGestureOverlay.java
index 6eb2f23..eda4224 100644
--- a/tests/sketch/src/com/android/gesture/example/ContactListGestureOverlay.java
+++ b/tests/sketch/src/com/android/gesture/example/ContactListGestureOverlay.java
@@ -30,12 +30,11 @@ import android.view.Window;
import android.widget.AdapterView;
import android.widget.ListView;
-import com.android.gesture.Gesture;
-import com.android.gesture.GestureActionListener;
-import com.android.gesture.GestureOverlay;
-import com.android.gesture.LetterRecognizer;
-import com.android.gesture.Prediction;
-import com.android.gesture.TouchThroughGesturing;
+import android.gesture.Gesture;
+import android.gesture.GestureOverlayView;
+import android.gesture.LetterRecognizer;
+import android.gesture.Prediction;
+import android.gesture.TouchThroughGestureListener;
import java.util.ArrayList;
@@ -52,7 +51,7 @@ public class ContactListGestureOverlay extends Activity {
private ContactAdapter mContactAdapter;
- private TouchThroughGesturing mGestureProcessor;
+ private TouchThroughGestureListener mGestureProcessor;
private LetterRecognizer mRecognizer;
@@ -67,7 +66,7 @@ public class ContactListGestureOverlay extends Activity {
setProgressBarIndeterminateVisibility(true);
// create a letter recognizer
- mRecognizer = LetterRecognizer.getLetterRecognizer(this, LetterRecognizer.LATIN_LOWERCASE);
+ mRecognizer = LetterRecognizer.getLetterRecognizer(this, LetterRecognizer.RECOGNIZER_LATIN_LOWERCASE);
// load the contact list
mContactList = (ListView) findViewById(R.id.list);
@@ -95,11 +94,11 @@ public class ContactListGestureOverlay extends Activity {
setProgressBarIndeterminateVisibility(false);
// add a gesture overlay on top of the ListView
- GestureOverlay overlay = new GestureOverlay(this);
- mGestureProcessor = new TouchThroughGesturing(mContactList);
- mGestureProcessor.setGestureType(TouchThroughGesturing.MULTIPLE_STROKE);
- mGestureProcessor.addGestureActionListener(new GestureActionListener() {
- public void onGesturePerformed(GestureOverlay overlay, Gesture gesture) {
+ GestureOverlayView overlay = new GestureOverlayView(this);
+ mGestureProcessor = new TouchThroughGestureListener(mContactList);
+ mGestureProcessor.setGestureType(TouchThroughGestureListener.MULTIPLE_STROKE);
+ mGestureProcessor.addOnGestureActionListener(new TouchThroughGestureListener.OnGesturePerformedListener() {
+ public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = mRecognizer.recognize(gesture);
if (!predictions.isEmpty()) {
Log.v(LOGTAG, "1st Prediction : " + predictions.get(0).name);
@@ -112,7 +111,7 @@ public class ContactListGestureOverlay extends Activity {
}
}
});
- overlay.addGestureListener(mGestureProcessor);
+ overlay.addOnGestureListener(mGestureProcessor);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
this.addContentView(overlay, params);
diff --git a/tests/sketch/src/com/android/gesture/example/GestureEntry.java b/tests/sketch/src/com/android/gesture/example/GestureEntry.java
index 53ba481..200f89f 100644
--- a/tests/sketch/src/com/android/gesture/example/GestureEntry.java
+++ b/tests/sketch/src/com/android/gesture/example/GestureEntry.java
@@ -34,12 +34,11 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.AdapterView.OnItemSelectedListener;
+import android.gesture.Gesture;
-import com.android.gesture.Gesture;
-import com.android.gesture.GestureLibrary;
-import com.android.gesture.GestureListener;
-import com.android.gesture.GestureOverlay;
-import com.android.gesture.Prediction;
+import android.gesture.GestureLibrary;
+import android.gesture.GestureOverlayView;
+import android.gesture.Prediction;
import java.io.File;
import java.util.ArrayList;
@@ -57,7 +56,7 @@ public class GestureEntry extends Activity {
private static final int VIEW_ID = Menu.FIRST + 1;
- private GestureOverlay mGesturePad;
+ private GestureOverlayView mGesturePad;
private Spinner mRecognitionResult;
@@ -96,17 +95,17 @@ public class GestureEntry extends Activity {
});
// create the area for drawing a gesture
- mGesturePad = (GestureOverlay) findViewById(R.id.drawingpad);
+ mGesturePad = (GestureOverlayView) findViewById(R.id.drawingpad);
mGesturePad.setBackgroundColor(Color.BLACK);
- mGesturePad.addGestureListener(new GestureListener() {
- public void onFinishGesture(GestureOverlay overlay, MotionEvent event) {
+ mGesturePad.addOnGestureListener(new GestureOverlayView.OnGestureListener() {
+ public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
recognize(overlay.getCurrentGesture());
}
- public void onGesture(GestureOverlay overlay, MotionEvent event) {
+ public void onGesture(GestureOverlayView overlay, MotionEvent event) {
}
- public void onStartGesture(GestureOverlay overlay, MotionEvent event) {
+ public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) {
overlay.clear(false);
}
});
diff --git a/tests/sketch/src/com/android/gesture/example/GestureLibViewer.java b/tests/sketch/src/com/android/gesture/example/GestureLibViewer.java
index ca54110..aa07e7b 100755
--- a/tests/sketch/src/com/android/gesture/example/GestureLibViewer.java
+++ b/tests/sketch/src/com/android/gesture/example/GestureLibViewer.java
@@ -26,10 +26,10 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.AdapterView.OnItemSelectedListener;
+import android.gesture.Gesture;
-import com.android.gesture.Gesture;
-import com.android.gesture.GestureLibrary;
-import com.android.gesture.GestureOverlay;
+import android.gesture.GestureLibrary;
+import android.gesture.GestureOverlayView;
import java.util.ArrayList;
import java.util.Collections;
@@ -41,7 +41,7 @@ import java.util.Collections;
public class GestureLibViewer extends Activity {
- private GestureOverlay mGesturePad;
+ private GestureOverlayView mGesturePad;
private Spinner mGestureCategory;
@@ -90,7 +90,7 @@ public class GestureLibViewer extends Activity {
setContentView(R.layout.gestureviewer);
// create the area for drawing a gesture
- mGesturePad = (GestureOverlay) findViewById(R.id.drawingpad);
+ mGesturePad = (GestureOverlayView) findViewById(R.id.drawingpad);
mGesturePad.setEnabled(false);
// init the gesture library
diff --git a/tests/sketch/tools/Converter.java b/tests/sketch/tools/Converter.java
index b4654f8..c0391d8 100644
--- a/tests/sketch/tools/Converter.java
+++ b/tests/sketch/tools/Converter.java
@@ -15,6 +15,7 @@ import java.io.BufferedInputStream;
*/
public class Converter {
private final File mFile;
+ private static final short VERSION_NUMBER = 1;
Converter(File file) {
mFile = file;
@@ -63,10 +64,10 @@ public class Converter {
iWeights = new float[hCount][];
for (int i = 0; i < hCount; i++) {
- iWeights[i] = new float[iCount];
+ iWeights[i] = new float[iCount + 1];
line = reader.readLine();
startIndex = 0;
- for (int j = 0; j < iCount; j++) {
+ for (int j = 0; j <= iCount; j++) {
endIndex = line.indexOf(" ", startIndex);
iWeights[i][j] = Float.parseFloat(line.substring(startIndex, endIndex));
startIndex = endIndex + 1;
@@ -75,10 +76,10 @@ public class Converter {
oWeights = new float[oCount][];
for (int i = 0; i < oCount; i++) {
- oWeights[i] = new float[hCount];
+ oWeights[i] = new float[hCount + 1];
line = reader.readLine();
startIndex = 0;
- for (int j = 0; j < hCount; j++) {
+ for (int j = 0; j <= hCount; j++) {
endIndex = line.indexOf(" ", startIndex);
oWeights[i][j] = Float.parseFloat(line.substring(startIndex, endIndex));
startIndex = endIndex + 1;
@@ -105,6 +106,7 @@ public class Converter {
try {
out = new DataOutputStream(new FileOutputStream(mFile));
+ out.writeShort(VERSION_NUMBER);
out.writeInt(iCount);
out.writeInt(hCount);
out.writeInt(oCount);