diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp index 74390ccdf..0f2c2da43 100644 --- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp +++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp @@ -16,8 +16,6 @@ #define LOG_TAG "LatinIME: jni: ProximityInfo" -#include - #include "com_android_inputmethod_keyboard_ProximityInfo.h" #include "jni.h" #include "jni_common.h" @@ -26,14 +24,13 @@ namespace latinime { static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object, - jstring localejStr, jint maxProximityCharsSize, jint displayWidth, jint displayHeight, + jstring localeJStr, jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight, jint mostCommonkeyWidth, jintArray proximityCharsArray, jint keyCount, jintArray keyXCoordinateArray, jintArray keyYCoordinateArray, jintArray keyWidthArray, jintArray keyHeightArray, jintArray keyCharCodeArray, jfloatArray sweetSpotCenterXArray, jfloatArray sweetSpotCenterYArray, jfloatArray sweetSpotRadiusArray) { - const char *localeStrPtr = env->GetStringUTFChars(localejStr, 0); - const std::string localeStr(localeStrPtr); + const char *localeCStr = env->GetStringUTFChars(localeJStr, 0); jint *proximityChars = env->GetIntArrayElements(proximityCharsArray, 0); jint *keyXCoordinates = safeGetIntArrayElements(env, keyXCoordinateArray); jint *keyYCoordinates = safeGetIntArrayElements(env, keyYCoordinateArray); @@ -44,7 +41,7 @@ static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object, jfloat *sweetSpotCenterYs = safeGetFloatArrayElements(env, sweetSpotCenterYArray); jfloat *sweetSpotRadii = safeGetFloatArrayElements(env, sweetSpotRadiusArray); ProximityInfo *proximityInfo = new ProximityInfo( - localeStr, maxProximityCharsSize, displayWidth, displayHeight, gridWidth, gridHeight, + localeCStr, maxProximityCharsSize, displayWidth, displayHeight, gridWidth, gridHeight, mostCommonkeyWidth, (const int32_t*)proximityChars, keyCount, (const int32_t*)keyXCoordinates, (const int32_t*)keyYCoordinates, (const int32_t*)keyWidths, (const int32_t*)keyHeights, (const int32_t*)keyCharCodes, @@ -59,7 +56,7 @@ static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object, safeReleaseIntArrayElements(env, keyYCoordinateArray, keyYCoordinates); safeReleaseIntArrayElements(env, keyXCoordinateArray, keyXCoordinates); env->ReleaseIntArrayElements(proximityCharsArray, proximityChars, 0); - env->ReleaseStringUTFChars(localejStr, localeStrPtr); + env->ReleaseStringUTFChars(localeJStr, localeCStr); return (jlong)proximityInfo; } diff --git a/native/jni/jni_common.cpp b/native/jni/jni_common.cpp index 105a4dc4c..d45f97a52 100644 --- a/native/jni/jni_common.cpp +++ b/native/jni/jni_common.cpp @@ -16,6 +16,8 @@ #define LOG_TAG "LatinIME: jni" +#include + #include "com_android_inputmethod_keyboard_ProximityInfo.h" #include "com_android_inputmethod_latin_BinaryDictionary.h" #include "com_android_inputmethod_latin_NativeUtils.h" @@ -23,8 +25,6 @@ #include "jni.h" #include "jni_common.h" -#include - using namespace latinime; /* diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp index cee408d46..e9cb14e63 100644 --- a/native/jni/src/proximity_info.cpp +++ b/native/jni/src/proximity_info.cpp @@ -36,7 +36,7 @@ inline void copyOrFillZero(void *to, const void *from, size_t size) { } } -ProximityInfo::ProximityInfo(const std::string localeStr, const int maxProximityCharsSize, +ProximityInfo::ProximityInfo(const char *localeCStr, const int maxProximityCharsSize, const int keyboardWidth, const int keyboardHeight, const int gridWidth, const int gridHeight, const int mostCommonKeyWidth, const int32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates, @@ -52,7 +52,7 @@ ProximityInfo::ProximityInfo(const std::string localeStr, const int maxProximity HAS_TOUCH_POSITION_CORRECTION_DATA(keyCount > 0 && keyXCoordinates && keyYCoordinates && keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs && sweetSpotCenterYs && sweetSpotRadii), - mLocaleStr(localeStr) { + mLocaleStr(localeCStr) { const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE; if (DEBUG_PROXIMITY_INFO) { AKLOGI("Create proximity info array %d", proximityGridLength); diff --git a/native/jni/src/proximity_info.h b/native/jni/src/proximity_info.h index abd07dd3e..6c5c6bf99 100644 --- a/native/jni/src/proximity_info.h +++ b/native/jni/src/proximity_info.h @@ -28,7 +28,7 @@ class Correction; class ProximityInfo { public: - ProximityInfo(const std::string localeStr, const int maxProximityCharsSize, + ProximityInfo(const char *localeCStr, const int maxProximityCharsSize, const int keyboardWidth, const int keyboardHeight, const int gridWidth, const int gridHeight, const int mostCommonkeyWidth, const int32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates,