diff options
author | 2010-09-28 16:35:29 -0700 | |
---|---|---|
committer | 2010-09-29 11:37:43 -0700 | |
commit | b8fa10080dfac777fce7c8a7fc3180e8b540f9f5 (patch) | |
tree | 62c02ac221932901c06da7ab5c22f4a5faf5f2b4 /java | |
parent | 6e5a3986854549a45c95770b5a88ae5577e93299 (diff) | |
download | latinime-b8fa10080dfac777fce7c8a7fc3180e8b540f9f5.tar.gz latinime-b8fa10080dfac777fce7c8a7fc3180e8b540f9f5.tar.xz latinime-b8fa10080dfac777fce7c8a7fc3180e8b540f9f5.zip |
Check recorrection on focusing into a text field that has text already.
Bug: 3004827
Change-Id: I00e9d925fcf17fa9f7a9aefe6572a648e023be11
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 26f8a328b..0bfcc0704 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -676,10 +676,33 @@ public class LatinIME extends InputMethodService inputView.setPreviewEnabled(mPopupOn); inputView.setProximityCorrectionEnabled(true); mPredictionOn = mPredictionOn && (mCorrectionMode > 0 || mShowSuggestions); + // If we just entered a text field, maybe it has some old text that requires correction + checkReCorrectionOnStart(); checkTutorial(attribute.privateImeOptions); if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } + private void checkReCorrectionOnStart() { + if (mReCorrectionEnabled && isPredictionOn()) { + // First get the cursor position. This is required by setOldSuggestions(), so that + // it can pass the correct range to setComposingRegion(). At this point, we don't + // have valid values for mLastSelectionStart/Stop because onUpdateSelection() has + // not been called yet. + InputConnection ic = getCurrentInputConnection(); + if (ic == null) return; + ExtractedTextRequest etr = new ExtractedTextRequest(); + etr.token = 0; // anything is fine here + ExtractedText et = ic.getExtractedText(etr, 0); + if (et == null) return; + + mLastSelectionStart = et.startOffset + et.selectionStart; + mLastSelectionEnd = et.startOffset + et.selectionEnd; + + // Then look for possible corrections in a delayed fashion + if (!TextUtils.isEmpty(et.text)) postUpdateOldSuggestions(); + } + } + @Override public void onFinishInput() { super.onFinishInput(); |