Trigger IME switcher by long-pressing space key
Long press time out for space key is set to 1000msec. FYI: Time out for shift key is 1200ms and for mini popup keyboard is 400ms. Bug: 4971680 Change-Id: Id05f519baa15ca2e54958997ddf7b6b3b7a2d078main
parent
60be1b6ae1
commit
98b5c982b9
|
@ -36,6 +36,8 @@
|
||||||
<bool name="config_show_mini_keyboard_at_touched_point">true</bool>
|
<bool name="config_show_mini_keyboard_at_touched_point">true</bool>
|
||||||
<!-- The language is never displayed if == 0, always displayed if < 0 -->
|
<!-- The language is never displayed if == 0, always displayed if < 0 -->
|
||||||
<integer name="config_delay_before_fadeout_language_on_spacebar">1200</integer>
|
<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}. -->
|
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
|
||||||
<string name="config_default_keyboard_theme_id" translatable="false">5</string>
|
<string name="config_default_keyboard_theme_id" translatable="false">5</string>
|
||||||
<string name="config_text_size_of_language_on_spacebar" translatable="false">medium</string>
|
<string name="config_text_size_of_language_on_spacebar" translatable="false">medium</string>
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
<!-- Showing mini keyboard, just above the touched point if true, aligned to the key if false -->
|
<!-- Showing mini keyboard, just above the touched point if true, aligned to the key if false -->
|
||||||
<bool name="config_show_mini_keyboard_at_touched_point">true</bool>
|
<bool name="config_show_mini_keyboard_at_touched_point">true</bool>
|
||||||
<integer name="config_delay_update_suggestions">180</integer>
|
<integer name="config_delay_update_suggestions">180</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}. -->
|
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
|
||||||
<string name="config_default_keyboard_theme_id" translatable="false">5</string>
|
<string name="config_default_keyboard_theme_id" translatable="false">5</string>
|
||||||
<string name="config_text_size_of_language_on_spacebar" translatable="false">medium</string>
|
<string name="config_text_size_of_language_on_spacebar" translatable="false">medium</string>
|
||||||
|
|
|
@ -60,7 +60,10 @@
|
||||||
<integer name="config_keyboard_grid_width">32</integer>
|
<integer name="config_keyboard_grid_width">32</integer>
|
||||||
<integer name="config_keyboard_grid_height">16</integer>
|
<integer name="config_keyboard_grid_height">16</integer>
|
||||||
<integer name="config_long_press_key_timeout">400</integer>
|
<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>
|
<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">1200</integer>
|
||||||
<integer name="config_touch_noise_threshold_millis">40</integer>
|
<integer name="config_touch_noise_threshold_millis">40</integer>
|
||||||
<integer name="config_double_spaces_turn_into_period_timeout">1100</integer>
|
<integer name="config_double_spaces_turn_into_period_timeout">1100</integer>
|
||||||
<dimen name="config_touch_noise_threshold_distance">2.0mm</dimen>
|
<dimen name="config_touch_noise_threshold_distance">2.0mm</dimen>
|
||||||
|
|
|
@ -52,7 +52,6 @@ import java.util.WeakHashMap;
|
||||||
public class LatinKeyboardBaseView extends KeyboardView implements PointerTracker.KeyEventHandler {
|
public class LatinKeyboardBaseView extends KeyboardView implements PointerTracker.KeyEventHandler {
|
||||||
private static final String TAG = LatinKeyboardBaseView.class.getSimpleName();
|
private static final String TAG = LatinKeyboardBaseView.class.getSimpleName();
|
||||||
|
|
||||||
private static final boolean ENABLE_CAPSLOCK_BY_LONGPRESS = true;
|
|
||||||
private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = true;
|
private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = true;
|
||||||
|
|
||||||
// Timing constants
|
// Timing constants
|
||||||
|
@ -87,8 +86,7 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
|
||||||
implements TimerProxy {
|
implements TimerProxy {
|
||||||
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_LONGPRESS_SHIFT_KEY = 3;
|
private static final int MSG_IGNORE_DOUBLE_TAP = 3;
|
||||||
private static final int MSG_IGNORE_DOUBLE_TAP = 4;
|
|
||||||
|
|
||||||
private boolean mInKeyRepeat;
|
private boolean mInKeyRepeat;
|
||||||
|
|
||||||
|
@ -108,9 +106,6 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
|
||||||
case MSG_LONGPRESS_KEY:
|
case MSG_LONGPRESS_KEY:
|
||||||
keyboardView.openMiniKeyboardIfRequired(msg.arg1, tracker);
|
keyboardView.openMiniKeyboardIfRequired(msg.arg1, tracker);
|
||||||
break;
|
break;
|
||||||
case MSG_LONGPRESS_SHIFT_KEY:
|
|
||||||
keyboardView.onLongPressShiftKey(tracker);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,29 +126,19 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) {
|
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) {
|
||||||
cancelLongPressTimers();
|
cancelLongPressTimer();
|
||||||
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay);
|
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker) {
|
public void cancelLongPressTimer() {
|
||||||
cancelLongPressTimers();
|
|
||||||
if (ENABLE_CAPSLOCK_BY_LONGPRESS) {
|
|
||||||
sendMessageDelayed(
|
|
||||||
obtainMessage(MSG_LONGPRESS_SHIFT_KEY, keyIndex, 0, tracker), delay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelLongPressTimers() {
|
|
||||||
removeMessages(MSG_LONGPRESS_KEY);
|
removeMessages(MSG_LONGPRESS_KEY);
|
||||||
removeMessages(MSG_LONGPRESS_SHIFT_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelKeyTimers() {
|
public void cancelKeyTimers() {
|
||||||
cancelKeyRepeatTimer();
|
cancelKeyRepeatTimer();
|
||||||
cancelLongPressTimers();
|
cancelLongPressTimer();
|
||||||
removeMessages(MSG_IGNORE_DOUBLE_TAP);
|
removeMessages(MSG_IGNORE_DOUBLE_TAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,11 +340,6 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
|
||||||
return onLongPress(parentKey, tracker);
|
return onLongPress(parentKey, tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onLongPressShiftKey(PointerTracker tracker) {
|
|
||||||
tracker.onLongPressed();
|
|
||||||
mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDoubleTapShiftKey(@SuppressWarnings("unused") PointerTracker tracker) {
|
private void onDoubleTapShiftKey(@SuppressWarnings("unused") PointerTracker tracker) {
|
||||||
// When shift key is double tapped, the first tap is correctly processed as usual tap. And
|
// When shift key is double tapped, the first tap is correctly processed as usual tap. And
|
||||||
// the second tap is treated as this double tap event, so that we need not mark tracker
|
// the second tap is treated as this double tap event, so that we need not mark tracker
|
||||||
|
|
|
@ -95,13 +95,17 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
||||||
@Override
|
@Override
|
||||||
protected boolean onLongPress(Key key, PointerTracker tracker) {
|
protected boolean onLongPress(Key key, PointerTracker tracker) {
|
||||||
int primaryCode = key.mCode;
|
int primaryCode = key.mCode;
|
||||||
if (primaryCode == Keyboard.CODE_SETTINGS) {
|
if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
|
// Both long pressing settings key and space key invoke IME switcher dialog.
|
||||||
return invokeOnKey(Keyboard.CODE_SETTINGS_LONGPRESS);
|
return invokeOnKey(Keyboard.CODE_SETTINGS_LONGPRESS);
|
||||||
} else if (primaryCode == '0' && getLatinKeyboard().isPhoneKeyboard()) {
|
} else if (primaryCode == '0' && getLatinKeyboard().isPhoneKeyboard()) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
// Long pressing on 0 in phone number keypad gives you a '+'.
|
// Long pressing on 0 in phone number keypad gives you a '+'.
|
||||||
return invokeOnKey('+');
|
return invokeOnKey('+');
|
||||||
|
} else if (primaryCode == Keyboard.CODE_SHIFT) {
|
||||||
|
tracker.onLongPressed();
|
||||||
|
return invokeOnKey(Keyboard.CODE_CAPSLOCK);
|
||||||
} else {
|
} else {
|
||||||
return super.onLongPress(key, tracker);
|
return super.onLongPress(key, tracker);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,7 @@ public class PointerTracker {
|
||||||
public interface TimerProxy {
|
public interface TimerProxy {
|
||||||
public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker);
|
public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker);
|
||||||
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker);
|
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker);
|
||||||
public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker);
|
public void cancelLongPressTimer();
|
||||||
public void cancelLongPressTimers();
|
|
||||||
public void cancelKeyTimers();
|
public void cancelKeyTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +83,7 @@ public class PointerTracker {
|
||||||
private static int sDelayBeforeKeyRepeatStart;
|
private static int sDelayBeforeKeyRepeatStart;
|
||||||
private static int sLongPressKeyTimeout;
|
private static int sLongPressKeyTimeout;
|
||||||
private static int sLongPressShiftKeyTimeout;
|
private static int sLongPressShiftKeyTimeout;
|
||||||
|
private static int sLongPressSpaceKeyTimeout;
|
||||||
private static int sTouchNoiseThresholdMillis;
|
private static int sTouchNoiseThresholdMillis;
|
||||||
private static int sTouchNoiseThresholdDistanceSquared;
|
private static int sTouchNoiseThresholdDistanceSquared;
|
||||||
|
|
||||||
|
@ -165,6 +165,7 @@ public class PointerTracker {
|
||||||
sDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
|
sDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
|
||||||
sLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
|
sLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
|
||||||
sLongPressShiftKeyTimeout = res.getInteger(R.integer.config_long_press_shift_key_timeout);
|
sLongPressShiftKeyTimeout = res.getInteger(R.integer.config_long_press_shift_key_timeout);
|
||||||
|
sLongPressSpaceKeyTimeout = res.getInteger(R.integer.config_long_press_space_key_timeout);
|
||||||
sTouchNoiseThresholdMillis = res.getInteger(R.integer.config_touch_noise_threshold_millis);
|
sTouchNoiseThresholdMillis = res.getInteger(R.integer.config_touch_noise_threshold_millis);
|
||||||
final float touchNoiseThresholdDistance = res.getDimension(
|
final float touchNoiseThresholdDistance = res.getDimension(
|
||||||
R.dimen.config_touch_noise_threshold_distance);
|
R.dimen.config_touch_noise_threshold_distance);
|
||||||
|
@ -553,7 +554,7 @@ public class PointerTracker {
|
||||||
setReleasedKeyGraphics(oldKeyIndex);
|
setReleasedKeyGraphics(oldKeyIndex);
|
||||||
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
||||||
startSlidingKeyInput(oldKey);
|
startSlidingKeyInput(oldKey);
|
||||||
mTimerProxy.cancelLongPressTimers();
|
mTimerProxy.cancelLongPressTimer();
|
||||||
if (mIsAllowedSlidingKeyInput) {
|
if (mIsAllowedSlidingKeyInput) {
|
||||||
onMoveToNewKey(keyIndex, x, y);
|
onMoveToNewKey(keyIndex, x, y);
|
||||||
} else {
|
} else {
|
||||||
|
@ -720,7 +721,13 @@ public class PointerTracker {
|
||||||
private void startLongPressTimer(int keyIndex) {
|
private void startLongPressTimer(int keyIndex) {
|
||||||
Key key = getKey(keyIndex);
|
Key key = getKey(keyIndex);
|
||||||
if (key.mCode == Keyboard.CODE_SHIFT) {
|
if (key.mCode == Keyboard.CODE_SHIFT) {
|
||||||
mTimerProxy.startLongPressShiftTimer(sLongPressShiftKeyTimeout, keyIndex, this);
|
if (sLongPressShiftKeyTimeout > 0) {
|
||||||
|
mTimerProxy.startLongPressTimer(sLongPressShiftKeyTimeout, keyIndex, this);
|
||||||
|
}
|
||||||
|
} else if (key.mCode == Keyboard.CODE_SPACE) {
|
||||||
|
if (sLongPressSpaceKeyTimeout > 0) {
|
||||||
|
mTimerProxy.startLongPressTimer(sLongPressSpaceKeyTimeout, keyIndex, this);
|
||||||
|
}
|
||||||
} else if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) {
|
} else if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) {
|
||||||
// We need not start long press timer on the key which has manual temporary upper case
|
// We need not start long press timer on the key which has manual temporary upper case
|
||||||
// code defined and the keyboard is in manual temporary upper case mode.
|
// code defined and the keyboard is in manual temporary upper case mode.
|
||||||
|
|
|
@ -49,9 +49,7 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) {}
|
public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) {}
|
||||||
@Override
|
@Override
|
||||||
public void startLongPressShiftTimer(long delay, int keyIndex, PointerTracker tracker) {}
|
public void cancelLongPressTimer() {}
|
||||||
@Override
|
|
||||||
public void cancelLongPressTimers() {}
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelKeyTimers() {}
|
public void cancelKeyTimers() {}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue