aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/StringUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/StringUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/StringUtils.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java
index 1dfec7ee0..8696a5caf 100644
--- a/java/src/com/android/inputmethod/latin/StringUtils.java
+++ b/java/src/com/android/inputmethod/latin/StringUtils.java
@@ -18,6 +18,8 @@ package com.android.inputmethod.latin;
import android.text.TextUtils;
+import com.android.inputmethod.keyboard.Keyboard; // For character constants
+
import java.util.ArrayList;
import java.util.Locale;
@@ -218,8 +220,6 @@ public final class StringUtils {
* {@link #CAP_MODE_SENTENCES}.
*/
public static int getCapsMode(CharSequence cs, int reqModes) {
- int i;
- char c;
// Quick description of what we want to do:
// CAP_MODE_CHARACTERS is always on.
// CAP_MODE_WORDS is on if there is some whitespace before the cursor.
@@ -245,9 +245,11 @@ public final class StringUtils {
// it may look like a right parenthesis for example. We also include double quote and
// single quote since they aren't start punctuation in the unicode sense, but should still
// be skipped for English. TODO: does this depend on the language?
+ int i;
for (i = cs.length(); i > 0; i--) {
- c = cs.charAt(i - 1);
- if (c != '"' && c != '\'' && Character.getType(c) != Character.START_PUNCTUATION) {
+ final char c = cs.charAt(i - 1);
+ if (c != Keyboard.CODE_DOUBLE_QUOTE && c != Keyboard.CODE_SINGLE_QUOTE
+ && Character.getType(c) != Character.START_PUNCTUATION) {
break;
}
}
@@ -294,15 +296,17 @@ public final class StringUtils {
// it's wrong for German, it's wrong for Spanish, and possibly everything else.
// (note that American rules and British rules have nothing to do with en_US and en_GB,
// as both rules are used in both countries - it's merely a name for the set of rules)
- c = cs.charAt(j - 1);
- if (c != '"' && c != '\'' && Character.getType(c) != Character.END_PUNCTUATION) {
+ final char c = cs.charAt(j - 1);
+ if (c != Keyboard.CODE_DOUBLE_QUOTE && c != Keyboard.CODE_SINGLE_QUOTE
+ && Character.getType(c) != Character.END_PUNCTUATION) {
break;
}
}
if (j <= 0) return TextUtils.CAP_MODE_CHARACTERS & reqModes;
- c = cs.charAt(j - 1);
- if (c == '.' || c == '?' || c == '!') {
+ char c = cs.charAt(j - 1);
+ if (c == Keyboard.CODE_PERIOD || c == Keyboard.CODE_QUESTION_MARK
+ || c == Keyboard.CODE_EXCLAMATION_MARK) {
// Here we found a marker for sentence end (we consider these to be one of
// either . or ? or ! only). So this is probably the end of a sentence, but if we
// found a period, we still want to check the case where this is a abbreviation
@@ -315,10 +319,10 @@ public final class StringUtils {
// whatever the reason. In the example "in the U.S..", the last period is a full
// stop following the abbreviation period, and we should capitalize but we don't.
// Likewise, "I don't know... " should capitalize, but fails to do so.
- if (c == '.') {
+ if (c == Keyboard.CODE_PERIOD) {
for (int k = j - 2; k >= 0; k--) {
c = cs.charAt(k);
- if (c == '.') {
+ if (c == Keyboard.CODE_PERIOD) {
return TextUtils.CAP_MODE_CHARACTERS & reqModes;
}
if (!Character.isLetter(c)) {