aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-01-24 07:34:07 -0800
committerAmith Yamasani <yamasani@google.com>2010-01-24 07:34:07 -0800
commit1c551251106e506c70fad7ba0cb8b1e2a7dff3a9 (patch)
tree880f7e2f8fb3190d82fd4c84cce84548a0ef8277 /src/com/android/inputmethod/latin/LatinIME.java
parent39acd7e80a84100e46386fc6e267c9b4754be764 (diff)
downloadlatinime-1c551251106e506c70fad7ba0cb8b1e2a7dff3a9.tar.gz
latinime-1c551251106e506c70fad7ba0cb8b1e2a7dff3a9.tar.xz
latinime-1c551251106e506c70fad7ba0cb8b1e2a7dff3a9.zip
Auto-added words will only be capitalized if user intended to. #2373284
If a user creates a new word at the beginning of a sentence, then don't add it as a capitalized word in the dictionary.
Diffstat (limited to 'src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--src/com/android/inputmethod/latin/LatinIME.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/com/android/inputmethod/latin/LatinIME.java b/src/com/android/inputmethod/latin/LatinIME.java
index a71f3d867..a9a61c3a2 100644
--- a/src/com/android/inputmethod/latin/LatinIME.java
+++ b/src/com/android/inputmethod/latin/LatinIME.java
@@ -815,15 +815,19 @@ public class LatinIME extends InputMethodService
InputConnection ic = getCurrentInputConnection();
if (attr != null && mInputView != null && mKeyboardSwitcher.isAlphabetMode()
&& ic != null) {
- int caps = 0;
- EditorInfo ei = getCurrentInputEditorInfo();
- if (mAutoCap && ei != null && ei.inputType != EditorInfo.TYPE_NULL) {
- caps = ic.getCursorCapsMode(attr.inputType);
- }
- mInputView.setShifted(mCapsLock || caps != 0);
+ mInputView.setShifted(mCapsLock || getCursorCapsMode(ic, attr) != 0);
}
}
-
+
+ private int getCursorCapsMode(InputConnection ic, EditorInfo attr) {
+ int caps = 0;
+ EditorInfo ei = getCurrentInputEditorInfo();
+ if (mAutoCap && ei != null && ei.inputType != EditorInfo.TYPE_NULL) {
+ caps = ic.getCursorCapsMode(attr.inputType);
+ }
+ return caps;
+ }
+
private void swapPunctuationAndSpace() {
final InputConnection ic = getCurrentInputConnection();
if (ic == null) return;
@@ -837,7 +841,7 @@ public class LatinIME extends InputMethodService
updateShiftKeyState(getCurrentInputEditorInfo());
}
}
-
+
private void doubleSpace() {
//if (!mAutoPunctuate) return;
if (mCorrectionMode == Suggest.CORRECTION_NONE) return;
@@ -1014,6 +1018,11 @@ public class LatinIME extends InputMethodService
mWord.add(primaryCode, keyCodes);
InputConnection ic = getCurrentInputConnection();
if (ic != null) {
+ // If it's the first letter, make note of auto-caps state
+ if (mWord.size() == 1) {
+ mWord.setAutoCapitalized(
+ getCursorCapsMode(ic, getCurrentInputEditorInfo()) != 0);
+ }
ic.setComposingText(mComposing, 1);
}
postUpdateSuggestions();
@@ -1847,6 +1856,11 @@ public class LatinIME extends InputMethodService
final int length = word.length();
// Don't add very short or very long words.
if (length < 2 || length > getMaxWordLength()) return;
+ if (mWord.isAutoCapitalized()) {
+ // Remove caps before adding
+ word = Character.toLowerCase(word.charAt(0))
+ + word.substring(1);
+ }
int freq = getWordFrequency(word);
freq = freq < 0 ? addFrequency : freq + addFrequency;
super.addWord(word, freq);