summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-08-31 17:24:47 +0900
committersatok <satok@google.com>2011-08-31 18:07:06 +0900
commitb669d6d8d8434918647b311612ebe8fd6f390b36 (patch)
tree71c222866155d02d86451a1be32e6cab1a46c97d
parent8da2a004b883dc4526bddb3198476414b2f3819c (diff)
downloadframeworks_base-b669d6d8d8434918647b311612ebe8fd6f390b36.zip
frameworks_base-b669d6d8d8434918647b311612ebe8fd6f390b36.tar.gz
frameworks_base-b669d6d8d8434918647b311612ebe8fd6f390b36.tar.bz2
Improve the fallback of the locale of the spell checker
Change-Id: I79655dd13e60f221b07346596fb05cf7d3d5cf7d
-rw-r--r--core/java/android/view/textservice/TextServicesManager.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/view/textservice/TextServicesManager.java b/core/java/android/view/textservice/TextServicesManager.java
index c85b2d9..a44582b 100644
--- a/core/java/android/view/textservice/TextServicesManager.java
+++ b/core/java/android/view/textservice/TextServicesManager.java
@@ -66,7 +66,13 @@ public final class TextServicesManager {
/**
* Get a spell checker session for the specified spell checker
- * @param locale the locale for the spell checker
+ * @param locale the locale for the spell checker. If {@param locale} is null and
+ * referToSpellCheckerLanguageSettings is true, the locale specified in Settings will be
+ * returned. If {@param locale} is not null and referToSpellCheckerLanguageSettings is true,
+ * the locale specified in Settings will be returned only when it is same as {@param locale}.
+ * Exceptionally, when referToSpellCheckerLanguageSettings is true and {@param locale} is
+ * only language (e.g. "en"), the specified locale in Settings (e.g. "en_US") will be
+ * selected.
* @param listener a spell checker session lister for getting results from a spell checker.
* @param referToSpellCheckerLanguageSettings if true, the session for one of enabled
* languages in settings will be returned.
@@ -108,7 +114,12 @@ public final class TextServicesManager {
final String localeStr = locale.toString();
for (int i = 0; i < sci.getSubtypeCount(); ++i) {
final SpellCheckerSubtype subtype = sci.getSubtypeAt(i);
- if (subtype.getLocale().equals(localeStr)) {
+ final String tempSubtypeLocale = subtype.getLocale();
+ if (tempSubtypeLocale.equals(localeStr)) {
+ subtypeInUse = subtype;
+ break;
+ } else if (localeStr.length() >= 2 && tempSubtypeLocale.length() >= 2
+ && localeStr.startsWith(tempSubtypeLocale)) {
subtypeInUse = subtype;
}
}