am 55ce2cc2: [IL27] Some refactoring

* commit '55ce2cc2d562a5733e8430f41dce265c8cf8f8db':
  [IL27] Some refactoring
main
Jean Chalard 2013-12-20 02:30:55 -08:00 committed by Android Git Automerger
commit df63ed4156
2 changed files with 9 additions and 6 deletions

View File

@ -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 {

View File

@ -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) {