summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/textservice
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-08-26 02:55:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-26 02:55:06 -0700
commitca6d29da777cffd40d9f3e38f95663ba1a2002c5 (patch)
treec8e1949e4d6231f23ec623b14596e0e866dd4be8 /core/java/android/view/textservice
parentbc81b692d51a9cd6f9d61584aacd8308ac3366ea (diff)
parentb387954a92eb6f15b7f49d5b946745f492a26363 (diff)
downloadframeworks_base-ca6d29da777cffd40d9f3e38f95663ba1a2002c5.zip
frameworks_base-ca6d29da777cffd40d9f3e38f95663ba1a2002c5.tar.gz
frameworks_base-ca6d29da777cffd40d9f3e38f95663ba1a2002c5.tar.bz2
Merge "Support system locale as the locale of the spell checkers"
Diffstat (limited to 'core/java/android/view/textservice')
-rw-r--r--core/java/android/view/textservice/TextServicesManager.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/core/java/android/view/textservice/TextServicesManager.java b/core/java/android/view/textservice/TextServicesManager.java
index 3e376da..adfb0df 100644
--- a/core/java/android/view/textservice/TextServicesManager.java
+++ b/core/java/android/view/textservice/TextServicesManager.java
@@ -72,27 +72,48 @@ public final class TextServicesManager {
* languages in settings will be returned.
* @return the spell checker session of the spell checker
*/
- // TODO: Add a method to get enabled spell checkers.
- // TODO: Handle referToSpellCheckerLanguageSettings
public SpellCheckerSession newSpellCheckerSession(Bundle bundle, Locale locale,
SpellCheckerSessionListener listener, boolean referToSpellCheckerLanguageSettings) {
if (listener == null) {
throw new NullPointerException();
}
- // TODO: set a proper locale instead of the dummy locale
- final String localeString = locale == null ? "en" : locale.toString();
final SpellCheckerInfo sci;
try {
- sci = sService.getCurrentSpellChecker(localeString);
+ sci = sService.getCurrentSpellChecker(null);
} catch (RemoteException e) {
return null;
}
if (sci == null) {
return null;
}
+ SpellCheckerSubtype subtypeInUse = null;
+ if (referToSpellCheckerLanguageSettings) {
+ subtypeInUse = getCurrentSpellCheckerSubtype(true);
+ if (subtypeInUse == null) {
+ return null;
+ }
+ if (locale != null) {
+ final String subtypeLocale = subtypeInUse.getLocale();
+ final String inputLocale = locale.toString();
+ if (subtypeLocale.length() < 2 || inputLocale.length() < 2
+ || !subtypeLocale.substring(0, 2).equals(inputLocale.substring(0, 2))) {
+ return null;
+ }
+ }
+ } else {
+ for (int i = 0; i < sci.getSubtypeCount(); ++i) {
+ final SpellCheckerSubtype subtype = sci.getSubtypeAt(i);
+ if (subtype.getLocale().equals(locale)) {
+ subtypeInUse = subtype;
+ }
+ }
+ }
+ if (subtypeInUse == null) {
+ return null;
+ }
final SpellCheckerSession session = new SpellCheckerSession(sci, sService, listener);
try {
- sService.getSpellCheckerService(sci.getId(), localeString,
+ sService.getSpellCheckerService(sci.getId(), subtypeInUse.getLocale(),
session.getTextServicesSessionListener(),
session.getSpellCheckerSessionListener(), bundle);
} catch (RemoteException e) {