From 87fdde6ec48844ddbb482c50fbda226c63ca5e85 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroynagi Date: Wed, 10 Apr 2013 11:40:53 +0900 Subject: [PATCH] Typing double letters via a 'circle' on the key. Bug: 8550980 Change-Id: I5e432dea0e025ccea196f80e90a6bf945488e130 --- .../inputmethod/keyboard/ProximityInfo.java | 18 ++++++++++-------- ...roid_inputmethod_keyboard_ProximityInfo.cpp | 8 ++++---- native/jni/src/proximity_info.cpp | 14 +++++++++----- native/jni/src/proximity_info.h | 15 ++++++++++----- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index 809ed6839..b77e378bf 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -88,8 +88,9 @@ public class ProximityInfo { this("", 1, 1, 1, 1, 1, 1, EMPTY_KEY_ARRAY, null); mNativeProximityInfo = setProximityInfoNative("" /* locale */, gridWidth /* displayWidth */, gridHeight /* displayHeight */, - gridWidth, gridHeight, 1 /* mostCommonKeyWidth */, proximityCharsArray, - 0 /* keyCount */, null /*keyXCoordinates */, null /* keyYCoordinates */, + gridWidth, gridHeight, 1 /* mostCommonKeyWidth */, + 1 /* mostCommonKeyHeight */, proximityCharsArray, 0 /* keyCount */, + null /*keyXCoordinates */, null /* keyYCoordinates */, null /* keyWidths */, null /* keyHeights */, null /* keyCharCodes */, null /* sweetSpotCenterXs */, null /* sweetSpotCenterYs */, null /* sweetSpotRadii */); @@ -103,9 +104,10 @@ public class ProximityInfo { // TODO: Stop passing proximityCharsArray private static native long setProximityInfoNative(String locale, int displayWidth, int displayHeight, int gridWidth, int gridHeight, - int mostCommonKeyWidth, int[] proximityCharsArray, int keyCount, int[] keyXCoordinates, - int[] keyYCoordinates, int[] keyWidths, int[] keyHeights, int[] keyCharCodes, - float[] sweetSpotCenterXs, float[] sweetSpotCenterYs, float[] sweetSpotRadii); + int mostCommonKeyWidth, int mostCommonKeyHeight, int[] proximityCharsArray, + int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, int[] keyWidths, + int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterXs, + float[] sweetSpotCenterYs, float[] sweetSpotRadii); private static native void releaseProximityInfoNative(long nativeProximityInfo); @@ -232,9 +234,9 @@ public class ProximityInfo { // TODO: Stop passing proximityCharsArray return setProximityInfoNative(mLocaleStr, mKeyboardMinWidth, mKeyboardHeight, - mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray, keyCount, - keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes, - sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii); + mGridWidth, mGridHeight, mMostCommonKeyWidth, mMostCommonKeyHeight, + proximityCharsArray, keyCount, keyXCoordinates, keyYCoordinates, keyWidths, + keyHeights, keyCharCodes, sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii); } public long getNativeProximityInfo() { diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp index 3c482ca58..dedb02abf 100644 --- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp +++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp @@ -26,13 +26,13 @@ namespace latinime { static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz, jstring localeJStr, jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight, - jint mostCommonkeyWidth, jintArray proximityChars, jint keyCount, + jint mostCommonkeyWidth, jint mostCommonkeyHeight, jintArray proximityChars, jint keyCount, jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths, jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs, jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) { ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, displayWidth, displayHeight, - gridWidth, gridHeight, mostCommonkeyWidth, proximityChars, keyCount, - keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes, + gridWidth, gridHeight, mostCommonkeyWidth, mostCommonkeyHeight, proximityChars, + keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes, sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii); return reinterpret_cast(proximityInfo); } @@ -44,7 +44,7 @@ static void latinime_Keyboard_release(JNIEnv *env, jclass clazz, jlong proximity static JNINativeMethod sMethods[] = { {const_cast("setProximityInfoNative"), - const_cast("(Ljava/lang/String;IIIII[II[I[I[I[I[I[F[F[F)J"), + const_cast("(Ljava/lang/String;IIIIII[II[I[I[I[I[I[F[F[F)J"), reinterpret_cast(latinime_Keyboard_setProximityInfo)}, {const_cast("releaseProximityInfoNative"), const_cast("(J)V"), diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp index 50f38e82e..88d670d61 100644 --- a/native/jni/src/proximity_info.cpp +++ b/native/jni/src/proximity_info.cpp @@ -49,13 +49,17 @@ static AK_FORCE_INLINE void safeGetOrFillZeroFloatArrayRegion(JNIEnv *env, jfloa ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int keyboardWidth, const int keyboardHeight, const int gridWidth, - const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars, - const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates, - const jintArray keyWidths, const jintArray keyHeights, const jintArray keyCharCodes, - const jfloatArray sweetSpotCenterXs, const jfloatArray sweetSpotCenterYs, - const jfloatArray sweetSpotRadii) + const int gridHeight, const int mostCommonKeyWidth, const int mostCommonKeyHeight, + const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates, + const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights, + const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs, + const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii) : GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth), MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth), + MOST_COMMON_KEY_HEIGHT(mostCommonKeyHeight), + NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE(1.0f + + SQUARE_FLOAT(static_cast(mostCommonKeyHeight) / + static_cast(mostCommonKeyWidth))), CELL_WIDTH((keyboardWidth + gridWidth - 1) / gridWidth), CELL_HEIGHT((keyboardHeight + gridHeight - 1) / gridHeight), KEY_COUNT(min(keyCount, MAX_KEY_COUNT_IN_A_KEYBOARD)), diff --git a/native/jni/src/proximity_info.h b/native/jni/src/proximity_info.h index e21262fdb..deb9ae0de 100644 --- a/native/jni/src/proximity_info.h +++ b/native/jni/src/proximity_info.h @@ -30,11 +30,11 @@ class ProximityInfo { public: ProximityInfo(JNIEnv *env, const jstring localeJStr, const int keyboardWidth, const int keyboardHeight, const int gridWidth, - const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars, - const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates, - const jintArray keyWidths, const jintArray keyHeights, const jintArray keyCharCodes, - const jfloatArray sweetSpotCenterXs, const jfloatArray sweetSpotCenterYs, - const jfloatArray sweetSpotRadii); + const int gridHeight, const int mostCommonKeyWidth, const int mostCommonKeyHeight, + const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates, + const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights, + const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs, + const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii); ~ProximityInfo(); bool hasSpaceProximity(const int x, const int y) const; int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const; @@ -56,6 +56,9 @@ class ProximityInfo { bool hasTouchPositionCorrectionData() const { return HAS_TOUCH_POSITION_CORRECTION_DATA; } int getMostCommonKeyWidth() const { return MOST_COMMON_KEY_WIDTH; } int getMostCommonKeyWidthSquare() const { return MOST_COMMON_KEY_WIDTH_SQUARE; } + float getNormalizedSquaredMostCommonKeyHypotenuse() const { + return NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE; + } int getKeyCount() const { return KEY_COUNT; } int getCellHeight() const { return CELL_HEIGHT; } int getCellWidth() const { return CELL_WIDTH; } @@ -99,6 +102,8 @@ class ProximityInfo { const int GRID_HEIGHT; const int MOST_COMMON_KEY_WIDTH; const int MOST_COMMON_KEY_WIDTH_SQUARE; + const int MOST_COMMON_KEY_HEIGHT; + const float NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE; const int CELL_WIDTH; const int CELL_HEIGHT; const int KEY_COUNT;