Add isDictionaryAvailable to SubtypeSwitcher

Change-Id: I534878d330b57bbfaa8b7711082456969771f4dc
This commit is contained in:
satok 2012-04-12 19:46:02 +09:00
parent 4c9b2504e2
commit cf6b2099be
3 changed files with 11 additions and 3 deletions

View file

@ -104,8 +104,9 @@ public class SuggestionSpanUtils {
} }
public static CharSequence getTextWithSuggestionSpan(Context context, public static CharSequence getTextWithSuggestionSpan(Context context,
CharSequence pickedWord, SuggestedWords suggestedWords) { CharSequence pickedWord, SuggestedWords suggestedWords, boolean dictionaryAvailable) {
if (TextUtils.isEmpty(pickedWord) || CONSTRUCTOR_SuggestionSpan == null if (!dictionaryAvailable || TextUtils.isEmpty(pickedWord)
|| CONSTRUCTOR_SuggestionSpan == null
|| suggestedWords == null || suggestedWords.size() == 0 || suggestedWords == null || suggestedWords.size() == 0
|| OBJ_SUGGESTIONS_MAX_SIZE == null) { || OBJ_SUGGESTIONS_MAX_SIZE == null) {
return pickedWord; return pickedWord;

View file

@ -1895,7 +1895,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (mSettingsValues.mEnableSuggestionSpanInsertion) { if (mSettingsValues.mEnableSuggestionSpanInsertion) {
final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions(); final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();
ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan( ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(
this, bestWord, suggestedWords), 1); this, bestWord, suggestedWords, mSubtypeSwitcher.isDictionaryAvailable()),
1);
} else { } else {
ic.commitText(bestWord, 1); ic.commitText(bestWord, 1);
} }

View file

@ -63,6 +63,7 @@ public class SubtypeSwitcher {
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
// Variants which should be changed only by reload functions. // Variants which should be changed only by reload functions.
private boolean mNeedsToDisplayLanguage; private boolean mNeedsToDisplayLanguage;
private boolean mIsDictionaryAvailable;
private boolean mIsSystemLanguageSameAsInputLanguage; private boolean mIsSystemLanguageSameAsInputLanguage;
private InputMethodInfo mShortcutInputMethodInfo; private InputMethodInfo mShortcutInputMethodInfo;
private InputMethodSubtype mShortcutSubtype; private InputMethodSubtype mShortcutSubtype;
@ -260,6 +261,7 @@ public class SubtypeSwitcher {
getInputLocale().getLanguage()); getInputLocale().getLanguage());
mNeedsToDisplayLanguage = !(getEnabledKeyboardLocaleCount() <= 1 mNeedsToDisplayLanguage = !(getEnabledKeyboardLocaleCount() <= 1
&& mIsSystemLanguageSameAsInputLanguage); && mIsSystemLanguageSameAsInputLanguage);
mIsDictionaryAvailable = DictionaryFactory.isDictionaryAvailable(mService, mInputLocale);
} }
//////////////////////////// ////////////////////////////
@ -379,6 +381,10 @@ public class SubtypeSwitcher {
} }
} }
public boolean isDictionaryAvailable() {
return mIsDictionaryAvailable;
}
// TODO: Remove this method // TODO: Remove this method
private boolean isKeyboardMode() { private boolean isKeyboardMode() {
return KEYBOARD_MODE.equals(getCurrentSubtypeMode()); return KEYBOARD_MODE.equals(getCurrentSubtypeMode());