diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java b/java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java index a33cefcd6..8493ef669 100644 --- a/java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java +++ b/java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java @@ -18,6 +18,8 @@ package com.android.inputmethod.latin; import android.view.inputmethod.EditorInfo; +import java.util.Locale; + /** * Holder class for data about a word already committed but that may still be edited. * @@ -70,10 +72,11 @@ public final class PositionalInfoForUserDictPendingAddition { * @param connection The RichInputConnection through which to contact the editor. * @param editorInfo Information pertaining to the editor we are currently in. * @param currentCursorPosition The current cursor position, for checking purposes. + * @param locale The locale for changing case, if necessary * @return true if the edit has been successfully made, false if we need to try again later */ public boolean tryReplaceWithActualWord(final RichInputConnection connection, - final EditorInfo editorInfo, final int currentCursorPosition) { + final EditorInfo editorInfo, final int currentCursorPosition, final Locale locale) { // If we still don't know the actual word being added, we need to try again later. if (null == mActualWordBeingAdded) return false; // The entered text and the registered text were the same anyway : we can @@ -92,9 +95,12 @@ public final class PositionalInfoForUserDictPendingAddition { // so that it won't be tried again if (currentCursorPosition != mCursorPos) return true; // We have made all the checks : do the replacement and report success + // If this was auto-capitalized, we need to restore the case before committing + final String wordWithCaseFixed = StringUtils.applyAutoCapsMode(mActualWordBeingAdded, + mCapitalizedMode, locale); connection.setComposingRegion(currentCursorPosition - mOriginalWord.length(), currentCursorPosition); - connection.commitText(mActualWordBeingAdded, mActualWordBeingAdded.length()); + connection.commitText(wordWithCaseFixed, wordWithCaseFixed.length()); return true; } } |