aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-01-16 22:07:43 +0900
committerJean Chalard <jchalard@google.com>2013-01-17 20:38:52 +0900
commit96845ecff62ac5a1131ce3eb8e6a06d3298dd984 (patch)
tree9ac9ae7ae3459cf3119b5604723f0362f50865ee /java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java
parentc665cbee7f136ea3cf334262f8dc1e7621f2004f (diff)
downloadlatinime-96845ecff62ac5a1131ce3eb8e6a06d3298dd984.tar.gz
latinime-96845ecff62ac5a1131ce3eb8e6a06d3298dd984.tar.xz
latinime-96845ecff62ac5a1131ce3eb8e6a06d3298dd984.zip
Insert into user dict in lower case if auto-caps (D2)
Also recapitalize afterwards if the word has been changed. Bug: 7972124 Change-Id: I9306580bb4ed0ffa80cc4559ce1abcd2034d1905
Diffstat (limited to 'java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java')
-rw-r--r--java/src/com/android/inputmethod/latin/PositionalInfoForUserDictPendingAddition.java10
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;
}
}