long-press symbols key for numpad

issue: immediately switches to symbols layout, after delay switches to numpad
This commit is contained in:
Helium314 2024-02-01 09:25:37 +01:00
parent 21254d895c
commit eb7333b1da
5 changed files with 18 additions and 9 deletions

View file

@ -1159,7 +1159,10 @@ public class Key implements Comparable<Key> {
}
// action flags don't need to be specified, they can be deduced from the key
if (backgroundType == BACKGROUND_TYPE_SPACEBAR || mCode == Constants.CODE_LANGUAGE_SWITCH)
if (backgroundType == BACKGROUND_TYPE_SPACEBAR
|| mCode == Constants.CODE_LANGUAGE_SWITCH
|| (mCode == CODE_SWITCH_ALPHA_SYMBOL && !params.mId.isAlphabetKeyboard())
)
actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS;
if (mCode <= Constants.CODE_SPACE && mCode != CODE_OUTPUT_TEXT)
actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW;

View file

@ -310,8 +310,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// Note that we need primaryCode argument because the keyboard may be in shifted state and the
// primaryCode is different from {@link Key#mKeyCode}.
private void callListenerOnRelease(final Key key, final int primaryCode,
final boolean withSliding) {
private void callListenerOnRelease(final Key key, final int primaryCode, final boolean withSliding) {
// See the comment at {@link #callListenerOnPressAndCheckKeyboardLayoutChange(Key}}.
if (sInGesture || mIsDetectingGesture || mIsTrackingForActionDisabled) {
return;
@ -1104,7 +1103,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
return;
}
final int code = key.getCode();
if (code == Constants.CODE_SPACE&&Settings.getInstance().getCurrent().mSpaceForLangChange || code == Constants.CODE_LANGUAGE_SWITCH) {
if (code == Constants.CODE_LANGUAGE_SWITCH
|| (code == Constants.CODE_SPACE && Settings.getInstance().getCurrent().mSpaceForLangChange)
) {
// Long pressing the space key invokes IME switcher dialog.
if (sListener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) {
cancelKeyTracking();
@ -1112,8 +1113,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
return;
}
}
if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
sListener.onCodeInput(Constants.CODE_NUMPAD, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);
return;
}
setReleasedKeyGraphics(key, false /* withAnimation */);
setReleasedKeyGraphics(key, false);
final MoreKeysPanel moreKeysPanel = sDrawingProxy.showMoreKeysKeyboard(key, this);
if (moreKeysPanel == null) {
return;
@ -1159,8 +1164,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
return true;
}
// Here curKey points to the different key from newKey.
final int keyHysteresisDistanceSquared = mKeyDetector.getKeyHysteresisDistanceSquared(
mIsInSlidingKeyInput);
final int keyHysteresisDistanceSquared = mKeyDetector.getKeyHysteresisDistanceSquared(mIsInSlidingKeyInput);
final int distanceFromKeyEdgeSquared = curKey.squaredDistanceToEdge(x, y);
if (distanceFromKeyEdgeSquared >= keyHysteresisDistanceSquared) {
if (DEBUG_MODE) {

View file

@ -18,7 +18,7 @@
<string name="enable_split_keyboard" msgid="4177264923999493614">"Enable split keyboard"</string>
<string name="language_switch_key_switch_input_method" msgid="4533689960308565519">"Switch to other input methods"</string>
<string name="show_language_switch_key" msgid="5915478828318774384">"Language switch key"</string>
<string name="abbreviation_unit_milliseconds" msgid="8700286094028323363">"<xliff:g id="MILLISECONDS">%s</xliff:g>ms"</string>
<string name="abbreviation_unit_milliseconds" msgid="8700286094028323363">"<xliff:g id="MILLISECONDS">%s</xliff:g> ms"</string>
<string name="settings_system_default" msgid="6268225104743331821">"System default"</string>
<string name="use_contacts_dict" msgid="4435317977804180815">"Suggest Contact names"</string>
<string name="use_contacts_dict_summary">"Use names from Contacts for suggestions and corrections"</string>
@ -150,7 +150,7 @@
<string name="prefs_long_press_keyboard_to_change_lang_summary">Long pressing space key will prompt input method selection menu</string>
<string name="settings_no_limit">No limit</string>
<string name="settings_category_clipboard_history">Clipboard history</string>
<string name="abbreviation_unit_minutes"><xliff:g id="MINUTES">%s</xliff:g>min.</string>
<string name="abbreviation_unit_minutes"><xliff:g id="MINUTES">%s</xliff:g> min</string>
<string name="enable_clipboard_history">Enable clipboard history</string>
<string name="enable_clipboard_history_summary">If disabled, clipboard key will paste clipboard content if any</string>
<string name="clipboard_history_retention_time">History retention time</string>