Skip to content
Snippets Groups Projects
Commit 231cacd0 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Fix occasional correction errors in suggesting obvious corrections.

Bug: 2513996

The array of adjacent letters did not have the primary code in the first
position. Swap the codes around to make the primary the first one.

Change-Id: Id753254c88d440d3d76dbc048d123dfc78edf58d
parent 6c2f9f5b
No related branches found
No related tags found
No related merge requests found
......@@ -84,10 +84,26 @@ public class WordComposer {
*/
public void add(int primaryCode, int[] codes) {
mTypedWord.append((char) primaryCode);
correctPrimaryJuxtapos(primaryCode, codes);
mCodes.add(codes);
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.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment