aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/EditingUtil.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-08-13 13:29:49 -0700
committerAmith Yamasani <yamasani@google.com>2010-08-17 09:05:24 -0700
commitc20c5a8d4c29f52075a157098cf8d7192a45ac36 (patch)
tree8a15bb122c488ad77b96bd321c039c38e5e16272 /java/src/com/android/inputmethod/latin/EditingUtil.java
parentc9a181b1b340012fbc8c32d23a3294364a7ad27b (diff)
downloadlatinime-c20c5a8d4c29f52075a157098cf8d7192a45ac36.tar.gz
latinime-c20c5a8d4c29f52075a157098cf8d7192a45ac36.tar.xz
latinime-c20c5a8d4c29f52075a157098cf8d7192a45ac36.zip
Fixes for correction mode - reliably show the corrections when tapping on a word.
Also, continue to show the corrections when user keeps replacing the word repeatedly with different corrections from the suggestion strip. There were problems with tapping suggestions quickly or tapping the same suggestion more than once (same length). Also fixes Bug: 2852891 - Text suggestion appears incorrectly when selecting text that's not a whole word. Changed the TextEntryState states to an enum type instead of int. Needed it to show the states for debugging purposes.
Diffstat (limited to 'java/src/com/android/inputmethod/latin/EditingUtil.java')
-rw-r--r--java/src/com/android/inputmethod/latin/EditingUtil.java27
1 files changed, 25 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/EditingUtil.java b/java/src/com/android/inputmethod/latin/EditingUtil.java
index 0c87f8d58..be31cb787 100644
--- a/java/src/com/android/inputmethod/latin/EditingUtil.java
+++ b/java/src/com/android/inputmethod/latin/EditingUtil.java
@@ -16,12 +16,12 @@
package com.android.inputmethod.latin;
-import java.util.regex.Pattern;
-
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
+import java.util.regex.Pattern;
+
/**
* Utility methods to deal with editing text through an InputConnection.
*/
@@ -203,4 +203,27 @@ public class EditingUtil {
return null;
}
}
+
+ /**
+ * Checks if the cursor is touching/inside a word or the selection is for a whole
+ * word and no more and no less.
+ * @param range the Range object that contains the bounds of the word around the cursor
+ * @param start the start of the selection
+ * @param end the end of the selection, which could be the same as the start, if text is not
+ * in selection mode
+ * @return false if the selection is a partial word or straddling multiple words, true if
+ * the selection is a full word or there is no selection.
+ */
+ public static boolean isFullWordOrInside(Range range, int start, int end) {
+ // Is the cursor inside or touching a word?
+ if (start == end) return true;
+
+ // Is it a selection? Then is the start of the selection the start of the word and
+ // the size of the selection the size of the word? Then return true
+ if (start < end
+ && (range.charsBefore == 0 && range.charsAfter == end - start)) {
+ return true;
+ }
+ return false;
+ }
}