diff options
author | 2013-01-18 05:39:18 +0000 | |
---|---|---|
committer | 2013-01-18 05:39:18 +0000 | |
commit | 5a6b4f953eb036c2d3e42316d0d62045686d2b30 (patch) | |
tree | 4b0362cd3beb5132105efa4f84f1dabb654d8f9c /java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java | |
parent | 345ef6762700cdb0fca25aa54b22ef83aaaac0ab (diff) | |
parent | 96845ecff62ac5a1131ce3eb8e6a06d3298dd984 (diff) | |
download | latinime-5a6b4f953eb036c2d3e42316d0d62045686d2b30.tar.gz latinime-5a6b4f953eb036c2d3e42316d0d62045686d2b30.tar.xz latinime-5a6b4f953eb036c2d3e42316d0d62045686d2b30.zip |
Merge "Insert into user dict in lower case if auto-caps (D2)"
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; } } |