am 1e974dea: Merge "Disable gesture input while fast typing" into jb-mr1-dev

* commit '1e974deaa61c5ed1a8e64fb623ddd0b6af09bc3e':
  Disable gesture input while fast typing
main
Tadashi G. Takaoka 2012-09-24 08:45:24 -07:00 committed by Android Git Automerger
commit b119f0da1b
6 changed files with 37 additions and 1 deletions

View File

@ -125,6 +125,8 @@
<attr name="longPressShiftKeyTimeout" format="integer" /> <attr name="longPressShiftKeyTimeout" format="integer" />
<!-- Ignore special key timeout while typing in millisecond. --> <!-- Ignore special key timeout while typing in millisecond. -->
<attr name="ignoreAltCodeKeyTimeout" format="integer" /> <attr name="ignoreAltCodeKeyTimeout" format="integer" />
<!-- Disable gesture input while fast typing timer in millisecond. -->
<attr name="disableGestureWhileFastTypingTimeout" format="integer" />
<!-- More keys keyboard will shown at touched point. --> <!-- More keys keyboard will shown at touched point. -->
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" /> <attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
</declare-styleable> </declare-styleable>

View File

@ -66,6 +66,7 @@
<!-- Long pressing shift will invoke caps-lock if > 0, never invoke caps-lock if == 0 --> <!-- Long pressing shift will invoke caps-lock if > 0, never invoke caps-lock if == 0 -->
<integer name="config_long_press_shift_key_timeout">1200</integer> <integer name="config_long_press_shift_key_timeout">1200</integer>
<integer name="config_ignore_alt_code_key_timeout">350</integer> <integer name="config_ignore_alt_code_key_timeout">350</integer>
<integer name="config_disable_gesture_while_fast_typing_timeout">350</integer>
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if <!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
false --> false -->
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool> <bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>

View File

@ -89,6 +89,7 @@
<item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item> <item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item>
<item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item> <item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item>
<item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item> <item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item>
<item name="disableGestureWhileFastTypingTimeout">@integer/config_disable_gesture_while_fast_typing_timeout</item>
<item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item> <item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item>
<item name="languageOnSpacebarFinalAlpha">@integer/config_language_on_spacebar_final_alpha</item> <item name="languageOnSpacebarFinalAlpha">@integer/config_language_on_spacebar_final_alpha</item>
<item name="languageOnSpacebarFadeoutAnimator">@anim/language_on_spacebar_fadeout</item> <item name="languageOnSpacebarFadeoutAnimator">@anim/language_on_spacebar_fadeout</item>

View File

@ -142,12 +142,14 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
private static final int MSG_REPEAT_KEY = 1; private static final int MSG_REPEAT_KEY = 1;
private static final int MSG_LONGPRESS_KEY = 2; private static final int MSG_LONGPRESS_KEY = 2;
private static final int MSG_DOUBLE_TAP = 3; private static final int MSG_DOUBLE_TAP = 3;
private static final int MSG_DISABLE_GESTURE_EXPIRED = 4;
private final int mKeyRepeatStartTimeout; private final int mKeyRepeatStartTimeout;
private final int mKeyRepeatInterval; private final int mKeyRepeatInterval;
private final int mLongPressKeyTimeout; private final int mLongPressKeyTimeout;
private final int mLongPressShiftKeyTimeout; private final int mLongPressShiftKeyTimeout;
private final int mIgnoreAltCodeKeyTimeout; private final int mIgnoreAltCodeKeyTimeout;
private final int mDisableGestureWhileFastTypingTimeout;
public KeyTimerHandler(final MainKeyboardView outerInstance, public KeyTimerHandler(final MainKeyboardView outerInstance,
final TypedArray mainKeyboardViewAttr) { final TypedArray mainKeyboardViewAttr) {
@ -163,6 +165,8 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
R.styleable.MainKeyboardView_longPressShiftKeyTimeout, 0); R.styleable.MainKeyboardView_longPressShiftKeyTimeout, 0);
mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt( mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0); R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
mDisableGestureWhileFastTypingTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_disableGestureWhileFastTypingTimeout, 0);
} }
@Override @Override
@ -187,6 +191,9 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1); KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
} }
break; break;
case MSG_DISABLE_GESTURE_EXPIRED:
PointerTracker.clearGestureOffWhileFastTyping();
break;
} }
} }
@ -311,6 +318,14 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
return hasMessages(MSG_TYPING_STATE_EXPIRED); return hasMessages(MSG_TYPING_STATE_EXPIRED);
} }
@Override
public void startGestureOffWhileFastTypingTimer() {
removeMessages(MSG_DISABLE_GESTURE_EXPIRED);
PointerTracker.setGestureOffWhileFastTyping();
sendMessageDelayed(obtainMessage(MSG_DISABLE_GESTURE_EXPIRED),
mDisableGestureWhileFastTypingTimeout);
}
@Override @Override
public void startDoubleTapTimer() { public void startDoubleTapTimer() {
sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP), sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP),

View File

@ -46,6 +46,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
private static boolean sMainDictionaryAvailable = false; private static boolean sMainDictionaryAvailable = false;
private static boolean sGestureHandlingEnabledByInputField = false; private static boolean sGestureHandlingEnabledByInputField = false;
private static boolean sGestureHandlingEnabledByUser = false; private static boolean sGestureHandlingEnabledByUser = false;
private static boolean sGestureOffWhileFastTyping = false;
public interface KeyEventHandler { public interface KeyEventHandler {
/** /**
@ -84,6 +85,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
public interface TimerProxy { public interface TimerProxy {
public void startTypingStateTimer(Key typedKey); public void startTypingStateTimer(Key typedKey);
public boolean isTypingState(); public boolean isTypingState();
public void startGestureOffWhileFastTypingTimer();
public void startKeyRepeatTimer(PointerTracker tracker); public void startKeyRepeatTimer(PointerTracker tracker);
public void startLongPressTimer(PointerTracker tracker); public void startLongPressTimer(PointerTracker tracker);
public void startLongPressTimer(int code); public void startLongPressTimer(int code);
@ -99,6 +101,8 @@ public class PointerTracker implements PointerTrackerQueue.Element {
@Override @Override
public boolean isTypingState() { return false; } public boolean isTypingState() { return false; }
@Override @Override
public void startGestureOffWhileFastTypingTimer() {}
@Override
public void startKeyRepeatTimer(PointerTracker tracker) {} public void startKeyRepeatTimer(PointerTracker tracker) {}
@Override @Override
public void startLongPressTimer(PointerTracker tracker) {} public void startLongPressTimer(PointerTracker tracker) {}
@ -225,6 +229,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
private static void updateGestureHandlingMode() { private static void updateGestureHandlingMode() {
sShouldHandleGesture = sMainDictionaryAvailable sShouldHandleGesture = sMainDictionaryAvailable
&& !sGestureOffWhileFastTyping
&& sGestureHandlingEnabledByInputField && sGestureHandlingEnabledByInputField
&& sGestureHandlingEnabledByUser && sGestureHandlingEnabledByUser
&& !AccessibilityUtils.getInstance().isTouchExplorationEnabled(); && !AccessibilityUtils.getInstance().isTouchExplorationEnabled();
@ -241,6 +246,16 @@ public class PointerTracker implements PointerTrackerQueue.Element {
updateGestureHandlingMode(); updateGestureHandlingMode();
} }
public static void setGestureOffWhileFastTyping() {
sGestureOffWhileFastTyping = true;
updateGestureHandlingMode();
}
public static void clearGestureOffWhileFastTyping() {
sGestureOffWhileFastTyping = false;
updateGestureHandlingMode();
}
public static PointerTracker getPointerTracker(final int id, final KeyEventHandler handler) { public static PointerTracker getPointerTracker(final int id, final KeyEventHandler handler) {
final ArrayList<PointerTracker> trackers = sTrackers; final ArrayList<PointerTracker> trackers = sTrackers;
@ -346,8 +361,10 @@ public class PointerTracker implements PointerTrackerQueue.Element {
if (key.isEnabled() || altersCode) { if (key.isEnabled() || altersCode) {
if (code == Keyboard.CODE_OUTPUT_TEXT) { if (code == Keyboard.CODE_OUTPUT_TEXT) {
mListener.onTextInput(key.getOutputText()); mListener.onTextInput(key.getOutputText());
mTimerProxy.startGestureOffWhileFastTypingTimer();
} else if (code != Keyboard.CODE_UNSPECIFIED) { } else if (code != Keyboard.CODE_UNSPECIFIED) {
mListener.onCodeInput(code, x, y); mListener.onCodeInput(code, x, y);
mTimerProxy.startGestureOffWhileFastTypingTimer();
} }
} }
} }

View File

@ -45,7 +45,7 @@ public class GestureStroke {
private int mDetectFastMoveY; private int mDetectFastMoveY;
// TODO: Move some of these to resource. // TODO: Move some of these to resource.
private static final float START_GESTURE_LENGTH_THRESHOLD_RATIO_TO_KEY_WIDTH = 0.75f; private static final float START_GESTURE_LENGTH_THRESHOLD_RATIO_TO_KEY_WIDTH = 0.60f;
private static final int START_GESTURE_DURATION_THRESHOLD = 70; // msec private static final int START_GESTURE_DURATION_THRESHOLD = 70; // msec
private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH = 1.0f / 6.0f; private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH = 1.0f / 6.0f;