am a59f65ad
: Merge "Extend JNI interface to pass the theme id of the keybaord to the native."
* commit 'a59f65ad0cadfd2e71ebbe7ca8b14285a4db6ae2': Extend JNI interface to pass the theme id of the keybaord to the native.
This commit is contained in:
commit
386489983d
5 changed files with 15 additions and 9 deletions
|
@ -47,6 +47,7 @@
|
||||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/LatinIME*)
|
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/LatinIME*)
|
||||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/LatinIME.apk)
|
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/LatinIME.apk)
|
||||||
|
|
||||||
|
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
|
||||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
|
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
|
||||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
|
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
|
||||||
# ************************************************
|
# ************************************************
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class ProximityInfo {
|
||||||
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
|
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
|
||||||
/** Number of key widths from current touch point to search for nearest keys. */
|
/** Number of key widths from current touch point to search for nearest keys. */
|
||||||
private static float SEARCH_DISTANCE = 1.2f;
|
private static float SEARCH_DISTANCE = 1.2f;
|
||||||
|
private static final int UNKNOWN_THEME = -1;
|
||||||
private static final int[] EMPTY_INT_ARRAY = new int[0];
|
private static final int[] EMPTY_INT_ARRAY = new int[0];
|
||||||
|
|
||||||
private final int mGridWidth;
|
private final int mGridWidth;
|
||||||
|
@ -66,7 +67,7 @@ public class ProximityInfo {
|
||||||
spellCheckerProximityInfo.setProximityInfoNative(
|
spellCheckerProximityInfo.setProximityInfoNative(
|
||||||
SpellCheckerProximityInfo.ROW_SIZE,
|
SpellCheckerProximityInfo.ROW_SIZE,
|
||||||
480, 300, 10, 3, SpellCheckerProximityInfo.PROXIMITY,
|
480, 300, 10, 3, SpellCheckerProximityInfo.PROXIMITY,
|
||||||
0, null, null, null, null, null);
|
0, null, null, null, null, null, UNKNOWN_THEME);
|
||||||
return spellCheckerProximityInfo;
|
return spellCheckerProximityInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public class ProximityInfo {
|
||||||
private native int setProximityInfoNative(int maxProximityCharsSize, int displayWidth,
|
private native int setProximityInfoNative(int maxProximityCharsSize, int displayWidth,
|
||||||
int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray,
|
int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray,
|
||||||
int keyCount, int[] keyXCoordinates, int[] keyYCoordinates,
|
int keyCount, int[] keyXCoordinates, int[] keyYCoordinates,
|
||||||
int[] keyWidths, int[] keyHeights, int[] keyCharCodes);
|
int[] keyWidths, int[] keyHeights, int[] keyCharCodes, int themeId);
|
||||||
private native void releaseProximityInfoNative(int nativeProximityInfo);
|
private native void releaseProximityInfoNative(int nativeProximityInfo);
|
||||||
|
|
||||||
private final void setProximityInfo(int[][] gridNeighborKeyIndexes, int keyboardWidth,
|
private final void setProximityInfo(int[][] gridNeighborKeyIndexes, int keyboardWidth,
|
||||||
|
@ -97,6 +98,7 @@ public class ProximityInfo {
|
||||||
int[] keyWidths = new int[keyCount];
|
int[] keyWidths = new int[keyCount];
|
||||||
int[] keyHeights = new int[keyCount];
|
int[] keyHeights = new int[keyCount];
|
||||||
int[] keyCharCodes = new int[keyCount];
|
int[] keyCharCodes = new int[keyCount];
|
||||||
|
final int themeId = 5; // TODO: Use real theme id.
|
||||||
for (int i = 0; i < keyCount; ++i) {
|
for (int i = 0; i < keyCount; ++i) {
|
||||||
final Key key = keys.get(i);
|
final Key key = keys.get(i);
|
||||||
keyXCoordinates[i] = key.mX;
|
keyXCoordinates[i] = key.mX;
|
||||||
|
@ -107,7 +109,8 @@ public class ProximityInfo {
|
||||||
}
|
}
|
||||||
mNativeProximityInfo = setProximityInfoNative(MAX_PROXIMITY_CHARS_SIZE,
|
mNativeProximityInfo = setProximityInfoNative(MAX_PROXIMITY_CHARS_SIZE,
|
||||||
keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, proximityCharsArray,
|
keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, proximityCharsArray,
|
||||||
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes);
|
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
||||||
|
themeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNativeProximityInfo() {
|
public int getNativeProximityInfo() {
|
||||||
|
|
|
@ -32,7 +32,7 @@ static jint latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
|
||||||
jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth,
|
jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth,
|
||||||
jint gridHeight, jintArray proximityCharsArray, jint keyCount,
|
jint gridHeight, jintArray proximityCharsArray, jint keyCount,
|
||||||
jintArray keyXCoordinateArray, jintArray keyYCoordinateArray, jintArray keyWidthArray,
|
jintArray keyXCoordinateArray, jintArray keyYCoordinateArray, jintArray keyWidthArray,
|
||||||
jintArray keyHeightArray, jintArray keyCharCodeArray) {
|
jintArray keyHeightArray, jintArray keyCharCodeArray, jint themeId) {
|
||||||
jint *proximityChars = env->GetIntArrayElements(proximityCharsArray, NULL);
|
jint *proximityChars = env->GetIntArrayElements(proximityCharsArray, NULL);
|
||||||
jint *keyXCoordinates = safeGetIntArrayElements(env, keyXCoordinateArray);
|
jint *keyXCoordinates = safeGetIntArrayElements(env, keyXCoordinateArray);
|
||||||
jint *keyYCoordinates = safeGetIntArrayElements(env, keyYCoordinateArray);
|
jint *keyYCoordinates = safeGetIntArrayElements(env, keyYCoordinateArray);
|
||||||
|
@ -42,7 +42,8 @@ static jint latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
|
||||||
ProximityInfo *proximityInfo = new ProximityInfo(maxProximityCharsSize, displayWidth,
|
ProximityInfo *proximityInfo = new ProximityInfo(maxProximityCharsSize, displayWidth,
|
||||||
displayHeight, gridWidth, gridHeight, (const uint32_t*)proximityChars,
|
displayHeight, gridWidth, gridHeight, (const uint32_t*)proximityChars,
|
||||||
keyCount, (const int32_t*)keyXCoordinates, (const int32_t*)keyYCoordinates,
|
keyCount, (const int32_t*)keyXCoordinates, (const int32_t*)keyYCoordinates,
|
||||||
(const int32_t*)keyWidths, (const int32_t*)keyHeights, (const int32_t*)keyCharCodes);
|
(const int32_t*)keyWidths, (const int32_t*)keyHeights, (const int32_t*)keyCharCodes,
|
||||||
|
themeId);
|
||||||
safeReleaseIntArrayElements(env, keyCharCodeArray, keyCharCodes);
|
safeReleaseIntArrayElements(env, keyCharCodeArray, keyCharCodes);
|
||||||
safeReleaseIntArrayElements(env, keyHeightArray, keyHeights);
|
safeReleaseIntArrayElements(env, keyHeightArray, keyHeights);
|
||||||
safeReleaseIntArrayElements(env, keyWidthArray, keyWidths);
|
safeReleaseIntArrayElements(env, keyWidthArray, keyWidths);
|
||||||
|
@ -59,7 +60,7 @@ static void latinime_Keyboard_release(JNIEnv *env, jobject object, jint proximit
|
||||||
}
|
}
|
||||||
|
|
||||||
static JNINativeMethod sKeyboardMethods[] = {
|
static JNINativeMethod sKeyboardMethods[] = {
|
||||||
{"setProximityInfoNative", "(IIIII[II[I[I[I[I[I)I", (void*)latinime_Keyboard_setProximityInfo},
|
{"setProximityInfoNative", "(IIIII[II[I[I[I[I[II)I", (void*)latinime_Keyboard_setProximityInfo},
|
||||||
{"releaseProximityInfoNative", "(I)V", (void*)latinime_Keyboard_release}
|
{"releaseProximityInfoNative", "(I)V", (void*)latinime_Keyboard_release}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,12 @@ ProximityInfo::ProximityInfo(const int maxProximityCharsSize, const int keyboard
|
||||||
const int keyboardHeight, const int gridWidth, const int gridHeight,
|
const int keyboardHeight, const int gridWidth, const int gridHeight,
|
||||||
const uint32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates,
|
const uint32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates,
|
||||||
const int32_t *keyYCoordinates, const int32_t *keyWidths, const int32_t *keyHeights,
|
const int32_t *keyYCoordinates, const int32_t *keyWidths, const int32_t *keyHeights,
|
||||||
const int32_t *keyCharCodes)
|
const int32_t *keyCharCodes, int themeId)
|
||||||
: MAX_PROXIMITY_CHARS_SIZE(maxProximityCharsSize), KEYBOARD_WIDTH(keyboardWidth),
|
: MAX_PROXIMITY_CHARS_SIZE(maxProximityCharsSize), KEYBOARD_WIDTH(keyboardWidth),
|
||||||
KEYBOARD_HEIGHT(keyboardHeight), GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight),
|
KEYBOARD_HEIGHT(keyboardHeight), GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight),
|
||||||
CELL_WIDTH((keyboardWidth + gridWidth - 1) / gridWidth),
|
CELL_WIDTH((keyboardWidth + gridWidth - 1) / gridWidth),
|
||||||
CELL_HEIGHT((keyboardHeight + gridHeight - 1) / gridHeight),
|
CELL_HEIGHT((keyboardHeight + gridHeight - 1) / gridHeight),
|
||||||
KEY_COUNT(min(keyCount, MAX_KEY_COUNT_IN_A_KEYBOARD)) {
|
KEY_COUNT(min(keyCount, MAX_KEY_COUNT_IN_A_KEYBOARD)), THEME_ID(themeId) {
|
||||||
const int len = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
const int len = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
||||||
mProximityCharsArray = new uint32_t[len];
|
mProximityCharsArray = new uint32_t[len];
|
||||||
if (DEBUG_PROXIMITY_INFO) {
|
if (DEBUG_PROXIMITY_INFO) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
const int keybaordHeight, const int gridWidth, const int gridHeight,
|
const int keybaordHeight, const int gridWidth, const int gridHeight,
|
||||||
const uint32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates,
|
const uint32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates,
|
||||||
const int32_t *keyYCoordinates, const int32_t *keyWidths, const int32_t *keyHeights,
|
const int32_t *keyYCoordinates, const int32_t *keyWidths, const int32_t *keyHeights,
|
||||||
const int32_t *keyCharCodes);
|
const int32_t *keyCharCodes, int themeId);
|
||||||
~ProximityInfo();
|
~ProximityInfo();
|
||||||
bool hasSpaceProximity(const int x, const int y) const;
|
bool hasSpaceProximity(const int x, const int y) const;
|
||||||
void setInputParams(const int* inputCodes, const int inputLength);
|
void setInputParams(const int* inputCodes, const int inputLength);
|
||||||
|
@ -69,6 +69,7 @@ private:
|
||||||
const int CELL_WIDTH;
|
const int CELL_WIDTH;
|
||||||
const int CELL_HEIGHT;
|
const int CELL_HEIGHT;
|
||||||
const int KEY_COUNT;
|
const int KEY_COUNT;
|
||||||
|
const int THEME_ID;
|
||||||
const int *mInputCodes;
|
const int *mInputCodes;
|
||||||
uint32_t *mProximityCharsArray;
|
uint32_t *mProximityCharsArray;
|
||||||
int32_t mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int32_t mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
|
|
Loading…
Reference in a new issue