diff options
author | 2011-11-22 18:07:43 -0800 | |
---|---|---|
committer | 2011-11-22 18:18:29 -0800 | |
commit | c1f7d39b4aabe71ecf7934272a848d8c0fe5a7f0 (patch) | |
tree | 0cf482dfc774bb20ddeec69c7e49c3bec31506c3 /java/src | |
parent | adb89c109e6ecf5c221e60fa705d69f1f9c35455 (diff) | |
download | latinime-c1f7d39b4aabe71ecf7934272a848d8c0fe5a7f0.tar.gz latinime-c1f7d39b4aabe71ecf7934272a848d8c0fe5a7f0.tar.xz latinime-c1f7d39b4aabe71ecf7934272a848d8c0fe5a7f0.zip |
Introduce ignoreWhileTyping flags to Key.keyActionFlags
Bug: 5639503
Change-Id: Ic2afad6766edb2538a58f722209e2daa40aa488d
Diffstat (limited to 'java/src')
3 files changed, 20 insertions, 13 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 15c41a9f2..ce5f29d73 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -108,6 +108,7 @@ public class Key { private final int mActionFlags; private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01; private static final int ACTION_FLAGS_NO_KEY_PREVIEW = 0x02; + private static final int ACTION_FLAGS_IGNORE_WHILE_TYPING = 0x04; /** The current pressed state of this key */ private boolean mPressed; @@ -325,6 +326,10 @@ public class Key { return (mActionFlags & ACTION_FLAGS_NO_KEY_PREVIEW) != 0; } + public boolean ignoreWhileTyping() { + return (mActionFlags & ACTION_FLAGS_IGNORE_WHILE_TYPING) != 0; + } + public Typeface selectTypeface(Typeface defaultTypeface) { // TODO: Handle "bold" here too? if ((mLabelFlags & LABEL_FLAGS_FONT_NORMAL) != 0) { diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 2b136e093..60631e867 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -145,7 +145,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke } @Override - public boolean isIgnoringSpecialKey() { + public boolean isTyping() { return hasMessages(MSG_KEY_TYPED); } diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 067fe9459..f7a0d97ae 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -75,7 +75,7 @@ public class PointerTracker { public interface TimerProxy { public void startKeyTypedTimer(long delay); - public boolean isIgnoringSpecialKey(); + public boolean isTyping(); public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker); public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker); public void cancelLongPressTimer(); @@ -85,7 +85,7 @@ public class PointerTracker { @Override public void startKeyTypedTimer(long delay) {} @Override - public boolean isIgnoringSpecialKey() { return false; } + public boolean isTyping() { return false; } @Override public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker) {} @Override @@ -720,10 +720,14 @@ public class PointerTracker { return; } if (key.mOutputText != null) { - callListenerOnTextInput(key); + final boolean ignoreText = key.ignoreWhileTyping() && mTimerProxy.isTyping(); + if (!ignoreText) { + callListenerOnTextInput(key); + } callListenerOnRelease(key, key.mCode, false); - // TODO: "text" input key could have a special action too - mTimerProxy.startKeyTypedTimer(sIgnoreSpecialKeyTimeout); + if (!ignoreText) { + mTimerProxy.startKeyTypedTimer(sIgnoreSpecialKeyTimeout); + } } else { int code = key.mCode; final int[] codes = mKeyDetector.newCodeArray(); @@ -743,16 +747,14 @@ public class PointerTracker { codes[1] = codes[0]; codes[0] = code; } - // TODO: Move this special action to Key.keyActionFlags - final boolean specialCode = ( - code == Keyboard.CODE_SETTINGS || code == Keyboard.CODE_SHORTCUT); - final boolean ignoreSpecialCode = specialCode && mTimerProxy.isIgnoringSpecialKey(); - final boolean shouldStartKeyTypedTyper = !(specialCode || isModifierCode(code)); - if (!ignoreSpecialCode) { + final boolean ignoreCode = key.ignoreWhileTyping() && mTimerProxy.isTyping(); + if (!ignoreCode) { + // TODO: It might be useful to register the nearest key code in codes[] instead of + // just ignoring. callListenerOnCodeInput(key, code, codes, x, y); } callListenerOnRelease(key, code, false); - if (shouldStartKeyTypedTyper) { + if (!key.ignoreWhileTyping() && !isModifierCode(code)) { mTimerProxy.startKeyTypedTimer(sIgnoreSpecialKeyTimeout); } } |