diff options
author | 2012-04-02 01:20:26 -0700 | |
---|---|---|
committer | 2012-04-02 01:20:26 -0700 | |
commit | 6747b30a6435775740c8ae9547c2719f7b350435 (patch) | |
tree | bc78cdfce0aeae132593b77637506bcb6c9cdde1 /java/src/com/android/inputmethod/latin/ExpandableDictionary.java | |
parent | 850f3a85250f9b1cebc5557109f524b08c2f5b26 (diff) | |
parent | 209dd09e5a534b5819c70fbc5cc1ef056f77d1a3 (diff) | |
download | latinime-6747b30a6435775740c8ae9547c2719f7b350435.tar.gz latinime-6747b30a6435775740c8ae9547c2719f7b350435.tar.xz latinime-6747b30a6435775740c8ae9547c2719f7b350435.zip |
Merge "Come back the proximity correction to ExpandableDictionary"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ExpandableDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/ExpandableDictionary.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java index 098913bef..46d11fa37 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -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; @@ -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); @@ -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) { |