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"
|
2013-05-30 11:45:53 +01:00
|
|
|
|
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"
|
2013-05-30 11:45:53 +01:00
|
|
|
#include "suggest/core/layout/proximity_info.h"
|
2011-02-22 08:28:55 +00:00
|
|
|
|
|
|
|
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,
|
2013-04-10 03:40:53 +01:00
|
|
|
jint mostCommonkeyWidth, jint mostCommonkeyHeight, 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,
|
2013-04-10 03:40:53 +01:00
|
|
|
gridWidth, gridHeight, mostCommonkeyWidth, mostCommonkeyHeight, proximityChars,
|
|
|
|
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
2012-08-08 12:43:47 +01: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 06:22:27 +01:00
|
|
|
ProximityInfo *pi = reinterpret_cast<ProximityInfo *>(proximityInfo);
|
2011-02-22 08:28:55 +00:00
|
|
|
delete pi;
|
|
|
|
}
|
|
|
|
|
2013-06-04 11:16:47 +01:00
|
|
|
static const JNINativeMethod sMethods[] = {
|
|
|
|
{
|
|
|
|
const_cast<char *>("setProximityInfoNative"),
|
|
|
|
const_cast<char *>("(Ljava/lang/String;IIIIII[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 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
|