From 717cef79ead5d63a01d09b47caab0a3d719c69df Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 26 Apr 2011 14:27:35 +0900 Subject: [PATCH] Fix quotation marks This change * Allows snap back from symbols shifted to symbol layout. * Add "left single", "right single", "single low" and "single high reversed" quotation marks to popup characters of "single quote". * Add "double low" and "double high reversed" quatation marks to popup characters of "double quote". * Add "prime" and "double prime" to popup characters of "degree". * Disable non-ASCII key of symbol more layout on passowrd input. Bug: 4345054 Bug: 4347045 Change-Id: I8168ce6a74a9536e4966f7f9d1099ac0132925c7 --- java/res/xml-xlarge/kbd_symbols.xml | 3 +- java/res/xml-xlarge/kbd_symbols_shift.xml | 3 +- java/res/xml/kbd_key_styles.xml | 23 ++++ java/res/xml/kbd_symbols.xml | 6 +- java/res/xml/kbd_symbols_shift.xml | 16 ++- java/res/xml/kbd_symbols_shift_row4.xml | 10 +- .../keyboard/KeyboardSwitcher.java | 127 +++++++++++++----- .../inputmethod/keyboard/PointerTracker.java | 2 +- 8 files changed, 146 insertions(+), 44 deletions(-) diff --git a/java/res/xml-xlarge/kbd_symbols.xml b/java/res/xml-xlarge/kbd_symbols.xml index 1061178e0..f1deae0f9 100644 --- a/java/res/xml-xlarge/kbd_symbols.xml +++ b/java/res/xml-xlarge/kbd_symbols.xml @@ -211,9 +211,10 @@ latin:keyLabel="-" /> + + latin:popupCharacters="“,”,„,‟,«,»,‘,’,‚,‛" /> diff --git a/java/res/xml-xlarge/kbd_symbols_shift.xml b/java/res/xml-xlarge/kbd_symbols_shift.xml index 8359b7571..cc23358a5 100644 --- a/java/res/xml-xlarge/kbd_symbols_shift.xml +++ b/java/res/xml-xlarge/kbd_symbols_shift.xml @@ -99,7 +99,8 @@ latin:popupCharacters="↑,↓,←,→" /> + latin:keyLabel="°" + latin:popupCharacters="′,″" /> + + + + + + + + + + + \ No newline at end of file diff --git a/java/res/xml/kbd_symbols.xml b/java/res/xml/kbd_symbols.xml index 0b8b89969..9748bce8b 100644 --- a/java/res/xml/kbd_symbols.xml +++ b/java/res/xml/kbd_symbols.xml @@ -105,12 +105,14 @@ + + latin:popupCharacters="“,”,„,‟,«,»" + latin:maxPopupKeyboardColumn="6" /> + latin:popupCharacters="‘,’,‚,‛,´" /> @@ -64,13 +69,18 @@ latin:keyStyle="nonSpecialBackgroundTabKeyStyle" latin:keyEdgeFlags="left" /> + latin:keyStyle="nonPasswordSymbolKeyStyle" + latin:keyLabel="°" + latin:popupCharacters="′,″" /> @@ -92,12 +102,16 @@ latin:visualInsetsRight="1%p" latin:keyEdgeFlags="left" /> + latin:popupCharacters="“,”,„,‟,«,»,‘,’,‚,‛" + latin:keyStyle="nonPasswordFunctionalKeyStyle" /> + latin:keyStyle="nonPasswordFunctionalKeyStyle" /> + latin:popupCharacters="“,”,„,‟,«,»,‘,’,‚,‛" + latin:keyStyle="nonPasswordFunctionalKeyStyle" /> + latin:keyStyle="nonPasswordFunctionalKeyStyle" /> = '\u2018' && c <= '\u201f') + return true; + // \u00ab: Left-pointing double angle quotation mark + // \u00bb: Right-pointing double angle quotation mark + if (c == '\u00ab' || c == '\u00bb') + return true; + return false; + } + /** * Updates state machine to figure out when to automatically snap back to the previous mode. */ - public void onKey(int key) { + public void onKey(int code) { if (DEBUG_STATE) - Log.d(TAG, "onKey: code=" + key + " autoModeSwitchState=" + mAutoModeSwitchState + Log.d(TAG, "onKey: code=" + code + " switchState=" + mSwitchState + " pointers=" + getPointerCount()); - switch (mAutoModeSwitchState) { - case AUTO_MODE_SWITCH_STATE_MOMENTARY: + switch (mSwitchState) { + case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: // Only distinct multi touch devices can be in this state. // On non-distinct multi touch devices, mode change key is handled by // {@link LatinIME#onCodeInput}, not by {@link LatinIME#onPress} and - // {@link LatinIME#onRelease}. So, on such devices, {@link #mAutoModeSwitchState} starts - // from {@link #AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN}, or - // {@link #AUTO_MODE_SWITCH_STATE_ALPHA}, not from - // {@link #AUTO_MODE_SWITCH_STATE_MOMENTARY}. - if (key == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) { + // {@link LatinIME#onRelease}. So, on such devices, {@link #mSwitchState} starts + // from {@link #SWITCH_STATE_SYMBOL_BEGIN}, or {@link #SWITCH_STATE_ALPHA}, not from + // {@link #SWITCH_STATE_MOMENTARY}. + if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) { // Detected only the mode change key has been pressed, and then released. if (mIsSymbols) { - mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN; + mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } else { - mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_ALPHA; + mSwitchState = SWITCH_STATE_ALPHA; } } else if (getPointerCount() == 1) { // Snap back to the previous keyboard mode if the user pressed the mode change key @@ -628,18 +671,34 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } else { // Chording input is being started. The keyboard mode will be snapped back to the // previous mode in {@link onReleaseSymbol} when the mode change key is released. - mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_CHORDING; + mSwitchState = SWITCH_STATE_CHORDING_ALPHA; } break; - case AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN: - if (key != Keyboard.CODE_SPACE && key != Keyboard.CODE_ENTER && key >= 0) { - mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_SYMBOL; + case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: + if (code == Keyboard.CODE_SHIFT) { + // Detected only the shift key has been pressed on symbol layout, and then released. + mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; + } else if (getPointerCount() == 1) { + // Snap back to the previous keyboard mode if the user pressed the shift key on + // symbol mode and slid to other key, then released the finger. + toggleShift(); + mSwitchState = SWITCH_STATE_SYMBOL; + } else { + // Chording input is being started. The keyboard mode will be snapped back to the + // previous mode in {@link onReleaseShift} when the shift key is released. + mSwitchState = SWITCH_STATE_CHORDING_SYMBOL; } break; - case AUTO_MODE_SWITCH_STATE_SYMBOL: + case SWITCH_STATE_SYMBOL_BEGIN: + if (!isSpaceCharacter(code) && code >= 0) { + mSwitchState = SWITCH_STATE_SYMBOL; + } + break; + case SWITCH_STATE_SYMBOL: + case SWITCH_STATE_CHORDING_SYMBOL: // Snap back to alpha keyboard mode if user types one or more non-space/enter - // characters followed by a space/enter. - if (key == Keyboard.CODE_ENTER || key == Keyboard.CODE_SPACE) { + // characters followed by a space/enter or quotation mark. + if (isSpaceCharacter(code) || isQuoteCharacter(code)) { changeKeyboardMode(); } break; diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index e3161f610..abd1ef286 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -662,7 +662,7 @@ public class PointerTracker { // We need not start long press timer on the key which has manual temporary upper case // code defined and the keyboard is in manual temporary upper case mode. return; - } else if (mKeyboardSwitcher.isInMomentaryAutoModeSwitchState()) { + } else if (mKeyboardSwitcher.isInMomentarySwitchState()) { // We use longer timeout for sliding finger input started from the symbols mode key. mHandler.startLongPressTimer(mLongPressKeyTimeout * 3, keyIndex, this); } else {