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.java48
1 files changed, 33 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index bbca316a4..3ee9fe8eb 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -163,8 +163,7 @@ public class LatinIME extends InputMethodService
KeyboardSwitcher mKeyboardSwitcher;
private UserDictionary mUserDictionary;
- // User Bigram is disabled for now
- //private UserBigramDictionary mUserBigramDictionary;
+ private UserBigramDictionary mUserBigramDictionary;
private ContactsDictionary mContactsDictionary;
private AutoDictionary mAutoDictionary;
@@ -454,15 +453,12 @@ public class LatinIME extends InputMethodService
mAutoDictionary.close();
}
mAutoDictionary = new AutoDictionary(this, this, mInputLocale, Suggest.DIC_AUTO);
- // User Bigram is disabled for now
- /*
if (mUserBigramDictionary != null) {
mUserBigramDictionary.close();
}
mUserBigramDictionary = new UserBigramDictionary(this, this, mInputLocale,
- Suggest.DIC_USERBIGRAM);
+ Suggest.DIC_USER);
mSuggest.setUserBigramDictionary(mUserBigramDictionary);
- */
mSuggest.setUserDictionary(mUserDictionary);
mSuggest.setContactsDictionary(mContactsDictionary);
mSuggest.setAutoDictionary(mAutoDictionary);
@@ -698,8 +694,7 @@ public class LatinIME extends InputMethodService
mKeyboardSwitcher.getInputView().closing();
}
if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites();
- // User Bigram is disabled for now
- //if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
+ if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
}
@Override
@@ -1060,6 +1055,9 @@ public class LatinIME extends InputMethodService
public boolean addWordToDictionary(String word) {
mUserDictionary.addWord(word, 128);
+ // Suggestion strip should be updated after the operation of adding word to the
+ // user dictionary
+ postUpdateSuggestions();
return true;
}
@@ -1211,9 +1209,20 @@ public class LatinIME extends InputMethodService
} else if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
ic.deleteSurroundingText(mEnteredText.length(), 0);
} else if (deleteChar) {
- sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
- if (mDeleteCount > DELETE_ACCELERATE_AT) {
+ if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
+ // Go back to the suggestion mode if the user canceled the
+ // "Tap again to save".
+ // NOTE: In gerenal, we don't revert the word when backspacing
+ // from a manual suggestion pick. We deliberately chose a
+ // different behavior only in the case of picking the first
+ // suggestion (typed word). It's intentional to have made this
+ // inconsistent with backspacing after selecting other suggestions.
+ revertLastWord(deleteChar);
+ } else {
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
+ if (mDeleteCount > DELETE_ACCELERATE_AT) {
+ sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
+ }
}
}
mJustRevertedSeparator = null;
@@ -1305,6 +1314,11 @@ public class LatinIME extends InputMethodService
mVoiceInput.incrementTextModificationInsertPunctuationCount(1);
}
+ // Should dismiss the "Tap again to save" message when handling separator
+ if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
+ postUpdateSuggestions();
+ }
+
boolean pickedDefault = false;
// Handle separator
InputConnection ic = getCurrentInputConnection();
@@ -1375,6 +1389,11 @@ public class LatinIME extends InputMethodService
mWord.reset();
return;
}
+ // Skip if result is null. It happens in some edge case.
+ if (TextUtils.isEmpty(result)) {
+ return;
+ }
+
// Make a copy of the CharSequence, since it is/could be a mutable CharSequence
final String resultCopy = result.toString();
TypedWordAlternatives entry = new TypedWordAlternatives(resultCopy,
@@ -1983,15 +2002,14 @@ public class LatinIME extends InputMethodService
&& !mSuggest.isValidWord(suggestion.toString().toLowerCase()))) {
mAutoDictionary.addWord(suggestion.toString(), frequencyDelta);
}
- // User Bigram is disabled for now
- /*
+
if (mUserBigramDictionary != null) {
- CharSequence prevWord = EditingUtil.getPreviousWord(getCurrentInputConnection());
+ CharSequence prevWord = EditingUtil.getPreviousWord(getCurrentInputConnection(),
+ mSentenceSeparators);
if (!TextUtils.isEmpty(prevWord)) {
- mUserBigramDictionary.addBigrams(prevWord.toString(), suggestion.toString(), 1);
+ mUserBigramDictionary.addBigrams(prevWord.toString(), suggestion.toString());
}
}
- */
}
}