aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java60
1 files changed, 41 insertions, 19 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 261755f53..b474a8558 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -106,6 +106,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
/** Whether to use the binary version of the contacts dictionary */
public static final boolean USE_BINARY_CONTACTS_DICTIONARY = true;
+ /** Whether to use the binary version of the user dictionary */
+ public static final boolean USE_BINARY_USER_DICTIONARY = true;
+
// TODO: migrate this to SettingsValues
private int mSuggestionVisibility;
private static final int SUGGESTION_VISIBILILTY_SHOW_VALUE
@@ -158,7 +161,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean mShouldSwitchToLastSubtype = true;
private boolean mIsMainDictionaryAvailable;
- private UserDictionary mUserDictionary;
+ // TODO: revert this back to the concrete class after transition.
+ private Dictionary mUserDictionary;
private UserHistoryDictionary mUserHistoryDictionary;
private boolean mIsUserDictionaryAvailable;
@@ -476,9 +480,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mIsMainDictionaryAvailable = DictionaryFactory.isDictionaryAvailable(this, subtypeLocale);
- mUserDictionary = new UserDictionary(this, localeStr);
+ if (USE_BINARY_USER_DICTIONARY) {
+ mUserDictionary = new UserBinaryDictionary(this, localeStr);
+ mIsUserDictionaryAvailable = ((UserBinaryDictionary)mUserDictionary).isEnabled();
+ } else {
+ mUserDictionary = new UserDictionary(this, localeStr);
+ mIsUserDictionaryAvailable = ((UserDictionary)mUserDictionary).isEnabled();
+ }
mSuggest.setUserDictionary(mUserDictionary);
- mIsUserDictionaryAvailable = mUserDictionary.isEnabled();
resetContactsDictionary(oldContactsDictionary);
@@ -1032,26 +1041,32 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
updateSuggestions();
}
- public boolean getCurrentAutoCapsState() {
- if (!mSettingsValues.mAutoCap) return false;
+ public int getCurrentAutoCapsState() {
+ if (!mSettingsValues.mAutoCap) return Constants.TextUtils.CAP_MODE_OFF;
final EditorInfo ei = getCurrentInputEditorInfo();
- if (ei == null) return false;
+ if (ei == null) return Constants.TextUtils.CAP_MODE_OFF;
final int inputType = ei.inputType;
- if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) return true;
+ if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) {
+ return TextUtils.CAP_MODE_CHARACTERS;
+ }
final boolean noNeedToCheckCapsMode = (inputType & (InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
| InputType.TYPE_TEXT_FLAG_CAP_WORDS)) == 0;
- if (noNeedToCheckCapsMode) return false;
+ if (noNeedToCheckCapsMode) return Constants.TextUtils.CAP_MODE_OFF;
+
+ // Avoid making heavy round-trip IPC calls of {@link InputConnection#getCursorCapsMode}
+ // unless needed.
+ if (mWordComposer.isComposingWord()) return Constants.TextUtils.CAP_MODE_OFF;
final InputConnection ic = getCurrentInputConnection();
- if (ic == null) return false;
+ if (ic == null) return Constants.TextUtils.CAP_MODE_OFF;
// TODO: This blocking IPC call is heavy. Consider doing this without using IPC calls.
// Note: getCursorCapsMode() returns the current capitalization mode that is any
// combination of CAP_MODE_CHARACTERS, CAP_MODE_WORDS, and CAP_MODE_SENTENCES. 0 means none
// of them.
- return ic.getCursorCapsMode(inputType) != 0;
+ return ic.getCursorCapsMode(inputType);
}
// "ic" may be null
@@ -1121,7 +1136,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public boolean addWordToDictionary(String word) {
- mUserDictionary.addWordToUserDictionary(word, 128);
+ if (USE_BINARY_USER_DICTIONARY) {
+ ((UserBinaryDictionary)mUserDictionary).addWordToUserDictionary(word, 128);
+ } else {
+ ((UserDictionary)mUserDictionary).addWordToUserDictionary(word, 128);
+ }
// Suggestion strip should be updated after the operation of adding word to the
// user dictionary
mHandler.postUpdateSuggestions();
@@ -1139,7 +1158,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Virtual codes representing custom requests. These are used in onCustomRequest() below.
public static final int CODE_SHOW_INPUT_METHOD_PICKER = 1;
- public static final int CODE_HAPTIC_AND_AUDIO_FEEDBACK = 2;
@Override
public boolean onCustomRequest(int requestCode) {
@@ -1152,9 +1170,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return true;
}
return false;
- case CODE_HAPTIC_AND_AUDIO_FEEDBACK:
- hapticAndAudioFeedback(Keyboard.CODE_UNSPECIFIED);
- return true;
}
return false;
}
@@ -1522,7 +1537,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ic != null) {
// If it's the first letter, make note of auto-caps state
if (mWordComposer.size() == 1) {
- mWordComposer.setAutoCapitalized(getCurrentAutoCapsState());
+ mWordComposer.setAutoCapitalized(
+ getCurrentAutoCapsState() != Constants.TextUtils.CAP_MODE_OFF);
}
ic.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
}
@@ -1834,10 +1850,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void pickSuggestionManually(final int index, final CharSequence suggestion,
int x, int y) {
- final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();
final InputConnection ic = getCurrentInputConnection();
- if (ic != null) ic.beginBatchEdit();
+ if (null != ic) ic.beginBatchEdit();
+ pickSuggestionManuallyWhileInBatchEdit(index, suggestion, x, y, ic);
+ if (null != ic) ic.endBatchEdit();
+ }
+ public void pickSuggestionManuallyWhileInBatchEdit(final int index,
+ final CharSequence suggestion, final int x, final int y, final InputConnection ic) {
+ final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
if (suggestion.length() == 1 && isShowingPunctuationList()) {
// Word separators are suggested before the user inputs something.
@@ -1933,7 +1954,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mHandler.postUpdateSuggestions();
}
}
- if (null != ic) ic.endBatchEdit();
}
/**
@@ -2245,6 +2265,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
+ // TODO: Remove this method from {@link LatinIME} and move {@link FeedbackManager} to
+ // {@link KeyboardSwitcher}.
public void hapticAndAudioFeedback(final int primaryCode) {
mFeedbackManager.hapticAndAudioFeedback(primaryCode, mKeyboardSwitcher.getKeyboardView());
}