mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 05:52:47 +00:00
make arrow keys repeatable (#932)
only applies to keyboard keys, not in toolbar
This commit is contained in:
parent
74571a3202
commit
a92d108444
4 changed files with 24 additions and 7 deletions
|
@ -1171,13 +1171,17 @@ public class Key implements Comparable<Key> {
|
|||
if (mCode <= Constants.CODE_SPACE && mCode != KeyCode.MULTIPLE_CODE_POINTS && mIconName == null)
|
||||
actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW;
|
||||
switch (mCode) {
|
||||
case KeyCode.DELETE, KeyCode.SHIFT, Constants.CODE_ENTER, KeyCode.SHIFT_ENTER, KeyCode.ALPHA, Constants.CODE_SPACE, KeyCode.NUMPAD,
|
||||
KeyCode.SYMBOL, KeyCode.SYMBOL_ALPHA, KeyCode.LANGUAGE_SWITCH, KeyCode.EMOJI, KeyCode.CLIPBOARD -> actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW; // no preview even if icon!
|
||||
case KeyCode.DELETE, KeyCode.ARROW_LEFT, KeyCode.ARROW_RIGHT, KeyCode.ARROW_UP, KeyCode.ARROW_DOWN:
|
||||
// repeating is disabled if a key is configured with pop-ups
|
||||
if (mPopupKeys == null)
|
||||
actionFlags |= ACTION_FLAGS_IS_REPEATABLE;
|
||||
// fallthrough
|
||||
case KeyCode.SHIFT, Constants.CODE_ENTER, KeyCode.SHIFT_ENTER, KeyCode.ALPHA, Constants.CODE_SPACE, KeyCode.NUMPAD,
|
||||
KeyCode.SYMBOL, KeyCode.SYMBOL_ALPHA, KeyCode.LANGUAGE_SWITCH, KeyCode.EMOJI, KeyCode.CLIPBOARD:
|
||||
actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW; // no preview even if icon!
|
||||
}
|
||||
if (mCode == KeyCode.SETTINGS || mCode == KeyCode.LANGUAGE_SWITCH)
|
||||
actionFlags |= ACTION_FLAGS_ALT_CODE_WHILE_TYPING;
|
||||
if (mCode == KeyCode.DELETE)
|
||||
actionFlags |= ACTION_FLAGS_IS_REPEATABLE;
|
||||
mActionFlags = actionFlags;
|
||||
|
||||
final int altCodeInAttr; // settings and language switch keys have alt code space, all others nothing
|
||||
|
|
|
@ -1731,9 +1731,16 @@ public class LatinIME extends InputMethodService implements
|
|||
return;
|
||||
}
|
||||
if (repeatCount > 0) {
|
||||
if (code == KeyCode.DELETE && !mInputLogic.mConnection.canDeleteCharacters()) {
|
||||
// No need to feedback when repeat delete key will have no effect.
|
||||
return;
|
||||
// No need to feedback when repeat delete/cursor keys will have no effect.
|
||||
switch (code) {
|
||||
case KeyCode.DELETE, KeyCode.ARROW_LEFT, KeyCode.ARROW_UP:
|
||||
if (!mInputLogic.mConnection.canDeleteCharacters())
|
||||
return;
|
||||
break;
|
||||
case KeyCode.ARROW_RIGHT, KeyCode.ARROW_DOWN:
|
||||
if (!mInputLogic.mConnection.canForwardDeleteCharacters())
|
||||
return;
|
||||
break;
|
||||
}
|
||||
// TODO: Use event time that the last feedback has been generated instead of relying on
|
||||
// a repeat count to thin out feedback.
|
||||
|
|
|
@ -363,6 +363,11 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
|||
return mExpectedSelStart > 0;
|
||||
}
|
||||
|
||||
public boolean canForwardDeleteCharacters() {
|
||||
final CharSequence after = getTextAfterCursor(1, 0);
|
||||
return !TextUtils.isEmpty(after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the caps modes we should be in after this specific string.
|
||||
* <p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue