Loading java/src/com/android/inputmethod/keyboard/ProximityInfo.java +25 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,31 @@ public class ProximityInfo { touchPositionCorrection); } public void fillArrayWithNearestKeyCodes(int x, int y, int primaryKeyCode, int[] dest) { final int destLength = dest.length; if (destLength < 1) { return; } int index = 0; if (primaryKeyCode > Keyboard.CODE_SPACE) { dest[index++] = primaryKeyCode; } final Key[] nearestKeys = getNearestKeys(x, y); for (Key key : nearestKeys) { if (index >= destLength) { break; } final int code = key.mCode; if (code <= Keyboard.CODE_SPACE) { break; } dest[index++] = code; } if (index < destLength) { dest[index] = KeyDetector.NOT_A_CODE; } } public Key[] getNearestKeys(int x, int y) { if (mGridNeighbors == null) { return EMPTY_KEY_ARRAY; Loading java/src/com/android/inputmethod/latin/ExpandableDictionary.java +10 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.latin; import android.content.Context; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.ProximityInfo; Loading Loading @@ -209,13 +210,19 @@ public class ExpandableDictionary extends Dictionary { @SuppressWarnings("unused") final ProximityInfo proximityInfo) { mInputLength = codes.size(); if (mCodes.length < mInputLength) mCodes = new int[mInputLength][]; final int[] xCoordinates = codes.getXCoordinates(); final int[] yCoordinates = codes.getYCoordinates(); // Cache the codes so that we don't have to lookup an array list for (int i = 0; i < mInputLength; i++) { // TODO: Calculate proximity info here. if (mCodes[i] == null || mCodes[i].length < 1) { mCodes[i] = new int[1]; mCodes[i] = new int[ProximityInfo.MAX_PROXIMITY_CHARS_SIZE]; } mCodes[i][0] = codes.getCodeAt(i); final int x = xCoordinates != null && i < xCoordinates.length ? xCoordinates[i] : WordComposer.NOT_A_COORDINATE; final int y = xCoordinates != null && i < yCoordinates.length ? yCoordinates[i] : WordComposer.NOT_A_COORDINATE; proximityInfo.fillArrayWithNearestKeyCodes(x, y, codes.getCodeAt(i), mCodes[i]); } mMaxDepth = mInputLength * 3; getWordsRec(mRoots, codes, mWordBuilder, 0, false, 1, 0, -1, callback); Loading Loading @@ -328,7 +335,7 @@ public class ExpandableDictionary extends Dictionary { for (int j = 0; j < alternativesSize; j++) { final int addedAttenuation = (j > 0 ? 1 : 2); final int currentChar = currentChars[j]; if (currentChar == -1) { if (currentChar == KeyDetector.NOT_A_CODE) { break; } if (currentChar == lowerC || currentChar == c) { Loading Loading
java/src/com/android/inputmethod/keyboard/ProximityInfo.java +25 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,31 @@ public class ProximityInfo { touchPositionCorrection); } public void fillArrayWithNearestKeyCodes(int x, int y, int primaryKeyCode, int[] dest) { final int destLength = dest.length; if (destLength < 1) { return; } int index = 0; if (primaryKeyCode > Keyboard.CODE_SPACE) { dest[index++] = primaryKeyCode; } final Key[] nearestKeys = getNearestKeys(x, y); for (Key key : nearestKeys) { if (index >= destLength) { break; } final int code = key.mCode; if (code <= Keyboard.CODE_SPACE) { break; } dest[index++] = code; } if (index < destLength) { dest[index] = KeyDetector.NOT_A_CODE; } } public Key[] getNearestKeys(int x, int y) { if (mGridNeighbors == null) { return EMPTY_KEY_ARRAY; Loading
java/src/com/android/inputmethod/latin/ExpandableDictionary.java +10 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.latin; import android.content.Context; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.ProximityInfo; Loading Loading @@ -209,13 +210,19 @@ public class ExpandableDictionary extends Dictionary { @SuppressWarnings("unused") final ProximityInfo proximityInfo) { mInputLength = codes.size(); if (mCodes.length < mInputLength) mCodes = new int[mInputLength][]; final int[] xCoordinates = codes.getXCoordinates(); final int[] yCoordinates = codes.getYCoordinates(); // Cache the codes so that we don't have to lookup an array list for (int i = 0; i < mInputLength; i++) { // TODO: Calculate proximity info here. if (mCodes[i] == null || mCodes[i].length < 1) { mCodes[i] = new int[1]; mCodes[i] = new int[ProximityInfo.MAX_PROXIMITY_CHARS_SIZE]; } mCodes[i][0] = codes.getCodeAt(i); final int x = xCoordinates != null && i < xCoordinates.length ? xCoordinates[i] : WordComposer.NOT_A_COORDINATE; final int y = xCoordinates != null && i < yCoordinates.length ? yCoordinates[i] : WordComposer.NOT_A_COORDINATE; proximityInfo.fillArrayWithNearestKeyCodes(x, y, codes.getCodeAt(i), mCodes[i]); } mMaxDepth = mInputLength * 3; getWordsRec(mRoots, codes, mWordBuilder, 0, false, 1, 0, -1, callback); Loading Loading @@ -328,7 +335,7 @@ public class ExpandableDictionary extends Dictionary { for (int j = 0; j < alternativesSize; j++) { final int addedAttenuation = (j > 0 ? 1 : 2); final int currentChar = currentChars[j]; if (currentChar == -1) { if (currentChar == KeyDetector.NOT_A_CODE) { break; } if (currentChar == lowerC || currentChar == c) { Loading