diff options
author | 2012-12-13 21:59:13 +0900 | |
---|---|---|
committer | 2012-12-14 20:28:22 +0900 | |
commit | 18d688c94bb8e1e26de2d12445cb3096c6126f75 (patch) | |
tree | 3a2d0c289e0ead79c8df7d582fa043bc8f975f0c /java/src/com/android/inputmethod/latin/RichInputConnection.java | |
parent | 5cb40f8a767c529af41836d33274ea3043e25011 (diff) | |
download | latinime-18d688c94bb8e1e26de2d12445cb3096c6126f75.tar.gz latinime-18d688c94bb8e1e26de2d12445cb3096c6126f75.tar.xz latinime-18d688c94bb8e1e26de2d12445cb3096c6126f75.zip |
Use the amended user dictionary word for insertion
When the user edits a word before adding it to the user
dictionary, the keyboard should replace whatever was
committed before with the amended version.
Bug: 7725834
Change-Id: I1a417be6c5a86d6a96bc2c76aca314ad8f1202a9
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 75b67bfc6..3b732278b 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -339,6 +339,24 @@ public final class RichInputConnection { } } + public void setComposingRegion(final int start, final int end) { + if (DEBUG_BATCH_NESTING) checkBatchEdit(); + if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); + mCurrentCursorPosition = end; + final CharSequence textBeforeCursor = + getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start), 0); + final int indexOfStartOfComposingText = + Math.max(textBeforeCursor.length() - (end - start), 0); + mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText, + textBeforeCursor.length())); + mCommittedTextBeforeComposingText.setLength(0); + mCommittedTextBeforeComposingText.append( + textBeforeCursor.subSequence(0, indexOfStartOfComposingText)); + if (null != mIC) { + mIC.setComposingRegion(start, end); + } + } + public void setComposingText(final CharSequence text, final int i) { if (DEBUG_BATCH_NESTING) checkBatchEdit(); if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); |