aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-10-08 13:06:16 +0900
committerJean Chalard <jchalard@google.com>2013-10-08 15:28:43 +0900
commit10581e68af1de7d0b5d2c88927ad7bbad7dad600 (patch)
treef98252235425da1a9bc57452dc882bf444c800e9 /java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java
parenta81d37eef640ffee430be813fcccf0a448cf7ed0 (diff)
downloadlatinime-10581e68af1de7d0b5d2c88927ad7bbad7dad600.tar.gz
latinime-10581e68af1de7d0b5d2c88927ad7bbad7dad600.tar.xz
latinime-10581e68af1de7d0b5d2c88927ad7bbad7dad600.zip
Make the sentence separator a resource.
This will help handing correctly the armenian full stop. Bug: 10082781 Change-Id: Id7bb219ebd89daba203216eab362d1cc26a65a36
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java20
1 files changed, 8 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java b/java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java
index 60b24d5d5..3d4404a98 100644
--- a/java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java
@@ -21,6 +21,7 @@ import android.text.TextUtils;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.WordComposer;
+import com.android.inputmethod.latin.settings.SettingsValues;
import java.util.Locale;
@@ -60,11 +61,6 @@ public final class CapsModeUtils {
|| WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED == mode;
}
- private static boolean isPeriod(final int codePoint) {
- // TODO: make this a resource.
- return codePoint == Constants.CODE_PERIOD || codePoint == Constants.CODE_ARMENIAN_PERIOD;
- }
-
/**
* Determine what caps mode should be in effect at the current offset in
* the text. Only the mode bits set in <var>reqModes</var> will be
@@ -78,7 +74,7 @@ public final class CapsModeUtils {
* @param reqModes The modes to be checked: may be any combination of
* {@link TextUtils#CAP_MODE_CHARACTERS}, {@link TextUtils#CAP_MODE_WORDS}, and
* {@link TextUtils#CAP_MODE_SENTENCES}.
- * @param locale The locale to consider for capitalization rules
+ * @param settingsValues The current settings values.
* @param hasSpaceBefore Whether we should consider there is a space inserted at the end of cs
*
* @return Returns the actual capitalization modes that can be in effect
@@ -86,8 +82,8 @@ public final class CapsModeUtils {
* {@link TextUtils#CAP_MODE_CHARACTERS}, {@link TextUtils#CAP_MODE_WORDS}, and
* {@link TextUtils#CAP_MODE_SENTENCES}.
*/
- public static int getCapsMode(final CharSequence cs, final int reqModes, final Locale locale,
- final boolean hasSpaceBefore) {
+ public static int getCapsMode(final CharSequence cs, final int reqModes,
+ final SettingsValues settingsValues, final boolean hasSpaceBefore) {
// 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.
@@ -172,7 +168,7 @@ public final class CapsModeUtils {
// mark as the exact thing quoted and handling the surrounding punctuation independently,
// e.g. <<Did he say, "let's go home"?>>
// Hence, specifically for English, we treat this special case here.
- if (Locale.ENGLISH.getLanguage().equals(locale.getLanguage())) {
+ if (Locale.ENGLISH.getLanguage().equals(settingsValues.mLocale.getLanguage())) {
for (; j > 0; j--) {
// Here we look to go over any closing punctuation. This is because in dominant
// variants of English, the final period is placed within double quotes and maybe
@@ -195,7 +191,7 @@ public final class CapsModeUtils {
if (c == Constants.CODE_QUESTION_MARK || c == Constants.CODE_EXCLAMATION_MARK) {
return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_SENTENCES) & reqModes;
}
- if (!isPeriod(c) || j <= 0) {
+ if (settingsValues.mSentenceSeparator != c || j <= 0) {
return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS) & reqModes;
}
@@ -245,7 +241,7 @@ public final class CapsModeUtils {
case WORD:
if (Character.isLetter(c)) {
state = WORD;
- } else if (isPeriod(c)) {
+ } else if (settingsValues.mSentenceSeparator == c) {
state = PERIOD;
} else {
return caps;
@@ -261,7 +257,7 @@ public final class CapsModeUtils {
case LETTER:
if (Character.isLetter(c)) {
state = LETTER;
- } else if (isPeriod(c)) {
+ } else if (settingsValues.mSentenceSeparator == c) {
state = PERIOD;
} else {
return noCaps;