aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-03-14 22:53:16 -0700
committerAmith Yamasani <yamasani@google.com>2010-03-14 22:53:16 -0700
commit231cacd08075e88a2bcdf25f025206de524e880b (patch)
treebf2c2b05f97c83dc35da4270c049637f12666a8b /java/src/com/android/inputmethod
parent6c2f9f5ba7afedc183086d4ee3a7aa50b3866edc (diff)
downloadlatinime-231cacd08075e88a2bcdf25f025206de524e880b.tar.gz
latinime-231cacd08075e88a2bcdf25f025206de524e880b.tar.xz
latinime-231cacd08075e88a2bcdf25f025206de524e880b.zip
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
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index e97cb24ba..8d8e35197 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -84,11 +84,27 @@ 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.
*/
public void deleteLast() {