From 4a7ff90d513f8b6cbf39688c08be0828a57e311b Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Thu, 23 Jul 2009 12:17:48 -0700 Subject: [PATCH] Less aggressive CAPS mode prediction. Don't auto-correct if the typed word has more than one uppercase letter. Also, delay applying shift state to the keyboard so that fast backspaces are not interrupted by the time taken to render the shifted/unshifted keyboard. Show ellipsis on the ?123 key --- res/xml-de/kbd_qwerty.xml | 8 ++++---- res/xml/kbd_phone.xml | 2 +- res/xml/kbd_phone_symbols.xml | 2 ++ res/xml/kbd_qwerty.xml | 10 +++++----- res/xml/kbd_symbols.xml | 2 +- res/xml/kbd_symbols_shift.xml | 2 +- src/com/android/inputmethod/latin/LatinIME.java | 13 ++++++++++--- .../android/inputmethod/latin/WordComposer.java | 16 +++++++++++++++- 8 files changed, 39 insertions(+), 16 deletions(-) diff --git a/res/xml-de/kbd_qwerty.xml b/res/xml-de/kbd_qwerty.xml index 763492db5..89e53efc8 100755 --- a/res/xml-de/kbd_qwerty.xml +++ b/res/xml-de/kbd_qwerty.xml @@ -98,7 +98,7 @@ @@ -150,7 +150,7 @@ diff --git a/res/xml/kbd_phone_symbols.xml b/res/xml/kbd_phone_symbols.xml index 9ce7a1a1f..107f85c03 100755 --- a/res/xml/kbd_phone_symbols.xml +++ b/res/xml/kbd_phone_symbols.xml @@ -55,6 +55,8 @@ @@ -161,7 +161,7 @@ - \ No newline at end of file + diff --git a/res/xml/kbd_symbols.xml b/res/xml/kbd_symbols.xml index 2a150397b..ecdf75137 100755 --- a/res/xml/kbd_symbols.xml +++ b/res/xml/kbd_symbols.xml @@ -121,7 +121,7 @@ 0; checkTutorial(attribute.privateImeOptions); - if (TRACE) Debug.startMethodTracing("latinime"); + if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } @Override @@ -622,7 +626,8 @@ public class LatinIME extends InputMethodService } else { deleteChar = true; } - updateShiftKeyState(getCurrentInputEditorInfo()); + mHandler.removeMessages(MSG_UPDATE_SHIFT_STATE); + mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_UPDATE_SHIFT_STATE), 300); TextEntryState.backspace(); if (TextEntryState.getState() == TextEntryState.STATE_UNDO_COMMIT) { revertLastWord(deleteChar); @@ -772,7 +777,9 @@ public class LatinIME extends InputMethodService if (mCorrectionMode == Suggest.CORRECTION_FULL) { correctionAvailable |= typedWordValid; } - + // Don't auto-correct words with multiple capital letter + correctionAvailable &= !mWord.isMostlyCaps(); + mCandidateView.setSuggestions(stringList, false, typedWordValid, correctionAvailable); if (stringList.size() > 0) { if (correctionAvailable && !typedWordValid && stringList.size() > 1) { diff --git a/src/com/android/inputmethod/latin/WordComposer.java b/src/com/android/inputmethod/latin/WordComposer.java index c950a7f18..6679fca76 100644 --- a/src/com/android/inputmethod/latin/WordComposer.java +++ b/src/com/android/inputmethod/latin/WordComposer.java @@ -34,6 +34,8 @@ public class WordComposer { private String mPreferredWord; private StringBuilder mTypedWord; + + private int mCapsCount; /** * Whether the user chose to capitalize the word. @@ -53,6 +55,7 @@ public class WordComposer { mIsCapitalized = false; mPreferredWord = null; mTypedWord.setLength(0); + mCapsCount = 0; } /** @@ -80,6 +83,7 @@ public class WordComposer { public void add(int primaryCode, int[] codes) { mTypedWord.append((char) primaryCode); mCodes.add(codes); + if (Character.isUpperCase((char) primaryCode)) mCapsCount++; } /** @@ -87,7 +91,10 @@ public class WordComposer { */ public void deleteLast() { mCodes.remove(mCodes.size() - 1); - mTypedWord.deleteCharAt(mTypedWord.length() - 1); + final int lastPos = mTypedWord.length() - 1; + char last = mTypedWord.charAt(lastPos); + mTypedWord.deleteCharAt(lastPos); + if (Character.isUpperCase(last)) mCapsCount--; } /** @@ -138,4 +145,11 @@ public class WordComposer { public CharSequence getPreferredWord() { return mPreferredWord != null ? mPreferredWord : getTypedWord(); } + + /** + * Returns true if more than one character is upper case, otherwise returns false. + */ + public boolean isMostlyCaps() { + return mCapsCount > 1; + } }