Merge "Fix occasional correction errors in suggesting obvious corrections."

main
Amith Yamasani 2010-03-16 12:24:13 -07:00 committed by Android (Google) Code Review
commit c3413faf92
1 changed files with 16 additions and 0 deletions

View File

@ -84,10 +84,26 @@ public class WordComposer {
*/ */
public void add(int primaryCode, int[] codes) { public void add(int primaryCode, int[] codes) {
mTypedWord.append((char) primaryCode); mTypedWord.append((char) primaryCode);
correctPrimaryJuxtapos(primaryCode, codes);
mCodes.add(codes); mCodes.add(codes);
if (Character.isUpperCase((char) primaryCode)) mCapsCount++; if (Character.isUpperCase((char) primaryCode)) mCapsCount++;
} }
/**
* Swaps the first and second values in the codes array if the primary code is not the first
* value in the array but the second. This happens when the preferred key is not the key that
* the user released the finger on.
* @param primaryCode the preferred character
* @param codes array of codes based on distance from touch point
*/
private void correctPrimaryJuxtapos(int primaryCode, int[] codes) {
if (codes.length < 2) return;
if (codes[0] > 0 && codes[1] > 0 && codes[0] != primaryCode && codes[1] == primaryCode) {
codes[1] = codes[0];
codes[0] = primaryCode;
}
}
/** /**
* Delete the last keystroke as a result of hitting backspace. * Delete the last keystroke as a result of hitting backspace.
*/ */