Merge "[ML13] Fix the locale passing in ProximityInfo"
commit
d415747a27
|
@ -108,10 +108,9 @@ public class Keyboard {
|
||||||
mAltCodeKeysWhileTyping = Collections.unmodifiableList(params.mAltCodeKeysWhileTyping);
|
mAltCodeKeysWhileTyping = Collections.unmodifiableList(params.mAltCodeKeysWhileTyping);
|
||||||
mIconsSet = params.mIconsSet;
|
mIconsSet = params.mIconsSet;
|
||||||
|
|
||||||
mProximityInfo = new ProximityInfo(params.mId.mLocale.toString(),
|
mProximityInfo = new ProximityInfo(params.GRID_WIDTH, params.GRID_HEIGHT,
|
||||||
params.GRID_WIDTH, params.GRID_HEIGHT, mOccupiedWidth, mOccupiedHeight,
|
mOccupiedWidth, mOccupiedHeight, mMostCommonKeyWidth, mMostCommonKeyHeight,
|
||||||
mMostCommonKeyWidth, mMostCommonKeyHeight, mSortedKeys,
|
mSortedKeys, params.mTouchPositionCorrection);
|
||||||
params.mTouchPositionCorrection);
|
|
||||||
mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled;
|
mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,18 +52,11 @@ public class ProximityInfo {
|
||||||
private final int mMostCommonKeyHeight;
|
private final int mMostCommonKeyHeight;
|
||||||
private final List<Key> mSortedKeys;
|
private final List<Key> mSortedKeys;
|
||||||
private final List<Key>[] mGridNeighbors;
|
private final List<Key>[] mGridNeighbors;
|
||||||
private final String mLocaleStr;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ProximityInfo(final String localeStr, final int gridWidth, final int gridHeight,
|
ProximityInfo(final int gridWidth, final int gridHeight, final int minWidth, final int height,
|
||||||
final int minWidth, final int height, final int mostCommonKeyWidth,
|
final int mostCommonKeyWidth, final int mostCommonKeyHeight, final List<Key> sortedKeys,
|
||||||
final int mostCommonKeyHeight, final List<Key> sortedKeys,
|
|
||||||
final TouchPositionCorrection touchPositionCorrection) {
|
final TouchPositionCorrection touchPositionCorrection) {
|
||||||
if (TextUtils.isEmpty(localeStr)) {
|
|
||||||
mLocaleStr = "";
|
|
||||||
} else {
|
|
||||||
mLocaleStr = localeStr;
|
|
||||||
}
|
|
||||||
mGridWidth = gridWidth;
|
mGridWidth = gridWidth;
|
||||||
mGridHeight = gridHeight;
|
mGridHeight = gridHeight;
|
||||||
mGridSize = mGridWidth * mGridHeight;
|
mGridSize = mGridWidth * mGridHeight;
|
||||||
|
@ -89,11 +82,10 @@ public class ProximityInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Stop passing proximityCharsArray
|
// TODO: Stop passing proximityCharsArray
|
||||||
private static native long setProximityInfoNative(String locale,
|
private static native long setProximityInfoNative(int displayWidth, int displayHeight,
|
||||||
int displayWidth, int displayHeight, int gridWidth, int gridHeight,
|
int gridWidth, int gridHeight, int mostCommonKeyWidth, int mostCommonKeyHeight,
|
||||||
int mostCommonKeyWidth, int mostCommonKeyHeight, int[] proximityCharsArray,
|
int[] proximityCharsArray, int keyCount, int[] keyXCoordinates, int[] keyYCoordinates,
|
||||||
int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, int[] keyWidths,
|
int[] keyWidths, int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterXs,
|
||||||
int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterXs,
|
|
||||||
float[] sweetSpotCenterYs, float[] sweetSpotRadii);
|
float[] sweetSpotCenterYs, float[] sweetSpotRadii);
|
||||||
|
|
||||||
private static native void releaseProximityInfoNative(long nativeProximityInfo);
|
private static native void releaseProximityInfoNative(long nativeProximityInfo);
|
||||||
|
@ -221,10 +213,10 @@ public class ProximityInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Stop passing proximityCharsArray
|
// TODO: Stop passing proximityCharsArray
|
||||||
return setProximityInfoNative(mLocaleStr, mKeyboardMinWidth, mKeyboardHeight,
|
return setProximityInfoNative(mKeyboardMinWidth, mKeyboardHeight, mGridWidth, mGridHeight,
|
||||||
mGridWidth, mGridHeight, mMostCommonKeyWidth, mMostCommonKeyHeight,
|
mMostCommonKeyWidth, mMostCommonKeyHeight, proximityCharsArray, keyCount,
|
||||||
proximityCharsArray, keyCount, keyXCoordinates, keyYCoordinates, keyWidths,
|
keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
||||||
keyHeights, keyCharCodes, sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getNativeProximityInfo() {
|
public long getNativeProximityInfo() {
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz, jstring localeJStr,
|
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz,
|
||||||
jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight,
|
jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight,
|
||||||
jint mostCommonkeyWidth, jint mostCommonkeyHeight, jintArray proximityChars, jint keyCount,
|
jint mostCommonkeyWidth, jint mostCommonkeyHeight, jintArray proximityChars, jint keyCount,
|
||||||
jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths,
|
jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths,
|
||||||
jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs,
|
jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs,
|
||||||
jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
|
jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
|
||||||
ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, displayWidth, displayHeight,
|
ProximityInfo *proximityInfo = new ProximityInfo(env, displayWidth, displayHeight,
|
||||||
gridWidth, gridHeight, mostCommonkeyWidth, mostCommonkeyHeight, proximityChars,
|
gridWidth, gridHeight, mostCommonkeyWidth, mostCommonkeyHeight, proximityChars,
|
||||||
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
||||||
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
||||||
|
@ -46,7 +46,7 @@ static void latinime_Keyboard_release(JNIEnv *env, jclass clazz, jlong proximity
|
||||||
static const JNINativeMethod sMethods[] = {
|
static const JNINativeMethod sMethods[] = {
|
||||||
{
|
{
|
||||||
const_cast<char *>("setProximityInfoNative"),
|
const_cast<char *>("setProximityInfoNative"),
|
||||||
const_cast<char *>("(Ljava/lang/String;IIIIII[II[I[I[I[I[I[F[F[F)J"),
|
const_cast<char *>("(IIIIII[II[I[I[I[I[I[F[F[F)J"),
|
||||||
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)
|
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
// TODO: Stop using hardcoded additional proximity characters.
|
// TODO: Stop using hardcoded additional proximity characters.
|
||||||
// TODO: Have proximity character informations in each language's binary dictionary.
|
// TODO: Have proximity character informations in each language's binary dictionary.
|
||||||
const char *AdditionalProximityChars::LOCALE_EN_US = "en";
|
const int AdditionalProximityChars::LOCALE_EN_US[LOCALE_EN_US_SIZE] = { 'e', 'n' };
|
||||||
|
|
||||||
const int AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
|
const int AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
|
||||||
'e', 'i', 'o', 'u'
|
'e', 'i', 'o', 'u'
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define LATINIME_ADDITIONAL_PROXIMITY_CHARS_H
|
#define LATINIME_ADDITIONAL_PROXIMITY_CHARS_H
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
|
@ -26,7 +27,8 @@ namespace latinime {
|
||||||
class AdditionalProximityChars {
|
class AdditionalProximityChars {
|
||||||
private:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(AdditionalProximityChars);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AdditionalProximityChars);
|
||||||
static const char *LOCALE_EN_US;
|
static const int LOCALE_EN_US_SIZE = 2;
|
||||||
|
static const int LOCALE_EN_US[LOCALE_EN_US_SIZE];
|
||||||
static const int EN_US_ADDITIONAL_A_SIZE = 4;
|
static const int EN_US_ADDITIONAL_A_SIZE = 4;
|
||||||
static const int EN_US_ADDITIONAL_A[];
|
static const int EN_US_ADDITIONAL_A[];
|
||||||
static const int EN_US_ADDITIONAL_E_SIZE = 4;
|
static const int EN_US_ADDITIONAL_E_SIZE = 4;
|
||||||
|
@ -38,15 +40,22 @@ class AdditionalProximityChars {
|
||||||
static const int EN_US_ADDITIONAL_U_SIZE = 4;
|
static const int EN_US_ADDITIONAL_U_SIZE = 4;
|
||||||
static const int EN_US_ADDITIONAL_U[];
|
static const int EN_US_ADDITIONAL_U[];
|
||||||
|
|
||||||
AK_FORCE_INLINE static bool isEnLocale(const char *localeStr) {
|
AK_FORCE_INLINE static bool isEnLocale(const std::vector<int> *locale) {
|
||||||
const size_t LOCALE_EN_US_SIZE = strlen(LOCALE_EN_US);
|
const int NCHARS = NELEMS(LOCALE_EN_US);
|
||||||
return localeStr && strlen(localeStr) >= LOCALE_EN_US_SIZE
|
if (locale->size() < NCHARS) {
|
||||||
&& strncmp(localeStr, LOCALE_EN_US, LOCALE_EN_US_SIZE) == 0;
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < NCHARS; ++i) {
|
||||||
|
if ((*locale)[i] != LOCALE_EN_US[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int getAdditionalCharsSize(const char *const localeStr, const int c) {
|
static int getAdditionalCharsSize(const std::vector<int> *locale, const int c) {
|
||||||
if (!isEnLocale(localeStr)) {
|
if (!isEnLocale(locale)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -65,8 +74,8 @@ class AdditionalProximityChars {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int *getAdditionalChars(const char *const localeStr, const int c) {
|
static const int *getAdditionalChars(const std::vector<int> *locale, const int c) {
|
||||||
if (!isEnLocale(localeStr)) {
|
if (!isEnLocale(locale)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
|
|
@ -49,13 +49,13 @@ static AK_FORCE_INLINE void safeGetOrFillZeroFloatArrayRegion(JNIEnv *env, jfloa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr,
|
ProximityInfo::ProximityInfo(JNIEnv *env, const int keyboardWidth, const int keyboardHeight,
|
||||||
const int keyboardWidth, const int keyboardHeight, const int gridWidth,
|
const int gridWidth, const int gridHeight, const int mostCommonKeyWidth,
|
||||||
const int gridHeight, const int mostCommonKeyWidth, const int mostCommonKeyHeight,
|
const int mostCommonKeyHeight, const jintArray proximityChars, const int keyCount,
|
||||||
const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates,
|
const jintArray keyXCoordinates, const jintArray keyYCoordinates,
|
||||||
const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights,
|
const jintArray keyWidths, const jintArray keyHeights, const jintArray keyCharCodes,
|
||||||
const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs,
|
const jfloatArray sweetSpotCenterXs, const jfloatArray sweetSpotCenterYs,
|
||||||
const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii)
|
const jfloatArray sweetSpotRadii)
|
||||||
: GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth),
|
: GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth),
|
||||||
MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth),
|
MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth),
|
||||||
NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE(1.0f +
|
NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE(1.0f +
|
||||||
|
@ -82,13 +82,6 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr,
|
||||||
if (DEBUG_PROXIMITY_INFO) {
|
if (DEBUG_PROXIMITY_INFO) {
|
||||||
AKLOGI("Create proximity info array %d", proximityCharsLength);
|
AKLOGI("Create proximity info array %d", proximityCharsLength);
|
||||||
}
|
}
|
||||||
const jsize localeCStrUtf8Length = env->GetStringUTFLength(localeJStr);
|
|
||||||
if (localeCStrUtf8Length >= MAX_LOCALE_STRING_LENGTH) {
|
|
||||||
AKLOGI("Locale string length too long: length=%d", localeCStrUtf8Length);
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
memset(mLocaleStr, 0, sizeof(mLocaleStr));
|
|
||||||
env->GetStringUTFRegion(localeJStr, 0, env->GetStringLength(localeJStr), mLocaleStr);
|
|
||||||
safeGetOrFillZeroIntArrayRegion(env, proximityChars, proximityCharsLength,
|
safeGetOrFillZeroIntArrayRegion(env, proximityChars, proximityCharsLength,
|
||||||
mProximityCharsArray);
|
mProximityCharsArray);
|
||||||
safeGetOrFillZeroIntArrayRegion(env, keyXCoordinates, KEY_COUNT, mKeyXCoordinates);
|
safeGetOrFillZeroIntArrayRegion(env, keyXCoordinates, KEY_COUNT, mKeyXCoordinates);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define LATINIME_PROXIMITY_INFO_H
|
#define LATINIME_PROXIMITY_INFO_H
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
@ -27,9 +28,9 @@ namespace latinime {
|
||||||
|
|
||||||
class ProximityInfo {
|
class ProximityInfo {
|
||||||
public:
|
public:
|
||||||
ProximityInfo(JNIEnv *env, const jstring localeJStr,
|
ProximityInfo(JNIEnv *env, const int keyboardWidth, const int keyboardHeight,
|
||||||
const int keyboardWidth, const int keyboardHeight, const int gridWidth,
|
const int gridWidth, const int gridHeight,
|
||||||
const int gridHeight, const int mostCommonKeyWidth, const int mostCommonKeyHeight,
|
const int mostCommonKeyWidth, const int mostCommonKeyHeight,
|
||||||
const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates,
|
const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates,
|
||||||
const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights,
|
const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights,
|
||||||
const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs,
|
const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs,
|
||||||
|
@ -71,11 +72,11 @@ class ProximityInfo {
|
||||||
|
|
||||||
AK_FORCE_INLINE void initializeProximities(const int *const inputCodes,
|
AK_FORCE_INLINE void initializeProximities(const int *const inputCodes,
|
||||||
const int *const inputXCoordinates, const int *const inputYCoordinates,
|
const int *const inputXCoordinates, const int *const inputYCoordinates,
|
||||||
const int inputSize, int *allInputCodes) const {
|
const int inputSize, int *allInputCodes, const std::vector<int> *locale) const {
|
||||||
ProximityInfoUtils::initializeProximities(inputCodes, inputXCoordinates, inputYCoordinates,
|
ProximityInfoUtils::initializeProximities(inputCodes, inputXCoordinates, inputYCoordinates,
|
||||||
inputSize, mKeyXCoordinates, mKeyYCoordinates, mKeyWidths, mKeyHeights,
|
inputSize, mKeyXCoordinates, mKeyYCoordinates, mKeyWidths, mKeyHeights,
|
||||||
mProximityCharsArray, CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH, MOST_COMMON_KEY_WIDTH,
|
mProximityCharsArray, CELL_HEIGHT, CELL_WIDTH, GRID_WIDTH, MOST_COMMON_KEY_WIDTH,
|
||||||
KEY_COUNT, mLocaleStr, &mLowerCodePointToKeyMap, allInputCodes);
|
KEY_COUNT, locale, &mLowerCodePointToKeyMap, allInputCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
AK_FORCE_INLINE int getKeyIndexOf(const int c) const {
|
AK_FORCE_INLINE int getKeyIndexOf(const int c) const {
|
||||||
|
@ -103,9 +104,6 @@ class ProximityInfo {
|
||||||
const int KEYBOARD_HEIGHT;
|
const int KEYBOARD_HEIGHT;
|
||||||
const float KEYBOARD_HYPOTENUSE;
|
const float KEYBOARD_HYPOTENUSE;
|
||||||
const bool HAS_TOUCH_POSITION_CORRECTION_DATA;
|
const bool HAS_TOUCH_POSITION_CORRECTION_DATA;
|
||||||
// Assuming locale strings such as en_US, sr-Latn etc.
|
|
||||||
static const int MAX_LOCALE_STRING_LENGTH = 10;
|
|
||||||
char mLocaleStr[MAX_LOCALE_STRING_LENGTH];
|
|
||||||
int *mProximityCharsArray;
|
int *mProximityCharsArray;
|
||||||
int mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
int mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
|
|
|
@ -42,7 +42,7 @@ int ProximityInfoState::getPrimaryOriginalCodePointAt(const int index) const {
|
||||||
void ProximityInfoState::initInputParams(const int pointerId, const float maxPointToKeyLength,
|
void ProximityInfoState::initInputParams(const int pointerId, const float maxPointToKeyLength,
|
||||||
const ProximityInfo *proximityInfo, const int *const inputCodes, const int inputSize,
|
const ProximityInfo *proximityInfo, const int *const inputCodes, const int inputSize,
|
||||||
const int *const xCoordinates, const int *const yCoordinates, const int *const times,
|
const int *const xCoordinates, const int *const yCoordinates, const int *const times,
|
||||||
const int *const pointerIds, const bool isGeometric) {
|
const int *const pointerIds, const bool isGeometric, const std::vector<int> *locale) {
|
||||||
ASSERT(isGeometric || (inputSize < MAX_WORD_LENGTH));
|
ASSERT(isGeometric || (inputSize < MAX_WORD_LENGTH));
|
||||||
mIsContinuousSuggestionPossible = (mHasBeenUpdatedByGeometricInput != isGeometric) ?
|
mIsContinuousSuggestionPossible = (mHasBeenUpdatedByGeometricInput != isGeometric) ?
|
||||||
false : ProximityInfoStateUtils::checkAndReturnIsContinuousSuggestionPossible(
|
false : ProximityInfoStateUtils::checkAndReturnIsContinuousSuggestionPossible(
|
||||||
|
@ -66,7 +66,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
|
|
||||||
if (!isGeometric && pointerId == 0) {
|
if (!isGeometric && pointerId == 0) {
|
||||||
mProximityInfo->initializeProximities(inputCodes, xCoordinates, yCoordinates,
|
mProximityInfo->initializeProximities(inputCodes, xCoordinates, yCoordinates,
|
||||||
inputSize, mInputProximities);
|
inputSize, mInputProximities, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
|
@ -37,7 +37,8 @@ class ProximityInfoState {
|
||||||
void initInputParams(const int pointerId, const float maxPointToKeyLength,
|
void initInputParams(const int pointerId, const float maxPointToKeyLength,
|
||||||
const ProximityInfo *proximityInfo, const int *const inputCodes,
|
const ProximityInfo *proximityInfo, const int *const inputCodes,
|
||||||
const int inputSize, const int *xCoordinates, const int *yCoordinates,
|
const int inputSize, const int *xCoordinates, const int *yCoordinates,
|
||||||
const int *const times, const int *const pointerIds, const bool isGeometric);
|
const int *const times, const int *const pointerIds, const bool isGeometric,
|
||||||
|
const std::vector<int> *locale);
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// Defined here //
|
// Defined here //
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/core/layout/additional_proximity_chars.h"
|
#include "suggest/core/layout/additional_proximity_chars.h"
|
||||||
|
@ -51,7 +52,7 @@ class ProximityInfoUtils {
|
||||||
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
|
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
|
||||||
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
||||||
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
||||||
const char *const localeStr,
|
const std::vector<int> *locale,
|
||||||
const std::unordered_map<int, int> *const codeToKeyMap, int *inputProximities) {
|
const std::unordered_map<int, int> *const codeToKeyMap, int *inputProximities) {
|
||||||
// Initialize
|
// Initialize
|
||||||
// - mInputCodes
|
// - mInputCodes
|
||||||
|
@ -64,7 +65,7 @@ class ProximityInfoUtils {
|
||||||
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE];
|
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE];
|
||||||
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
|
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
|
||||||
proximityCharsArray, cellHeight, cellWidth, gridWidth, mostCommonKeyWidth,
|
proximityCharsArray, cellHeight, cellWidth, gridWidth, mostCommonKeyWidth,
|
||||||
keyCount, x, y, primaryKey, localeStr, codeToKeyMap, proximities);
|
keyCount, x, y, primaryKey, locale, codeToKeyMap, proximities);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG_PROXIMITY_CHARS) {
|
if (DEBUG_PROXIMITY_CHARS) {
|
||||||
|
@ -143,7 +144,7 @@ class ProximityInfoUtils {
|
||||||
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
|
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
|
||||||
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
|
||||||
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
const int gridWidth, const int mostCommonKeyWidth, const int keyCount,
|
||||||
const int x, const int y, const int primaryKey, const char *const localeStr,
|
const int x, const int y, const int primaryKey, const std::vector<int> *locale,
|
||||||
const std::unordered_map<int, int> *const codeToKeyMap, int *proximities) {
|
const std::unordered_map<int, int> *const codeToKeyMap, int *proximities) {
|
||||||
const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
|
const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
|
||||||
int insertPos = 0;
|
int insertPos = 0;
|
||||||
|
@ -177,7 +178,7 @@ class ProximityInfoUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int additionalProximitySize =
|
const int additionalProximitySize =
|
||||||
AdditionalProximityChars::getAdditionalCharsSize(localeStr, primaryKey);
|
AdditionalProximityChars::getAdditionalCharsSize(locale, primaryKey);
|
||||||
if (additionalProximitySize > 0) {
|
if (additionalProximitySize > 0) {
|
||||||
proximities[insertPos++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
|
proximities[insertPos++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
|
||||||
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
|
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
|
||||||
|
@ -188,7 +189,7 @@ class ProximityInfoUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
const int *additionalProximityChars =
|
const int *additionalProximityChars =
|
||||||
AdditionalProximityChars::getAdditionalChars(localeStr, primaryKey);
|
AdditionalProximityChars::getAdditionalChars(locale, primaryKey);
|
||||||
for (int j = 0; j < additionalProximitySize; ++j) {
|
for (int j = 0; j < additionalProximitySize; ++j) {
|
||||||
const int ac = additionalProximityChars[j];
|
const int ac = additionalProximityChars[j];
|
||||||
int k = 0;
|
int k = 0;
|
||||||
|
|
|
@ -69,8 +69,12 @@ void DicTraverseSession::initializeProximityInfoStates(const int *const inputCod
|
||||||
for (int i = 0; i < maxPointerCount; ++i) {
|
for (int i = 0; i < maxPointerCount; ++i) {
|
||||||
mProximityInfoStates[i].initInputParams(i, maxSpatialDistance, getProximityInfo(),
|
mProximityInfoStates[i].initInputParams(i, maxSpatialDistance, getProximityInfo(),
|
||||||
inputCodePoints, inputSize, inputXs, inputYs, times, pointerIds,
|
inputCodePoints, inputSize, inputXs, inputYs, times, pointerIds,
|
||||||
maxPointerCount == MAX_POINTER_COUNT_G
|
// Right now the line below is trying to figure out whether this is a gesture by
|
||||||
/* TODO: this is a hack. fix proximity info state */);
|
// looking at the pointer count and assuming whatever is above the cutoff is
|
||||||
|
// a gesture and whatever is below is type. This is hacky and incorrect, we
|
||||||
|
// should pass the correct information instead.
|
||||||
|
maxPointerCount == MAX_POINTER_COUNT_G,
|
||||||
|
getDictionaryStructurePolicy()->getHeaderStructurePolicy()->getLocale());
|
||||||
mInputSize += mProximityInfoStates[i].size();
|
mInputSize += mProximityInfoStates[i].size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue