From 55ce2cc2d562a5733e8430f41dce265c8cf8f8db Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 20 Dec 2013 19:05:33 +0900 Subject: [PATCH] [IL27] Some refactoring Bug: 8636060 Change-Id: Iedfdf71350f5fe3ab451fc5ec6e3c9901f71e50f --- java/src/com/android/inputmethod/latin/LatinIME.java | 10 ++++++---- .../inputmethod/latin/UserBinaryDictionary.java | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index dd2c80664..d6bebe22d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -128,7 +128,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private final SubtypeState mSubtypeState = new SubtypeState(); private UserBinaryDictionary mUserDictionary; - private boolean mIsUserDictionaryAvailable; // Personalization debugging params private boolean mUseOnlyPersonalizationDictionaryForDebug = false; @@ -563,7 +562,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } mUserDictionary = new UserBinaryDictionary(this, subtypeLocale); - mIsUserDictionaryAvailable = mUserDictionary.isEnabled(); newSuggest.setUserDictionary(mUserDictionary); newSuggest.setAdditionalDictionaries(mInputLogic.mSuggest /* oldSuggest */, mSettings.getCurrent()); @@ -1246,6 +1244,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return mInputLogic.getCurrentRecapitalizeState(); } + public Locale getCurrentSubtypeLocale() { + return mSubtypeSwitcher.getCurrentSubtypeLocale(); + } + // Callback for the {@link SuggestionStripView}, to call when the "add to dictionary" hint is // pressed. @Override @@ -1256,7 +1258,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } final String wordToEdit; if (CapsModeUtils.isAutoCapsMode(mInputLogic.mLastComposedWord.mCapitalizedMode)) { - wordToEdit = word.toLowerCase(mSubtypeSwitcher.getCurrentSubtypeLocale()); + wordToEdit = word.toLowerCase(getCurrentSubtypeLocale()); } else { wordToEdit = word; } @@ -1884,7 +1886,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen LatinImeLoggerUtils.onSeparator((char)Constants.CODE_SPACE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); } - if (showingAddToDictionaryHint && mIsUserDictionaryAvailable) { + if (showingAddToDictionaryHint && mUserDictionary.mEnabled) { mSuggestionStripView.showAddToDictionaryHint( suggestion, currentSettings.mHintToSaveText); } else { diff --git a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java index 6fc98220f..68648dd62 100644 --- a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java @@ -74,6 +74,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { private ContentObserver mObserver; final private String mLocale; final private boolean mAlsoUseMoreRestrictiveLocales; + final public boolean mEnabled; public UserBinaryDictionary(final Context context, final Locale locale) { this(context, locale, false); @@ -118,7 +119,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { } }; cres.registerContentObserver(Words.CONTENT_URI, true, mObserver); - + mEnabled = readIsEnabled(); loadDictionary(); } @@ -196,7 +197,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { } } - public boolean isEnabled() { + private boolean readIsEnabled() { final ContentResolver cr = mContext.getContentResolver(); final ContentProviderClient client = cr.acquireContentProviderClient(Words.CONTENT_URI); if (client != null) {