From 7b6afb1287fb6d5edfebed7403eb31ed23a8348d Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" <takaoka@google.com> Date: Tue, 8 May 2012 12:39:54 +0900 Subject: [PATCH] Enable long-press spacebar on 7 inch tablet This change also eliminate useless attribute longPressSpaceKeyTimeout of LatinKeyboardView. Bug: 6449356 Change-Id: Ib4dace4b9510c0eb96bdddacf8e0dbaa14fcfbbf --- java/res/values-sw600dp/config.xml | 2 - java/res/values-sw768dp/config.xml | 2 - java/res/values/attrs.xml | 2 - java/res/values/config.xml | 3 -- java/res/values/styles.xml | 1 - java/res/xml-sw600dp/key_styles_common.xml | 2 +- .../keyboard/LatinKeyboardView.java | 52 ++++++++----------- 7 files changed, 23 insertions(+), 41 deletions(-) diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml index c507bd2a9e..2f35d9ae5a 100644 --- a/java/res/values-sw600dp/config.xml +++ b/java/res/values-sw600dp/config.xml @@ -28,8 +28,6 @@ <bool name="config_auto_correction_spacebar_led_enabled">false</bool> <!-- The language is never displayed if == 0, always displayed if < 0 --> <integer name="config_delay_before_fadeout_language_on_spacebar">1200</integer> - <!-- Long pressing space will invoke IME switcher if > 0, never invoke IME switcher if == 0 --> - <integer name="config_long_press_space_key_timeout">0</integer> <!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. --> <string name="config_default_keyboard_theme_index" translatable="false">5</string> <integer name="config_max_more_keys_column">5</integer> diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml index b78a6c62a2..5fcaeeb416 100644 --- a/java/res/values-sw768dp/config.xml +++ b/java/res/values-sw768dp/config.xml @@ -26,8 +26,6 @@ <bool name="config_default_popup_preview">false</bool> <bool name="config_default_sound_enabled">true</bool> <bool name="config_auto_correction_spacebar_led_enabled">false</bool> - <!-- Long pressing space will invoke IME switcher if > 0, never invoke IME switcher if == 0 --> - <integer name="config_long_press_space_key_timeout">0</integer> <!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. --> <string name="config_default_keyboard_theme_index" translatable="false">5</string> <integer name="config_max_more_keys_column">5</integer> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index dbe3cd74f4..844b8e96d0 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -154,8 +154,6 @@ <attr name="longPressKeyTimeout" format="integer" /> <!-- Long press timeout of shift key in millisecond. --> <attr name="longPressShiftKeyTimeout" format="integer" /> - <!-- Long press timeout of space key in millisecond. --> - <attr name="longPressSpaceKeyTimeout" format="integer" /> <!-- Ignore special key timeout while typing in millisecond. --> <attr name="ignoreAltCodeKeyTimeout" format="integer" /> <!-- More keys keyboard will shown at touched point. --> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 133bb0a068..a6fd22ee14 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -63,9 +63,6 @@ <integer name="config_long_press_key_timeout">400</integer> <!-- 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> - <!-- Long pressing space will invoke IME switcher if > 0, never invoke IME switcher if == 0 --> - <integer name="config_long_press_space_key_timeout"> - @integer/config_long_press_key_timeout</integer> <integer name="config_ignore_alt_code_key_timeout">700</integer> <!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if false --> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index b08ff3b908..1f8c37550c 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -75,7 +75,6 @@ <item name="keyRepeatInterval">@integer/config_key_repeat_interval</item> <item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item> <item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item> - <item name="longPressSpaceKeyTimeout">@integer/config_long_press_space_key_timeout</item> <item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</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> diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml index dcaf45027f..5b3d1b8354 100644 --- a/java/res/xml-sw600dp/key_styles_common.xml +++ b/java/res/xml-sw600dp/key_styles_common.xml @@ -77,7 +77,7 @@ <key-style latin:styleName="spaceKeyStyle" latin:code="!code/key_space" - latin:keyActionFlags="noKeyPreview" /> + latin:keyActionFlags="noKeyPreview|enableLongPress" /> <!-- U+200C: ZERO WIDTH NON-JOINER U+200D: ZERO WIDTH JOINER --> <key-style diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 58bd845e10..84564c87af 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -110,7 +110,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint; private final PointerTrackerParams mPointerTrackerParams; - private final boolean mIsSpacebarTriggeringPopupByLongPress; private final SuddenJumpingTouchEventHandler mTouchScreenRegulator; protected KeyDetector mKeyDetector; @@ -197,29 +196,27 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke @Override public void startLongPressTimer(PointerTracker tracker) { cancelLongPressTimer(); - if (tracker != null) { - final Key key = tracker.getKey(); - final int delay; - switch (key.mCode) { - case Keyboard.CODE_SHIFT: - delay = mParams.mLongPressShiftKeyTimeout; - break; - case Keyboard.CODE_SPACE: - delay = mParams.mLongPressSpaceKeyTimeout; - break; - default: - if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) { - // We use longer timeout for sliding finger input started from the symbols - // mode key. - delay = mParams.mLongPressKeyTimeout * 3; - } else { - delay = mParams.mLongPressKeyTimeout; - } - break; - } - if (delay > 0) { - sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay); + if (tracker == null) { + return; + } + final Key key = tracker.getKey(); + final int delay; + switch (key.mCode) { + case Keyboard.CODE_SHIFT: + delay = mParams.mLongPressShiftKeyTimeout; + break; + default: + if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) { + // We use longer timeout for sliding finger input started from the symbols + // mode key. + delay = mParams.mLongPressKeyTimeout * 3; + } else { + delay = mParams.mLongPressKeyTimeout; } + break; + } + if (delay > 0) { + sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay); } } @@ -314,7 +311,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke public final int mKeyRepeatInterval; public final int mLongPressKeyTimeout; public final int mLongPressShiftKeyTimeout; - public final int mLongPressSpaceKeyTimeout; public final int mIgnoreAltCodeKeyTimeout; public KeyTimerParams(TypedArray latinKeyboardViewAttr) { @@ -326,8 +322,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke R.styleable.LatinKeyboardView_longPressKeyTimeout, 0); mLongPressShiftKeyTimeout = latinKeyboardViewAttr.getInt( R.styleable.LatinKeyboardView_longPressShiftKeyTimeout, 0); - mLongPressSpaceKeyTimeout = latinKeyboardViewAttr.getInt( - R.styleable.LatinKeyboardView_longPressSpaceKeyTimeout, 0); mIgnoreAltCodeKeyTimeout = latinKeyboardViewAttr.getInt( R.styleable.LatinKeyboardView_ignoreAltCodeKeyTimeout, 0); } @@ -369,7 +363,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final KeyTimerParams keyTimerParams = new KeyTimerParams(a); mPointerTrackerParams = new PointerTrackerParams(a); - mIsSpacebarTriggeringPopupByLongPress = (keyTimerParams.mLongPressSpaceKeyTimeout > 0); final float keyHysteresisDistance = a.getDimension( R.styleable.LatinKeyboardView_keyHysteresisDistance, 0); @@ -881,9 +874,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke drawSpacebar(key, canvas, paint); // Whether space key needs to show the "..." popup hint for special purposes - if (mIsSpacebarTriggeringPopupByLongPress - && ImfUtils.hasMultipleEnabledIMEsOrSubtypes( - getContext(), true /* include aux subtypes */)) { + if (key.isLongPressEnabled() && ImfUtils.hasMultipleEnabledIMEsOrSubtypes( + getContext(), true /* include aux subtypes */)) { drawKeyPopupHint(key, canvas, paint, params); } } else if (key.mCode == Keyboard.CODE_LANGUAGE_SWITCH) { -- GitLab