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 08:51:43 +00: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 08:51:43 +00: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 02:46:14 +00:00
|
|
|
#include "defines.h"
|
2011-02-22 08:28:55 +00:00
|
|
|
#include "jni.h"
|
2011-06-18 04:09:55 +00:00
|
|
|
#include "jni_common.h"
|
2011-02-22 08:28:55 +00:00
|
|
|
#include "proximity_info.h"
|
|
|
|
|
|
|
|
namespace latinime {
|
|
|
|
|
2013-01-11 16:18:00 +00:00
|
|
|
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz, jstring localeJStr,
|
2013-01-22 04:14:53 +00:00
|
|
|
jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight,
|
|
|
|
jint mostCommonkeyWidth, jintArray proximityChars, jint keyCount,
|
2013-01-11 16:18:00 +00:00
|
|
|
jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths,
|
|
|
|
jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs,
|
|
|
|
jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
|
2013-01-22 04:14:53 +00:00
|
|
|
ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, displayWidth, displayHeight,
|
|
|
|
gridWidth, gridHeight, mostCommonkeyWidth, proximityChars, keyCount,
|
|
|
|
keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
2012-08-08 11:43:47 +00:00
|
|
|
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
|
|
|
return reinterpret_cast<jlong>(proximityInfo);
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
|
|
|
|
2013-01-11 16:18:00 +00:00
|
|
|
static void latinime_Keyboard_release(JNIEnv *env, jclass clazz, jlong proximityInfo) {
|
2012-08-14 05:22:27 +00:00
|
|
|
ProximityInfo *pi = reinterpret_cast<ProximityInfo *>(proximityInfo);
|
2011-02-22 08:28:55 +00:00
|
|
|
delete pi;
|
|
|
|
}
|
|
|
|
|
2012-10-08 02:46:14 +00:00
|
|
|
static JNINativeMethod sMethods[] = {
|
2013-03-26 08:56:33 +00:00
|
|
|
{const_cast<char *>("setProximityInfoNative"),
|
|
|
|
const_cast<char *>("(Ljava/lang/String;IIIII[II[I[I[I[I[I[F[F[F)J"),
|
|
|
|
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)},
|
|
|
|
{const_cast<char *>("releaseProximityInfoNative"),
|
|
|
|
const_cast<char *>("(J)V"),
|
|
|
|
reinterpret_cast<void *>(latinime_Keyboard_release)}
|
2011-02-22 08:28:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int register_ProximityInfo(JNIEnv *env) {
|
2011-09-27 02:15:18 +00:00
|
|
|
const char *const kClassPathName = "com/android/inputmethod/keyboard/ProximityInfo";
|
2012-10-08 02:46:14 +00:00
|
|
|
return registerNativeMethods(env, kClassPathName, sMethods, NELEMS(sMethods));
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
2011-06-18 04:09:55 +00:00
|
|
|
} // namespace latinime
|