diff options
author | 2013-01-17 21:41:47 -0800 | |
---|---|---|
committer | 2013-01-17 21:41:47 -0800 | |
commit | 22d271755ee06aa83a5cc421597095e9027831af (patch) | |
tree | a05f76082af22f8713dacb05bf94e12efa765a81 /java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java | |
parent | 4dc422aa51476bdfb2ad2d55bafb0d1b4ff39d5f (diff) | |
parent | 5a6b4f953eb036c2d3e42316d0d62045686d2b30 (diff) | |
download | latinime-22d271755ee06aa83a5cc421597095e9027831af.tar.gz latinime-22d271755ee06aa83a5cc421597095e9027831af.tar.xz latinime-22d271755ee06aa83a5cc421597095e9027831af.zip |
am 5a6b4f95: Merge "Insert into user dict in lower case if auto-caps (D2)"
* commit '5a6b4f953eb036c2d3e42316d0d62045686d2b30':
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; } } |