aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-10-09 20:33:38 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-09 20:33:38 -0700
commit0126566c03c47176172bfbcd78ee45e1929e6ffc (patch)
treece946934c469e9e8640242bdbe9b985d86e4a246 /java/src
parent470f13fc1155ec3ca1095d71a088175d9861849b (diff)
parent0ded41149e8adb0d84205eb75c59b3b207e801e4 (diff)
downloadlatinime-0126566c03c47176172bfbcd78ee45e1929e6ffc.tar.gz
latinime-0126566c03c47176172bfbcd78ee45e1929e6ffc.tar.xz
latinime-0126566c03c47176172bfbcd78ee45e1929e6ffc.zip
am 0ded4114: am 73ca0f2c: am 423921ca: Merge "Fallback on empty locales."
* commit '0ded41149e8adb0d84205eb75c59b3b207e801e4': Fallback on empty locales.
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 21849ba14..d51c63dd3 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -605,8 +605,24 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
private void initSuggest() {
- final Locale subtypeLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
- final String localeStr = subtypeLocale.toString();
+ final Locale switcherSubtypeLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
+ final String switcherLocaleStr = switcherSubtypeLocale.toString();
+ final Locale subtypeLocale;
+ final String localeStr;
+ if (TextUtils.isEmpty(switcherLocaleStr)) {
+ // This happens in very rare corner cases - for example, immediately after a switch
+ // to LatinIME has been requested, about a frame later another switch happens. In this
+ // case, we are about to go down but we still don't know it, however the system tells
+ // us there is no current subtype so the locale is the empty string. Take the best
+ // possible guess instead -- it's bound to have no consequences, and we have no way
+ // of knowing anyway.
+ Log.e(TAG, "System is reporting no current subtype.");
+ subtypeLocale = getResources().getConfiguration().locale;
+ localeStr = subtypeLocale.toString();
+ } else {
+ subtypeLocale = switcherSubtypeLocale;
+ localeStr = switcherLocaleStr;
+ }
final Suggest newSuggest = new Suggest(this /* Context */, subtypeLocale,
this /* SuggestInitializationListener */);