2011-02-22 08:28:55 +00:00
|
|
|
/*
|
2013-01-08 08:57:26 +00:00
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
2012-07-25 09:51:43 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2013-01-08 08:57:26 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-07-25 09:51:43 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2011-02-22 08:28:55 +00:00
|
|
|
|
|
|
|
#define LOG_TAG "LatinIME: jni: ProximityInfo"
|
|
|
|
|
|
|
|
#include "com_android_inputmethod_keyboard_ProximityInfo.h"
|
2012-10-08 03:46:14 +01:00
|
|
|
#include "defines.h"
|
2011-02-22 08:28:55 +00:00
|
|
|
#include "jni.h"
|
2011-06-18 05:09:55 +01:00
|
|
|
#include "jni_common.h"
|
2011-02-22 08:28:55 +00:00
|
|
|
#include "proximity_info.h"
|
|
|
|
|
|
|
|
namespace latinime {
|
|
|
|
|
2011-10-31 11:44:01 +00:00
|
|
|
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
|
2012-08-08 08:46:16 +01:00
|
|
|
jstring localeJStr, jint maxProximityCharsSize, jint displayWidth, jint displayHeight,
|
2012-08-08 12:43:47 +01:00
|
|
|
jint gridWidth, jint gridHeight, jint mostCommonkeyWidth, jintArray proximityChars,
|
|
|
|
jint keyCount, jintArray keyXCoordinates, jintArray keyYCoordinates,
|
|
|
|
jintArray keyWidths, jintArray keyHeights, jintArray keyCharCodes,
|
|
|
|
jfloatArray sweetSpotCenterXs, jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
|
2012-08-09 07:58:15 +01:00
|
|
|
ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, maxProximityCharsSize,
|
2012-08-08 12:43:47 +01:00
|
|
|
displayWidth, displayHeight, gridWidth, gridHeight, mostCommonkeyWidth, proximityChars,
|
|
|
|
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
|
|
|
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
|
|
|
return reinterpret_cast<jlong>(proximityInfo);
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
|
|
|
|
2011-10-31 11:44:01 +00:00
|
|
|
static void latinime_Keyboard_release(JNIEnv *env, jobject object, jlong proximityInfo) {
|
2012-08-14 06:22:27 +01:00
|
|
|
ProximityInfo *pi = reinterpret_cast<ProximityInfo *>(proximityInfo);
|
2011-02-22 08:28:55 +00:00
|
|
|
delete pi;
|
|
|
|
}
|
|
|
|
|
2012-10-08 03:46:14 +01:00
|
|
|
static JNINativeMethod sMethods[] = {
|
2012-03-13 07:33:47 +00:00
|
|
|
{"setProximityInfoNative", "(Ljava/lang/String;IIIIII[II[I[I[I[I[I[F[F[F)J",
|
2012-08-12 03:10:48 +01:00
|
|
|
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)},
|
|
|
|
{"releaseProximityInfoNative", "(J)V", reinterpret_cast<void *>(latinime_Keyboard_release)}
|
2011-02-22 08:28:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int register_ProximityInfo(JNIEnv *env) {
|
2011-09-27 03:15:18 +01:00
|
|
|
const char *const kClassPathName = "com/android/inputmethod/keyboard/ProximityInfo";
|
2012-10-08 03:46:14 +01:00
|
|
|
return registerNativeMethods(env, kClassPathName, sMethods, NELEMS(sMethods));
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
2011-06-18 05:09:55 +01:00
|
|
|
} // namespace latinime
|