Merge "Step 24-A remove setdict" into jb-mr1-dev
diff --git a/dictionaries/en_whitelist.xml b/dictionaries/en_whitelist.xml
index f112077..e11935f 100644
--- a/dictionaries/en_whitelist.xml
+++ b/dictionaries/en_whitelist.xml
@@ -19,13 +19,13 @@
-->
<shortcuts>
<entry shortcut="ill">
- <target replacement="I\'ll" priority="whitelist" />
+ <target replacement="I'll" priority="whitelist" />
</entry>
<entry shortcut="acomodate">
<target replacement="accommodate" priority="whitelist" />
</entry>
<entry shortcut="aint">
- <target replacement="ain\'t" priority="whitelist" />
+ <target replacement="ain't" priority="whitelist" />
</entry>
<entry shortcut="alot">
<target replacement="a lot" priority="whitelist" />
@@ -34,7 +34,7 @@
<target replacement="and the" priority="whitelist" />
</entry>
<entry shortcut="arent">
- <target replacement="aren\'t" priority="whitelist" />
+ <target replacement="aren't" priority="whitelist" />
</entry>
<entry shortcut="bern">
<target replacement="been" priority="whitelist" />
@@ -49,13 +49,13 @@
<target replacement="can" priority="whitelist" />
</entry>
<entry shortcut="cant">
- <target replacement="can\'t" priority="whitelist" />
+ <target replacement="can't" priority="whitelist" />
</entry>
<entry shortcut="dame">
<target replacement="same" priority="whitelist" />
</entry>
<entry shortcut="didint">
- <target replacement="didn\'t" priority="whitelist" />
+ <target replacement="didn't" priority="whitelist" />
</entry>
<entry shortcut="dormer">
<target replacement="former" priority="whitelist" />
@@ -82,13 +82,13 @@
<target replacement="too" priority="whitelist" />
</entry>
<entry shortcut="hed">
- <target replacement="he\'d" priority="whitelist" />
+ <target replacement="he'd" priority="whitelist" />
</entry>
<entry shortcut="hel">
- <target replacement="he\'ll" priority="whitelist" />
+ <target replacement="he'll" priority="whitelist" />
</entry>
<entry shortcut="heres">
- <target replacement="here\'s" priority="whitelist" />
+ <target replacement="here's" priority="whitelist" />
</entry>
<entry shortcut="hew">
<target replacement="new" priority="whitelist" />
@@ -97,19 +97,19 @@
<target replacement="how" priority="whitelist" />
</entry>
<entry shortcut="hoes">
- <target replacement="how\'s" priority="whitelist" />
+ <target replacement="how's" priority="whitelist" />
</entry>
<entry shortcut="howd">
- <target replacement="how\'d" priority="whitelist" />
+ <target replacement="how'd" priority="whitelist" />
</entry>
<entry shortcut="howll">
- <target replacement="how\'ll" priority="whitelist" />
+ <target replacement="how'll" priority="whitelist" />
</entry>
<entry shortcut="hows">
- <target replacement="how\'s" priority="whitelist" />
+ <target replacement="how's" priority="whitelist" />
</entry>
<entry shortcut="howve">
- <target replacement="how\'ve" priority="whitelist" />
+ <target replacement="how've" priority="whitelist" />
</entry>
<entry shortcut="hum">
<target replacement="him" priority="whitelist" />
@@ -121,25 +121,25 @@
<target replacement="its" priority="whitelist" />
</entry>
<entry shortcut="il">
- <target replacement="I\'ll" priority="whitelist" />
+ <target replacement="I'll" priority="whitelist" />
</entry>
<entry shortcut="im">
- <target replacement="I\'m" priority="whitelist" />
+ <target replacement="I'm" priority="whitelist" />
</entry>
<entry shortcut="inteh">
<target replacement="in the" priority="whitelist" />
</entry>
<entry shortcut="itd">
- <target replacement="it\'d" priority="whitelist" />
+ <target replacement="it'd" priority="whitelist" />
</entry>
<entry shortcut="itsa">
- <target replacement="it\'s a" priority="whitelist" />
+ <target replacement="it's a" priority="whitelist" />
</entry>
<entry shortcut="lets">
- <target replacement="let\'s" priority="whitelist" />
+ <target replacement="let's" priority="whitelist" />
</entry>
<entry shortcut="maam">
- <target replacement="ma\'am" priority="whitelist" />
+ <target replacement="ma'am" priority="whitelist" />
</entry>
<entry shortcut="manu">
<target replacement="many" priority="whitelist" />
@@ -196,10 +196,10 @@
<target replacement="took" priority="whitelist" />
</entry>
<entry shortcut="shel">
- <target replacement="she\'ll" priority="whitelist" />
+ <target replacement="she'll" priority="whitelist" />
</entry>
<entry shortcut="shouldent">
- <target replacement="shouldn\'t" priority="whitelist" />
+ <target replacement="shouldn't" priority="whitelist" />
</entry>
<entry shortcut="sill">
<target replacement="will" priority="whitelist" />
@@ -208,7 +208,7 @@
<target replacement="down" priority="whitelist" />
</entry>
<entry shortcut="thatd">
- <target replacement="that\'d" priority="whitelist" />
+ <target replacement="that'd" priority="whitelist" />
</entry>
<entry shortcut="tine">
<target replacement="time" priority="whitelist" />
@@ -238,60 +238,60 @@
<target replacement="weird" priority="whitelist" />
</entry>
<entry shortcut="wel">
- <target replacement="we\'ll" priority="whitelist" />
+ <target replacement="we'll" priority="whitelist" />
</entry>
<entry shortcut="wer">
- <target replacement="we\'re" priority="whitelist" />
+ <target replacement="we're" priority="whitelist" />
</entry>
<entry shortcut="whatd">
- <target replacement="what\'d" priority="whitelist" />
+ <target replacement="what'd" priority="whitelist" />
</entry>
<entry shortcut="whatm">
- <target replacement="what\'m" priority="whitelist" />
+ <target replacement="what'm" priority="whitelist" />
</entry>
<entry shortcut="whatre">
- <target replacement="what\'re" priority="whitelist" />
+ <target replacement="what're" priority="whitelist" />
</entry>
<entry shortcut="whats">
- <target replacement="what\'s" priority="whitelist" />
+ <target replacement="what's" priority="whitelist" />
</entry>
<entry shortcut="whens">
- <target replacement="when\'s" priority="whitelist" />
+ <target replacement="when's" priority="whitelist" />
</entry>
<entry shortcut="whered">
- <target replacement="where\'d" priority="whitelist" />
+ <target replacement="where'd" priority="whitelist" />
</entry>
<entry shortcut="wherell">
- <target replacement="where\'ll" priority="whitelist" />
+ <target replacement="where'll" priority="whitelist" />
</entry>
<entry shortcut="wheres">
- <target replacement="where\'s" priority="whitelist" />
+ <target replacement="where's" priority="whitelist" />
</entry>
<entry shortcut="wholl">
- <target replacement="who\'ll" priority="whitelist" />
+ <target replacement="who'll" priority="whitelist" />
</entry>
<entry shortcut="whove">
- <target replacement="who\'ve" priority="whitelist" />
+ <target replacement="who've" priority="whitelist" />
</entry>
<entry shortcut="whyd">
- <target replacement="why\'d" priority="whitelist" />
+ <target replacement="why'd" priority="whitelist" />
</entry>
<entry shortcut="whyll">
- <target replacement="why\'ll" priority="whitelist" />
+ <target replacement="why'll" priority="whitelist" />
</entry>
<entry shortcut="whys">
- <target replacement="why\'s" priority="whitelist" />
+ <target replacement="why's" priority="whitelist" />
</entry>
<entry shortcut="whyve">
- <target replacement="why\'ve" priority="whitelist" />
+ <target replacement="why've" priority="whitelist" />
</entry>
<entry shortcut="wont">
- <target replacement="won\'t" priority="whitelist" />
+ <target replacement="won't" priority="whitelist" />
</entry>
<entry shortcut="yall">
- <target replacement="y\'all" priority="whitelist" />
+ <target replacement="y'all" priority="whitelist" />
</entry>
<entry shortcut="youd">
- <target replacement="you\'d" priority="whitelist" />
+ <target replacement="you'd" priority="whitelist" />
</entry>
</shortcuts>
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 85360c4..faa08db 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -29,7 +29,6 @@
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.LatinImeLogger;
-import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.research.ResearchLogger;
@@ -130,10 +129,6 @@
private static final InputPointers sAggregratedPointers = new InputPointers(
GestureStroke.DEFAULT_CAPACITY);
private static PointerTrackerQueue sPointerTrackerQueue;
- // HACK: Change gesture detection criteria depending on this variable.
- // TODO: Find more comprehensive ways to detect a gesture start.
- // True when the previous user input was a gesture input, not a typing input.
- private static boolean sWasInGesture;
public final int mPointerId;
@@ -586,7 +581,6 @@
mListener.onEndBatchInput(batchPoints);
clearBatchInputRecognitionStateOfThisPointerTracker();
clearBatchInputPointsOfAllPointerTrackers();
- sWasInGesture = true;
}
private void abortBatchInput() {
@@ -719,7 +713,7 @@
if (sShouldHandleGesture && mIsPossibleGesture) {
final GestureStroke stroke = mGestureStroke;
stroke.addPoint(x, y, gestureTime, isHistorical);
- if (!mInGesture && stroke.isStartOfAGesture(gestureTime, sWasInGesture)) {
+ if (!mInGesture && stroke.isStartOfAGesture(gestureTime)) {
startBatchInput();
}
}
@@ -1002,7 +996,6 @@
int code = key.mCode;
callListenerOnCodeInput(key, code, x, y);
callListenerOnRelease(key, code, false);
- sWasInGesture = false;
}
private void printTouchEvent(String title, int x, int y, long eventTime) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
index 5ccb40f..778e8e5 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
@@ -37,14 +37,11 @@
private int mLastPointY;
private int mMinGestureLength;
- private int mMinGestureLengthWhileInGesture;
private int mMinGestureSampleLength;
// TODO: Move some of these to resource.
- private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 1.0f;
- private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE = 0.5f;
- private static final int MIN_GESTURE_DURATION = 150; // msec
- private static final int MIN_GESTURE_DURATION_WHILE_IN_GESTURE = 75; // msec
+ private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f;
+ private static final int MIN_GESTURE_DURATION = 100; // msec
private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT = 1.0f / 6.0f;
private static final float GESTURE_RECOG_SPEED_THRESHOLD = 0.4f; // dip/msec
private static final float GESTURE_RECOG_CURVATURE_THRESHOLD = (float)(Math.PI / 4.0f);
@@ -63,18 +60,10 @@
public void setGestureSampleLength(final int keyWidth, final int keyHeight) {
// TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key?
mMinGestureLength = (int)(keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH);
- mMinGestureLengthWhileInGesture = (int)(
- keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE);
mMinGestureSampleLength = (int)(keyHeight * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT);
}
- public boolean isStartOfAGesture(final int downDuration, final boolean wasInGesture) {
- // The tolerance of the time duration and the stroke length to detect the start of a
- // gesture stroke should be eased when the previous input was a gesture input.
- if (wasInGesture) {
- return downDuration > MIN_GESTURE_DURATION_WHILE_IN_GESTURE
- && mLength > mMinGestureLengthWhileInGesture;
- }
+ public boolean isStartOfAGesture(final int downDuration) {
return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength;
}
diff --git a/native/jni/src/geometry_utils.h b/native/jni/src/geometry_utils.h
index 65611b9..168542e 100644
--- a/native/jni/src/geometry_utils.h
+++ b/native/jni/src/geometry_utils.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef LATINIME_INCREMENTAL_GEOMETRY_UTILS_H
-#define LATINIME_INCREMENTAL_GEOMETRY_UTILS_H
+#ifndef LATINIME_GEOMETRY_UTILS_H
+#define LATINIME_GEOMETRY_UTILS_H
#include <cmath>
@@ -49,21 +49,18 @@
}
static inline float getAngle(int x1, int y1, int x2, int y2) {
- int dx = x1 - x2;
- int dy = y1 - y2;
+ const int dx = x1 - x2;
+ const int dy = y1 - y2;
if (dx == 0 && dy == 0) {
return 0;
}
- float dxf = static_cast<float>(dx);
- float dyf = static_cast<float>(dy);
+ const float dxf = static_cast<float>(dx);
+ const float dyf = static_cast<float>(dy);
return atan2f(dyf, dxf);
}
static inline float angleDiff(float a1, float a2) {
- float diff = a1 - a2;
- if (diff < 0) {
- diff = -diff;
- }
+ const float diff = fabsf(a1 - a2);
if (diff > M_PI_F) {
return 2.0f * M_PI_F - diff;
}
@@ -76,32 +73,33 @@
// float B = y - y1;
// float C = x2 - x1;
// float D = y2 - y1;
-// return abs(A * D - C * B) / sqrt(C * C + D * D);
+// return fabsf(A * D - C * B) / sqrtf(C * C + D * D);
// }
static inline float pointToLineSegDistanceSqrFloat(
float x, float y, float x1, float y1, float x2, float y2) {
- float ray1x = x - x1;
- float ray1y = y - y1;
- float ray2x = x2 - x1;
- float ray2y = y2 - y1;
+ const float ray1x = x - x1;
+ const float ray1y = y - y1;
+ const float ray2x = x2 - x1;
+ const float ray2y = y2 - y1;
- float dotProduct = ray1x * ray2x + ray1y * ray2y;
- float lineLengthSq = ray2x * ray2x + ray2y * ray2y;
- float projectionLengthSq = dotProduct / lineLengthSq;
+ const float dotProduct = ray1x * ray2x + ray1y * ray2y;
+ const float lineLengthSqr = sqrf(ray2x) + sqrf(ray2y);
+ const float projectionLengthSqr = dotProduct / lineLengthSqr;
- float projectionX, projectionY;
- if (projectionLengthSq < 0) {
+ float projectionX;
+ float projectionY;
+ if (projectionLengthSqr < 0.0f) {
projectionX = x1;
projectionY = y1;
- } else if (projectionLengthSq > 1) {
+ } else if (projectionLengthSqr > 1.0f) {
projectionX = x2;
projectionY = y2;
} else {
- projectionX = x1 + projectionLengthSq * ray2x;
- projectionY = y1 + projectionLengthSq * ray2y;
+ projectionX = x1 + projectionLengthSqr * ray2x;
+ projectionY = y1 + projectionLengthSqr * ray2y;
}
return getDistanceSqrFloat(x, y, projectionX, projectionY);
}
} // namespace latinime
-#endif // LATINIME_INCREMENTAL_GEOMETRY_UTILS_H
+#endif // LATINIME_GEOMETRY_UTILS_H