From cf6b2099be5deda896ba129a835a06867be2293f Mon Sep 17 00:00:00 2001
From: satok <satok@google.com>
Date: Thu, 12 Apr 2012 19:46:02 +0900
Subject: [PATCH] Add isDictionaryAvailable to SubtypeSwitcher

Change-Id: I534878d330b57bbfaa8b7711082456969771f4dc
---
 .../com/android/inputmethod/compat/SuggestionSpanUtils.java | 5 +++--
 java/src/com/android/inputmethod/latin/LatinIME.java        | 3 ++-
 java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 6 ++++++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
index 43c19d7eb1..d97989d9c0 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
@@ -104,8 +104,9 @@ public class SuggestionSpanUtils {
     }
 
     public static CharSequence getTextWithSuggestionSpan(Context context,
-            CharSequence pickedWord, SuggestedWords suggestedWords) {
-        if (TextUtils.isEmpty(pickedWord) || CONSTRUCTOR_SuggestionSpan == null
+            CharSequence pickedWord, SuggestedWords suggestedWords, boolean dictionaryAvailable) {
+        if (!dictionaryAvailable || TextUtils.isEmpty(pickedWord)
+                || CONSTRUCTOR_SuggestionSpan == null
                 || suggestedWords == null || suggestedWords.size() == 0
                 || OBJ_SUGGESTIONS_MAX_SIZE == null) {
             return pickedWord;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 7cdeef897a..187252a317 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1895,7 +1895,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
             if (mSettingsValues.mEnableSuggestionSpanInsertion) {
                 final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();
                 ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(
-                        this, bestWord, suggestedWords), 1);
+                        this, bestWord, suggestedWords, mSubtypeSwitcher.isDictionaryAvailable()),
+                        1);
             } else {
                 ic.commitText(bestWord, 1);
             }
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index 6612c24cd5..99f0ee1841 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -63,6 +63,7 @@ public class SubtypeSwitcher {
     /*-----------------------------------------------------------*/
     // Variants which should be changed only by reload functions.
     private boolean mNeedsToDisplayLanguage;
+    private boolean mIsDictionaryAvailable;
     private boolean mIsSystemLanguageSameAsInputLanguage;
     private InputMethodInfo mShortcutInputMethodInfo;
     private InputMethodSubtype mShortcutSubtype;
@@ -260,6 +261,7 @@ public class SubtypeSwitcher {
                 getInputLocale().getLanguage());
         mNeedsToDisplayLanguage = !(getEnabledKeyboardLocaleCount() <= 1
                 && mIsSystemLanguageSameAsInputLanguage);
+        mIsDictionaryAvailable = DictionaryFactory.isDictionaryAvailable(mService, mInputLocale);
     }
 
     ////////////////////////////
@@ -379,6 +381,10 @@ public class SubtypeSwitcher {
         }
     }
 
+    public boolean isDictionaryAvailable() {
+        return mIsDictionaryAvailable;
+    }
+
     // TODO: Remove this method
     private boolean isKeyboardMode() {
         return KEYBOARD_MODE.equals(getCurrentSubtypeMode());
-- 
GitLab