am c1f7d39b: Introduce ignoreWhileTyping flags to Key.keyActionFlags
* commit 'c1f7d39b4aabe71ecf7934272a848d8c0fe5a7f0': Introduce ignoreWhileTyping flags to Key.keyActionFlagsmain
commit
c92d08b71c
|
@ -201,6 +201,7 @@
|
|||
<!-- This should be aligned with Key.ACTION_FLAGS_* -->
|
||||
<flag name="isRepeatable" value="0x01" />
|
||||
<flag name="noKeyPreview" value="0x02" />
|
||||
<flag name="ignoreWhileTyping" value="0x04" />
|
||||
</attr>
|
||||
<!-- The string of characters to output when this key is pressed. -->
|
||||
<attr name="keyOutputText" format="string" />
|
||||
|
|
|
@ -77,13 +77,13 @@
|
|||
latin:styleName="shortcutKeyStyle"
|
||||
latin:code="@integer/key_shortcut"
|
||||
latin:keyIcon="iconShortcutKey"
|
||||
latin:keyActionFlags="noKeyPreview"
|
||||
latin:keyActionFlags="noKeyPreview|ignoreWhileTyping"
|
||||
latin:parentStyle="f2PopupStyle" />
|
||||
<key-style
|
||||
latin:styleName="settingsKeyStyle"
|
||||
latin:code="@integer/key_settings"
|
||||
latin:keyIcon="iconSettingsKey"
|
||||
latin:keyActionFlags="noKeyPreview"
|
||||
latin:keyActionFlags="noKeyPreview|ignoreWhileTyping"
|
||||
latin:backgroundType="functional" />
|
||||
<key-style
|
||||
latin:styleName="tabKeyStyle"
|
||||
|
|
|
@ -55,17 +55,17 @@
|
|||
latin:keyLabelFlags="hasPopupHint"
|
||||
latin:moreKeys="@string/more_keys_for_smiley"
|
||||
latin:maxMoreKeysColumn="5" />
|
||||
<key-style
|
||||
latin:styleName="settingsKeyStyle"
|
||||
latin:code="@integer/key_settings"
|
||||
latin:keyIcon="iconSettingsKey"
|
||||
latin:keyActionFlags="noKeyPreview"
|
||||
latin:backgroundType="functional" />
|
||||
<key-style
|
||||
latin:styleName="shortcutKeyStyle"
|
||||
latin:code="@integer/key_shortcut"
|
||||
latin:keyIcon="iconShortcutKey"
|
||||
latin:keyActionFlags="noKeyPreview"
|
||||
latin:keyActionFlags="noKeyPreview|ignoreWhileTyping"
|
||||
latin:backgroundType="functional" />
|
||||
<key-style
|
||||
latin:styleName="settingsKeyStyle"
|
||||
latin:code="@integer/key_settings"
|
||||
latin:keyIcon="iconSettingsKey"
|
||||
latin:keyActionFlags="noKeyPreview|ignoreWhileTyping"
|
||||
latin:backgroundType="functional" />
|
||||
<key-style
|
||||
latin:styleName="tabKeyStyle"
|
||||
|
|
|
@ -163,13 +163,13 @@
|
|||
latin:styleName="shortcutKeyStyle"
|
||||
latin:code="@integer/key_shortcut"
|
||||
latin:keyIcon="iconShortcutKey"
|
||||
latin:keyActionFlags="noKeyPreview"
|
||||
latin:keyActionFlags="noKeyPreview|ignoreWhileTyping"
|
||||
latin:parentStyle="f1PopupStyle" />
|
||||
<key-style
|
||||
latin:styleName="settingsKeyStyle"
|
||||
latin:code="@integer/key_settings"
|
||||
latin:keyIcon="iconSettingsKey"
|
||||
latin:keyActionFlags="noKeyPreview"
|
||||
latin:keyActionFlags="noKeyPreview|ignoreWhileTyping"
|
||||
latin:backgroundType="functional" />
|
||||
<key-style
|
||||
latin:styleName="tabKeyStyle"
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -145,7 +145,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoringSpecialKey() {
|
||||
public boolean isTyping() {
|
||||
return hasMessages(MSG_KEY_TYPED);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue