LatinIME/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
Jean Chalard 4ef27c0358 [ML13] Fix the locale passing in ProximityInfo
The locale is used to determine additional proximity characters. This
is dependent on the dictionary language, but was passed as a function
of the layout, which is wrong and would have given bad suggestions in
multi-lingual mode.

Ideally, additional proximity characters should be inserted in the
dictionary header, but for now it's a rather simple change to get
it from the dictionary's locale instead of the proximity info locale.

Also, that allows us to remove completely the locale parameter from
proximity info, which is a much needed change.

This change has zero effect on unit tests and on regression tests.

Bug: 11230254
Change-Id: If95157155db7dccd1f00b8ba55ccb3600283f9e4
2014-10-03 18:16:34 +09:00

63 lines
2.5 KiB
C++

/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
#define LOG_TAG "LatinIME: jni: ProximityInfo"
#include "com_android_inputmethod_keyboard_ProximityInfo.h"
#include "defines.h"
#include "jni.h"
#include "jni_common.h"
#include "suggest/core/layout/proximity_info.h"
namespace latinime {
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz,
jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight,
jint mostCommonkeyWidth, jint mostCommonkeyHeight, jintArray proximityChars, jint keyCount,
jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths,
jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs,
jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
ProximityInfo *proximityInfo = new ProximityInfo(env, displayWidth, displayHeight,
gridWidth, gridHeight, mostCommonkeyWidth, mostCommonkeyHeight, proximityChars,
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
return reinterpret_cast<jlong>(proximityInfo);
}
static void latinime_Keyboard_release(JNIEnv *env, jclass clazz, jlong proximityInfo) {
ProximityInfo *pi = reinterpret_cast<ProximityInfo *>(proximityInfo);
delete pi;
}
static const JNINativeMethod sMethods[] = {
{
const_cast<char *>("setProximityInfoNative"),
const_cast<char *>("(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)
}
};
int register_ProximityInfo(JNIEnv *env) {
const char *const kClassPathName = "com/android/inputmethod/keyboard/ProximityInfo";
return registerNativeMethods(env, kClassPathName, sMethods, NELEMS(sMethods));
}
} // namespace latinime