diff options
author | 2012-01-10 17:24:00 +0900 | |
---|---|---|
committer | 2012-01-10 18:19:36 +0900 | |
commit | 8cab0b56eb8db311f158b18a361d9ceb85cff482 (patch) | |
tree | f0518e4f9cc3c1a8b648a632d30f5a7fc0f531dc /java/src/com | |
parent | 33e2813d0964a0c7accfbef1bbca957d083cba1b (diff) | |
download | latinime-8cab0b56eb8db311f158b18a361d9ceb85cff482.tar.gz latinime-8cab0b56eb8db311f158b18a361d9ceb85cff482.tar.xz latinime-8cab0b56eb8db311f158b18a361d9ceb85cff482.zip |
Get rid of Keyboard.CODE_DUMMY
Change-Id: Id2320f4d9b5f22f0ac844ab20ce42b0c4e7c6880
Diffstat (limited to 'java/src/com')
7 files changed, 24 insertions, 24 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 3d5ab05c3..efaf58fc2 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -142,7 +142,7 @@ public class KeyCodeDescriptionMapper { } // Just attempt to speak the description. - if (key.mCode != Keyboard.CODE_DUMMY) { + if (key.mCode != Keyboard.CODE_UNSPECIFIED) { return getDescriptionForKeyCode(context, keyboard, key, shouldObscure); } diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index e1e74fc9a..ebd61505d 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -198,7 +198,7 @@ public class Key { mLabel = label; mOutputText = outputText; mCode = code; - mAltCode = Keyboard.CODE_DUMMY; + mAltCode = Keyboard.CODE_UNSPECIFIED; mIcon = icon; mDisabledIcon = null; mPreviewIcon = null; @@ -299,13 +299,13 @@ public class Key { } final int firstChar = mLabel.charAt(0); mCode = getRtlParenthesisCode(firstChar, params.mIsRtlKeyboard); - } else if (code != Keyboard.CODE_UNSPECIFIED) { - mCode = code; + } else if (code == Keyboard.CODE_UNSPECIFIED && mOutputText != null) { + mCode = Keyboard.CODE_OUTPUT_TEXT; } else { - mCode = Keyboard.CODE_DUMMY; + mCode = code; } mAltCode = style.getInt(keyAttr, - R.styleable.Keyboard_Key_altCode, Keyboard.CODE_DUMMY); + R.styleable.Keyboard_Key_altCode, Keyboard.CODE_UNSPECIFIED); mHashCode = hashCode(this); keyAttr.recycle(); @@ -508,7 +508,7 @@ public class Key { * @param y the y-coordinate of the point * @return whether or not the point falls on the key. If the key is attached to an edge, it * will assume that all points between the key and the edge are considered to be on the key. - * @see #markAsLeftEdge(KeyboardParams) etc. + * @see #markAsLeftEdge(Keyboard.Params) etc. */ public boolean isOnKey(int x, int y) { return mHitBox.contains(x, y); @@ -615,7 +615,7 @@ public class Key { * This constructor is being used only for divider in more keys keyboard. */ public Spacer(Keyboard.Params params, Drawable icon, int x, int y, int width, int height) { - super(params, null, null, icon, Keyboard.CODE_DUMMY, null, x, y, width, height); + super(params, null, null, icon, Keyboard.CODE_UNSPECIFIED, null, x, y, width, height); } @Override diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index fad12cc1f..c1d024cef 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -86,19 +86,20 @@ public class Keyboard { public static final int CODE_CLOSING_ANGLE_BRACKET = '>'; public static final int CODE_DIGIT0 = '0'; public static final int CODE_PLUS = '+'; + private static final int MINIMUM_LETTER_CODE = CODE_TAB; - /** Special keys code. Must be non-positive. + /** Special keys code. Must be negative. * These should be aligned with values/keycodes.xml */ - public static final int CODE_DUMMY = 0; public static final int CODE_SHIFT = -1; public static final int CODE_SWITCH_ALPHA_SYMBOL = -2; public static final int CODE_CAPSLOCK = -3; + public static final int CODE_OUTPUT_TEXT = -4; public static final int CODE_DELETE = -5; public static final int CODE_SETTINGS = -6; public static final int CODE_SHORTCUT = -7; // Code value representing the code is not specified. - public static final int CODE_UNSPECIFIED = -99; + public static final int CODE_UNSPECIFIED = -9; public final KeyboardId mId; public final int mThemeId; @@ -167,7 +168,7 @@ public class Keyboard { } public Key getKey(int code) { - if (code == CODE_DUMMY) { + if (code == CODE_UNSPECIFIED) { return null; } final Integer keyCode = code; @@ -253,7 +254,7 @@ public class Keyboard { } public static boolean isLetterCode(int code) { - return code > CODE_DUMMY; + return code >= MINIMUM_LETTER_CODE; } public static class Params { @@ -428,9 +429,9 @@ public class Keyboard { case CODE_SHIFT: return "shift"; case CODE_SWITCH_ALPHA_SYMBOL: return "symbol"; case CODE_CAPSLOCK: return "capslock"; + case CODE_OUTPUT_TEXT: return "text"; case CODE_DELETE: return "delete"; case CODE_SHORTCUT: return "shortcut"; - case CODE_DUMMY: return "dummy"; case CODE_UNSPECIFIED: return "unspec"; default: if (code < 0) Log.w(TAG, "Unknow negative key code=" + code); diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 7c14b5888..2183e8ed6 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -262,10 +262,8 @@ public class PointerTracker { final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier(); final boolean alterCode = key.altCodeWhileTyping() && mTimerProxy.isTyping(); final int code = alterCode ? key.mAltCode : primaryCode; - // If code is CODE_DUMMY here, this key will be ignored or generate text. - final CharSequence text = (code != Keyboard.CODE_DUMMY) ? null : key.mOutputText; if (DEBUG_LISTENER) { - Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + text + Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + key.mOutputText + " codes="+ KeyDetector.printableCodes(keyCodes) + " x=" + x + " y=" + y + " ignoreModifier=" + ignoreModifierKey + " alterCode=" + alterCode + " enabled=" + key.isEnabled()); @@ -274,10 +272,10 @@ public class PointerTracker { return; } if (key.isEnabled()) { - if (code != Keyboard.CODE_DUMMY) { + if (code == Keyboard.CODE_OUTPUT_TEXT) { + mListener.onTextInput(key.mOutputText); + } else if (code != Keyboard.CODE_UNSPECIFIED) { mListener.onCodeInput(code, keyCodes, x, y); - } else if (text != null) { - mListener.onTextInput(text); } if (!key.altCodeWhileTyping() && !key.isModifier()) { mTimerProxy.startKeyTypedTimer(sIgnoreSpecialKeyTimeout); diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index c0adf970a..f54bdbb05 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -434,7 +434,8 @@ public class KeyboardState { } break; case SWITCH_STATE_SYMBOL_BEGIN: - if (!isSpaceCharacter(code) && code >= 0) { + if (!isSpaceCharacter(code) && (Keyboard.isLetterCode(code) + || code == Keyboard.CODE_OUTPUT_TEXT)) { mSwitchState = SWITCH_STATE_SYMBOL; } // Snap back to alpha keyboard mode immediately if user types a quote character. diff --git a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java index a490b0ad6..93be31ed9 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java @@ -148,12 +148,12 @@ public class MoreKeySpecParser { return code; } if (indexOfLabelEnd(moreKeySpec, 0) > 0) - return Keyboard.CODE_DUMMY; + return Keyboard.CODE_UNSPECIFIED; final String label = getLabel(moreKeySpec); // Code is automatically generated for one letter label. if (label != null && label.length() == 1) return label.charAt(0); - return Keyboard.CODE_DUMMY; + return Keyboard.CODE_UNSPECIFIED; } public static int getIconId(String moreKeySpec) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e6478b683..4cb60558c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1305,7 +1305,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar ic.commitText(text, 1); ic.endBatchEdit(); mKeyboardSwitcher.updateShiftState(); - mKeyboardSwitcher.onCodeInput(Keyboard.CODE_DUMMY); + mKeyboardSwitcher.onCodeInput(Keyboard.CODE_OUTPUT_TEXT); mSpaceState = SPACE_STATE_NONE; mEnteredText = text; mWordComposer.reset(); |