aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java28
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java28
-rw-r--r--native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp6
-rw-r--r--native/jni/src/suggest/core/layout/additional_proximity_chars.cpp2
-rw-r--r--native/jni/src/suggest/core/layout/additional_proximity_chars.h27
-rw-r--r--native/jni/src/suggest/core/layout/proximity_info.cpp21
-rw-r--r--native/jni/src/suggest/core/layout/proximity_info.h14
-rw-r--r--native/jni/src/suggest/core/layout/proximity_info_state.cpp4
-rw-r--r--native/jni/src/suggest/core/layout/proximity_info_state.h3
-rw-r--r--native/jni/src/suggest/core/layout/proximity_info_utils.h11
-rw-r--r--native/jni/src/suggest/core/session/dic_traverse_session.cpp8
13 files changed, 91 insertions, 73 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 85dfea4e7..d35c8fae1 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -108,10 +108,9 @@ public class Keyboard {
mAltCodeKeysWhileTyping = Collections.unmodifiableList(params.mAltCodeKeysWhileTyping);
mIconsSet = params.mIconsSet;
- mProximityInfo = new ProximityInfo(params.mId.mLocale.toString(),
- params.GRID_WIDTH, params.GRID_HEIGHT, mOccupiedWidth, mOccupiedHeight,
- mMostCommonKeyWidth, mMostCommonKeyHeight, mSortedKeys,
- params.mTouchPositionCorrection);
+ mProximityInfo = new ProximityInfo(params.GRID_WIDTH, params.GRID_HEIGHT,
+ mOccupiedWidth, mOccupiedHeight, mMostCommonKeyWidth, mMostCommonKeyHeight,
+ mSortedKeys, params.mTouchPositionCorrection);
mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled;
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 246d11bac..7f2957fff 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -254,8 +254,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
}
public void onToggleEmojiKeyboard() {
- if (mKeyboardLayoutSet == null || !isShowingEmojiPalettes()) {
- mLatinIME.startShowingInputView();
+ final boolean needsToLoadKeyboard = (mKeyboardLayoutSet == null);
+ if (needsToLoadKeyboard || !isShowingEmojiPalettes()) {
+ mLatinIME.startShowingInputView(needsToLoadKeyboard);
setEmojiKeyboard();
} else {
mLatinIME.stopShowingInputView();
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index c19cd671a..9c5abcd71 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -52,18 +52,11 @@ public class ProximityInfo {
private final int mMostCommonKeyHeight;
private final List<Key> mSortedKeys;
private final List<Key>[] mGridNeighbors;
- private final String mLocaleStr;
@SuppressWarnings("unchecked")
- ProximityInfo(final String localeStr, final int gridWidth, final int gridHeight,
- final int minWidth, final int height, final int mostCommonKeyWidth,
- final int mostCommonKeyHeight, final List<Key> sortedKeys,
+ ProximityInfo(final int gridWidth, final int gridHeight, final int minWidth, final int height,
+ final int mostCommonKeyWidth, final int mostCommonKeyHeight, final List<Key> sortedKeys,
final TouchPositionCorrection touchPositionCorrection) {
- if (TextUtils.isEmpty(localeStr)) {
- mLocaleStr = "";
- } else {
- mLocaleStr = localeStr;
- }
mGridWidth = gridWidth;
mGridHeight = gridHeight;
mGridSize = mGridWidth * mGridHeight;
@@ -89,11 +82,10 @@ public class ProximityInfo {
}
// TODO: Stop passing proximityCharsArray
- private static native long setProximityInfoNative(String locale,
- int displayWidth, int displayHeight, int gridWidth, int gridHeight,
- int mostCommonKeyWidth, int mostCommonKeyHeight, int[] proximityCharsArray,
- int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, int[] keyWidths,
- int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterXs,
+ private static native long setProximityInfoNative(int displayWidth, int displayHeight,
+ int gridWidth, int gridHeight, int mostCommonKeyWidth, int mostCommonKeyHeight,
+ int[] proximityCharsArray, int keyCount, int[] keyXCoordinates, int[] keyYCoordinates,
+ int[] keyWidths, int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterXs,
float[] sweetSpotCenterYs, float[] sweetSpotRadii);
private static native void releaseProximityInfoNative(long nativeProximityInfo);
@@ -221,10 +213,10 @@ public class ProximityInfo {
}
// TODO: Stop passing proximityCharsArray
- return setProximityInfoNative(mLocaleStr, mKeyboardMinWidth, mKeyboardHeight,
- mGridWidth, mGridHeight, mMostCommonKeyWidth, mMostCommonKeyHeight,
- proximityCharsArray, keyCount, keyXCoordinates, keyYCoordinates, keyWidths,
- keyHeights, keyCharCodes, sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
+ return setProximityInfoNative(mKeyboardMinWidth, mKeyboardHeight, mGridWidth, mGridHeight,
+ mMostCommonKeyWidth, mMostCommonKeyHeight, proximityCharsArray, keyCount,
+ keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
+ sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
}
public long getNativeProximityInfo() {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 861a8903e..be2efb2dc 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -733,6 +733,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void setInputView(final View view) {
super.setInputView(view);
mInputView = view;
+ updateSoftInputWindowLayoutParameters();
mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view);
if (hasSuggestionStripView()) {
mSuggestionStripView.setListener(this, view);
@@ -1147,6 +1148,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets);
+ // This method may be called before {@link #setInputView(View)}.
+ if (mInputView == null) {
+ return;
+ }
final SettingsValues settingsValues = mSettings.getCurrent();
final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
if (visibleKeyboardView == null || !hasSuggestionStripView()) {
@@ -1181,12 +1186,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
outInsets.visibleTopInsets = visibleTopY;
}
- public void startShowingInputView() {
+ public void startShowingInputView(final boolean needsToLoadKeyboard) {
mIsExecutingStartShowingInputView = true;
// This {@link #showWindow(boolean)} will eventually call back
// {@link #onEvaluateInputViewShown()}.
showWindow(true /* showInput */);
mIsExecutingStartShowingInputView = false;
+ if (needsToLoadKeyboard) {
+ loadKeyboard();
+ }
}
public void stopShowingInputView() {
@@ -1194,6 +1202,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
@Override
+ public boolean onShowInputRequested(final int flags, final boolean configChange) {
+ if (Settings.getInstance().getCurrent().mHasHardwareKeyboard) {
+ return true;
+ }
+ return super.onShowInputRequested(flags, configChange);
+ }
+
+ @Override
public boolean onEvaluateInputViewShown() {
if (mIsExecutingStartShowingInputView) {
return true;
@@ -1223,8 +1239,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void updateFullscreenMode() {
+ super.updateFullscreenMode();
+ mInputLogic.onUpdateFullscreenMode(isFullscreenMode());
+ updateSoftInputWindowLayoutParameters();
+ }
+
+ private void updateSoftInputWindowLayoutParameters() {
// Override layout parameters to expand {@link SoftInputWindow} to the entire screen.
- // See {@link InputMethodService#setinputView(View) and
+ // See {@link InputMethodService#setinputView(View)} and
// {@link SoftInputWindow#updateWidthHeight(WindowManager.LayoutParams)}.
final Window window = getWindow().getWindow();
ViewLayoutUtils.updateLayoutHeightOf(window, LayoutParams.MATCH_PARENT);
@@ -1243,8 +1265,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
ViewLayoutUtils.updateLayoutGravityOf(inputArea, Gravity.BOTTOM);
ViewLayoutUtils.updateLayoutHeightOf(mInputView, layoutHeight);
}
- super.updateFullscreenMode();
- mInputLogic.onUpdateFullscreenMode(isFullscreenMode());
}
private int getCurrentAutoCapsState() {
diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
index f88d37ec9..80419b335 100644
--- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
+++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
@@ -25,13 +25,13 @@
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 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, localeJStr, displayWidth, displayHeight,
+ ProximityInfo *proximityInfo = new ProximityInfo(env, displayWidth, displayHeight,
gridWidth, gridHeight, mostCommonkeyWidth, mostCommonkeyHeight, proximityChars,
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
@@ -46,7 +46,7 @@ static void latinime_Keyboard_release(JNIEnv *env, jclass clazz, jlong proximity
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"),
+ const_cast<char *>("(IIIIII[II[I[I[I[I[I[F[F[F)J"),
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)
},
{
diff --git a/native/jni/src/suggest/core/layout/additional_proximity_chars.cpp b/native/jni/src/suggest/core/layout/additional_proximity_chars.cpp
index 34b8b37b0..8b39f7da5 100644
--- a/native/jni/src/suggest/core/layout/additional_proximity_chars.cpp
+++ b/native/jni/src/suggest/core/layout/additional_proximity_chars.cpp
@@ -19,7 +19,7 @@
namespace latinime {
// TODO: Stop using hardcoded additional proximity characters.
// 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] = {
'e', 'i', 'o', 'u'
diff --git a/native/jni/src/suggest/core/layout/additional_proximity_chars.h b/native/jni/src/suggest/core/layout/additional_proximity_chars.h
index a88fd6cea..2260be9bd 100644
--- a/native/jni/src/suggest/core/layout/additional_proximity_chars.h
+++ b/native/jni/src/suggest/core/layout/additional_proximity_chars.h
@@ -18,6 +18,7 @@
#define LATINIME_ADDITIONAL_PROXIMITY_CHARS_H
#include <cstring>
+#include <vector>
#include "defines.h"
@@ -26,7 +27,8 @@ namespace latinime {
class AdditionalProximityChars {
private:
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[];
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[];
- AK_FORCE_INLINE static bool isEnLocale(const char *localeStr) {
- const size_t LOCALE_EN_US_SIZE = strlen(LOCALE_EN_US);
- return localeStr && strlen(localeStr) >= LOCALE_EN_US_SIZE
- && strncmp(localeStr, LOCALE_EN_US, LOCALE_EN_US_SIZE) == 0;
+ AK_FORCE_INLINE static bool isEnLocale(const std::vector<int> *locale) {
+ const int NCHARS = NELEMS(LOCALE_EN_US);
+ if (locale->size() < NCHARS) {
+ return false;
+ }
+ for (int i = 0; i < NCHARS; ++i) {
+ if ((*locale)[i] != LOCALE_EN_US[i]) {
+ return false;
+ }
+ }
+ return true;
}
public:
- static int getAdditionalCharsSize(const char *const localeStr, const int c) {
- if (!isEnLocale(localeStr)) {
+ static int getAdditionalCharsSize(const std::vector<int> *locale, const int c) {
+ if (!isEnLocale(locale)) {
return 0;
}
switch (c) {
@@ -65,8 +74,8 @@ class AdditionalProximityChars {
}
}
- static const int *getAdditionalChars(const char *const localeStr, const int c) {
- if (!isEnLocale(localeStr)) {
+ static const int *getAdditionalChars(const std::vector<int> *locale, const int c) {
+ if (!isEnLocale(locale)) {
return 0;
}
switch (c) {
diff --git a/native/jni/src/suggest/core/layout/proximity_info.cpp b/native/jni/src/suggest/core/layout/proximity_info.cpp
index 4c75a188e..933a5e145 100644
--- a/native/jni/src/suggest/core/layout/proximity_info.cpp
+++ b/native/jni/src/suggest/core/layout/proximity_info.cpp
@@ -49,13 +49,13 @@ static AK_FORCE_INLINE void safeGetOrFillZeroFloatArrayRegion(JNIEnv *env, jfloa
}
}
-ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr,
- const int keyboardWidth, const int keyboardHeight, const int gridWidth,
- const int gridHeight, const int mostCommonKeyWidth, const int mostCommonKeyHeight,
- const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates,
- const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights,
- const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs,
- const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii)
+ProximityInfo::ProximityInfo(JNIEnv *env, const int keyboardWidth, const int keyboardHeight,
+ const int gridWidth, const int gridHeight, const int mostCommonKeyWidth,
+ const int mostCommonKeyHeight, const jintArray proximityChars, const int keyCount,
+ const jintArray keyXCoordinates, const jintArray keyYCoordinates,
+ const jintArray keyWidths, const jintArray keyHeights, const jintArray keyCharCodes,
+ const jfloatArray sweetSpotCenterXs, const jfloatArray sweetSpotCenterYs,
+ const jfloatArray sweetSpotRadii)
: GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth),
MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth),
NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE(1.0f +
@@ -82,13 +82,6 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr,
if (DEBUG_PROXIMITY_INFO) {
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,
mProximityCharsArray);
safeGetOrFillZeroIntArrayRegion(env, keyXCoordinates, KEY_COUNT, mKeyXCoordinates);
diff --git a/native/jni/src/suggest/core/layout/proximity_info.h b/native/jni/src/suggest/core/layout/proximity_info.h
index d4e453736..f7c907697 100644
--- a/native/jni/src/suggest/core/layout/proximity_info.h
+++ b/native/jni/src/suggest/core/layout/proximity_info.h
@@ -18,6 +18,7 @@
#define LATINIME_PROXIMITY_INFO_H
#include <unordered_map>
+#include <vector>
#include "defines.h"
#include "jni.h"
@@ -27,9 +28,9 @@ namespace latinime {
class ProximityInfo {
public:
- ProximityInfo(JNIEnv *env, const jstring localeJStr,
- const int keyboardWidth, const int keyboardHeight, const int gridWidth,
- const int gridHeight, const int mostCommonKeyWidth, const int mostCommonKeyHeight,
+ ProximityInfo(JNIEnv *env, const int keyboardWidth, const int keyboardHeight,
+ const int gridWidth, const int gridHeight,
+ const int mostCommonKeyWidth, const int mostCommonKeyHeight,
const jintArray proximityChars, const int keyCount, const jintArray keyXCoordinates,
const jintArray keyYCoordinates, const jintArray keyWidths, const jintArray keyHeights,
const jintArray keyCharCodes, const jfloatArray sweetSpotCenterXs,
@@ -71,11 +72,11 @@ class ProximityInfo {
AK_FORCE_INLINE void initializeProximities(const int *const inputCodes,
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,
inputSize, mKeyXCoordinates, mKeyYCoordinates, mKeyWidths, mKeyHeights,
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 {
@@ -103,9 +104,6 @@ class ProximityInfo {
const int KEYBOARD_HEIGHT;
const float KEYBOARD_HYPOTENUSE;
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 mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
int mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.cpp b/native/jni/src/suggest/core/layout/proximity_info_state.cpp
index 91469e26d..d43a0026a 100644
--- a/native/jni/src/suggest/core/layout/proximity_info_state.cpp
+++ b/native/jni/src/suggest/core/layout/proximity_info_state.cpp
@@ -42,7 +42,7 @@ int ProximityInfoState::getPrimaryOriginalCodePointAt(const int index) const {
void ProximityInfoState::initInputParams(const int pointerId, const float maxPointToKeyLength,
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 pointerIds, const bool isGeometric) {
+ const int *const pointerIds, const bool isGeometric, const std::vector<int> *locale) {
ASSERT(isGeometric || (inputSize < MAX_WORD_LENGTH));
mIsContinuousSuggestionPossible = (mHasBeenUpdatedByGeometricInput != isGeometric) ?
false : ProximityInfoStateUtils::checkAndReturnIsContinuousSuggestionPossible(
@@ -66,7 +66,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
if (!isGeometric && pointerId == 0) {
mProximityInfo->initializeProximities(inputCodes, xCoordinates, yCoordinates,
- inputSize, mInputProximities);
+ inputSize, mInputProximities, locale);
}
///////////////////////
diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.h b/native/jni/src/suggest/core/layout/proximity_info_state.h
index e6180fe17..a2d663544 100644
--- a/native/jni/src/suggest/core/layout/proximity_info_state.h
+++ b/native/jni/src/suggest/core/layout/proximity_info_state.h
@@ -37,7 +37,8 @@ class ProximityInfoState {
void initInputParams(const int pointerId, const float maxPointToKeyLength,
const ProximityInfo *proximityInfo, const int *const inputCodes,
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 //
diff --git a/native/jni/src/suggest/core/layout/proximity_info_utils.h b/native/jni/src/suggest/core/layout/proximity_info_utils.h
index 178aada2d..79d0615b8 100644
--- a/native/jni/src/suggest/core/layout/proximity_info_utils.h
+++ b/native/jni/src/suggest/core/layout/proximity_info_utils.h
@@ -19,6 +19,7 @@
#include <cmath>
#include <unordered_map>
+#include <vector>
#include "defines.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 proximityCharsArray, const int cellHeight, const int cellWidth,
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) {
// Initialize
// - mInputCodes
@@ -64,7 +65,7 @@ class ProximityInfoUtils {
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE];
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
proximityCharsArray, cellHeight, cellWidth, gridWidth, mostCommonKeyWidth,
- keyCount, x, y, primaryKey, localeStr, codeToKeyMap, proximities);
+ keyCount, x, y, primaryKey, locale, codeToKeyMap, proximities);
}
if (DEBUG_PROXIMITY_CHARS) {
@@ -143,7 +144,7 @@ class ProximityInfoUtils {
const int *const keyYCoordinates, const int *const keyWidths, const int *keyHeights,
const int *const proximityCharsArray, const int cellHeight, const int cellWidth,
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 int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth;
int insertPos = 0;
@@ -177,7 +178,7 @@ class ProximityInfoUtils {
}
}
const int additionalProximitySize =
- AdditionalProximityChars::getAdditionalCharsSize(localeStr, primaryKey);
+ AdditionalProximityChars::getAdditionalCharsSize(locale, primaryKey);
if (additionalProximitySize > 0) {
proximities[insertPos++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
if (insertPos >= MAX_PROXIMITY_CHARS_SIZE) {
@@ -188,7 +189,7 @@ class ProximityInfoUtils {
}
const int *additionalProximityChars =
- AdditionalProximityChars::getAdditionalChars(localeStr, primaryKey);
+ AdditionalProximityChars::getAdditionalChars(locale, primaryKey);
for (int j = 0; j < additionalProximitySize; ++j) {
const int ac = additionalProximityChars[j];
int k = 0;
diff --git a/native/jni/src/suggest/core/session/dic_traverse_session.cpp b/native/jni/src/suggest/core/session/dic_traverse_session.cpp
index 4d7505a55..b4d01d0f0 100644
--- a/native/jni/src/suggest/core/session/dic_traverse_session.cpp
+++ b/native/jni/src/suggest/core/session/dic_traverse_session.cpp
@@ -69,8 +69,12 @@ void DicTraverseSession::initializeProximityInfoStates(const int *const inputCod
for (int i = 0; i < maxPointerCount; ++i) {
mProximityInfoStates[i].initInputParams(i, maxSpatialDistance, getProximityInfo(),
inputCodePoints, inputSize, inputXs, inputYs, times, pointerIds,
- maxPointerCount == MAX_POINTER_COUNT_G
- /* TODO: this is a hack. fix proximity info state */);
+ // Right now the line below is trying to figure out whether this is a gesture by
+ // 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();
}
}