From 18d688c94bb8e1e26de2d12445cb3096c6126f75 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 13 Dec 2012 21:59:13 +0900 Subject: 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 --- .../android/inputmethod/latin/RichInputConnection.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java') 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(); -- cgit v1.2.3-83-g751a