aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/values/strings.xml22
-rw-r--r--java/src/com/android/inputmethod/latin/StringUtils.java31
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java35
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java8
4 files changed, 48 insertions, 48 deletions
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index fb341acc3..201fc7030 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -350,10 +350,10 @@
<!-- Inform the user that a particular language has an available dictionary -->
<string name="has_dictionary">Dictionary available</string>
- <!-- Preferences item for enabling to send user statistics to Google -->
+ <!-- Preferences item for enabling to send user statistics for development only diagnostics -->
<string name="prefs_enable_log">Enable user feedback</string>
- <!-- Description for enabling to send user statistics to Google -->
- <string name="prefs_description_log">Help improve this input method editor by automatically sending usage statistics and crash reports to Google.</string>
+ <!-- Description for enabling to send user statistics for development only diagnostics -->
+ <string name="prefs_description_log">Help improve this input method editor by automatically sending usage statistics and crash reports</string>
<!-- Title of the item to change the keyboard theme [CHAR LIMIT=20]-->
<string name="keyboard_layout">Keyboard theme</string>
@@ -422,12 +422,12 @@
<!-- Title of an option for usability study mode -->
<string name="prefs_usability_study_mode">Usability study mode</string>
- <!-- Title of the settings for key long press delay -->
- <string name="prefs_key_longpress_timeout_settings">Key long press delay settings</string>
- <!-- Title of the settings for keypress vibration duration -->
- <string name="prefs_keypress_vibration_duration_settings">Keypress vibration duration settings</string>
- <!-- Title of the settings for keypress sound volume -->
- <string name="prefs_keypress_sound_volume_settings">Keypress sound volume settings</string>
+ <!-- Title of the settings for key long press delay [CHAR LIMIT=30] -->
+ <string name="prefs_key_longpress_timeout_settings">Key long press delay</string>
+ <!-- Title of the settings for keypress vibration duration [CHAR LIMIT=30] -->
+ <string name="prefs_keypress_vibration_duration_settings">Keypress vibration duration</string>
+ <!-- Title of the settings for keypress sound volume [CHAR LIMIT=30] -->
+ <string name="prefs_keypress_sound_volume_settings">Keypress sound volume</string>
<!-- Title of the settings for reading an external dictionary file -->
<string name="prefs_read_external_dictionary">Read external dictionary file</string>
<!-- Message to show when there are no files to install as an external dictionary [CHAR LIMIT=100] -->
@@ -498,9 +498,9 @@
<!-- Message about some dictionary indicating the file is installed, but the dictionary is disabled -->
<string name="dictionary_disabled">Installed, disabled</string>
- <!-- Message to display in the dictionaries setting screen when some error prevented us to list installed dictionaries [CHAR LIMIT=50] -->
+ <!-- Message to display in the dictionaries setting screen when some error prevented us to list installed dictionaries [CHAR LIMIT=20] -->
<string name="cannot_connect_to_dict_service">Problem connecting to dictionary service</string>
- <!-- Message to display in the dictionaries setting screen when we found that no dictionaries are available [CHAR LIMIT=50]-->
+ <!-- Message to display in the dictionaries setting screen when we found that no dictionaries are available [CHAR LIMIT=20]-->
<string name="no_dictionaries_available">No dictionaries available</string>
<!-- Title of the options to press to refresh the list (as in, check for updates now) [CHAR_LIMIT=50] -->
diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java
index 90c3fcdd2..dcb514a5e 100644
--- a/java/src/com/android/inputmethod/latin/StringUtils.java
+++ b/java/src/com/android/inputmethod/latin/StringUtils.java
@@ -22,6 +22,10 @@ import java.util.ArrayList;
import java.util.Locale;
public final class StringUtils {
+ public static final int CAPITALIZE_NONE = 0; // No caps, or mixed case
+ public static final int CAPITALIZE_FIRST = 1; // First only
+ public static final int CAPITALIZE_ALL = 2; // All caps
+
private StringUtils() {
// This utility class is not publicly instantiable.
}
@@ -171,4 +175,31 @@ public final class StringUtils {
}
return list.toArray(new String[list.size()]);
}
+
+ // This method assumes the text is not empty or null.
+ public static int getCapitalizationType(final String text) {
+ // If the first char is not uppercase, then the word is either all lower case or
+ // camel case, and in either case we return CAPITALIZE_NONE.
+ if (!Character.isUpperCase(text.codePointAt(0))) return CAPITALIZE_NONE;
+ final int len = text.length();
+ int capsCount = 1;
+ int letterCount = 1;
+ for (int i = 1; i < len; i = text.offsetByCodePoints(i, 1)) {
+ if (1 != capsCount && letterCount != capsCount) break;
+ final int codePoint = text.codePointAt(i);
+ if (Character.isUpperCase(codePoint)) {
+ ++capsCount;
+ ++letterCount;
+ } else if (Character.isLetter(codePoint)) {
+ // We need to discount non-letters since they may not be upper-case, but may
+ // still be part of a word (e.g. single quote or dash, as in "IT'S" or "FULL-TIME")
+ ++letterCount;
+ }
+ }
+ // We know the first char is upper case. So we want to test if either every letter other
+ // than the first is lower case, or if they are all upper case. If the string is exactly
+ // one char long, then we will arrive here with letterCount 1, and this is correct, too.
+ if (1 == capsCount) return CAPITALIZE_FIRST;
+ return (letterCount == capsCount ? CAPITALIZE_ALL : CAPITALIZE_NONE);
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 38a26486d..8d3b062ff 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -58,10 +58,6 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
public static final String PREF_USE_CONTACTS_KEY = "pref_spellcheck_use_contacts";
- public static final int CAPITALIZE_NONE = 0; // No caps, or mixed case
- public static final int CAPITALIZE_FIRST = 1; // First only
- public static final int CAPITALIZE_ALL = 2; // All caps
-
private final static String[] EMPTY_STRING_ARRAY = new String[0];
private Map<String, DictionaryPool> mDictionaryPools = CollectionUtils.newSynchronizedTreeMap();
private Map<String, UserBinaryDictionary> mUserDictionaries =
@@ -325,13 +321,13 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
}
Collections.reverse(mSuggestions);
StringUtils.removeDupes(mSuggestions);
- if (CAPITALIZE_ALL == capitalizeType) {
+ if (StringUtils.CAPITALIZE_ALL == capitalizeType) {
for (int i = 0; i < mSuggestions.size(); ++i) {
// get(i) returns a CharSequence which is actually a String so .toString()
// should return the same object.
mSuggestions.set(i, mSuggestions.get(i).toString().toUpperCase(locale));
}
- } else if (CAPITALIZE_FIRST == capitalizeType) {
+ } else if (StringUtils.CAPITALIZE_FIRST == capitalizeType) {
for (int i = 0; i < mSuggestions.size(); ++i) {
// Likewise
mSuggestions.set(i, StringUtils.toTitleCase(
@@ -438,31 +434,4 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
}
return new DictAndProximity(dictionaryCollection, proximityInfo);
}
-
- // This method assumes the text is not empty or null.
- public static int getCapitalizationType(String text) {
- // If the first char is not uppercase, then the word is either all lower case,
- // and in either case we return CAPITALIZE_NONE.
- if (!Character.isUpperCase(text.codePointAt(0))) return CAPITALIZE_NONE;
- final int len = text.length();
- int capsCount = 1;
- int letterCount = 1;
- for (int i = 1; i < len; i = text.offsetByCodePoints(i, 1)) {
- if (1 != capsCount && letterCount != capsCount) break;
- final int codePoint = text.codePointAt(i);
- if (Character.isUpperCase(codePoint)) {
- ++capsCount;
- ++letterCount;
- } else if (Character.isLetter(codePoint)) {
- // We need to discount non-letters since they may not be upper-case, but may
- // still be part of a word (e.g. single quote or dash, as in "IT'S" or "FULL-TIME")
- ++letterCount;
- }
- }
- // We know the first char is upper case. So we want to test if either every letter other
- // than the first is lower case, or if they are all upper case. If the string is exactly
- // one char long, then we will arrive here with letterCount 1, and this is correct, too.
- if (1 == capsCount) return CAPITALIZE_FIRST;
- return (letterCount == capsCount ? CAPITALIZE_ALL : CAPITALIZE_NONE);
- }
}
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
index 4f86a3175..b15063235 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
@@ -150,7 +150,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
// Greek letters are either in the 370~3FF range (Greek & Coptic), or in the
// 1F00~1FFF range (Greek extended). Our dictionary contains both sort of characters.
// Our dictionary also contains a few words with 0xF2; it would be best to check
- // if that's correct, but a Google search does return results for these words so
+ // if that's correct, but a web search does return results for these words so
// they are probably okay.
return (codePoint >= 0x370 && codePoint <= 0x3FF)
|| (codePoint >= 0x1F00 && codePoint <= 0x1FFF)
@@ -214,14 +214,14 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
// If the word is in there as is, then it's in the dictionary. If not, we'll test lower
// case versions, but only if the word is not already all-lower case or mixed case.
if (dict.isValidWord(text)) return true;
- if (AndroidSpellCheckerService.CAPITALIZE_NONE == capitalizeType) return false;
+ if (StringUtils.CAPITALIZE_NONE == capitalizeType) return false;
// If we come here, we have a capitalized word (either First- or All-).
// Downcase the word and look it up again. If the word is only capitalized, we
// tested all possibilities, so if it's still negative we can return false.
final String lowerCaseText = text.toLowerCase(mLocale);
if (dict.isValidWord(lowerCaseText)) return true;
- if (AndroidSpellCheckerService.CAPITALIZE_FIRST == capitalizeType) return false;
+ if (StringUtils.CAPITALIZE_FIRST == capitalizeType) return false;
// If the lower case version is not in the dictionary, it's still possible
// that we have an all-caps version of a word that needs to be capitalized
@@ -296,7 +296,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
}
}
- final int capitalizeType = AndroidSpellCheckerService.getCapitalizationType(text);
+ final int capitalizeType = StringUtils.getCapitalizationType(text);
boolean isInDict = true;
DictAndProximity dictInfo = null;
try {