mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-25 11:22:20 +00:00
only use alt-code-while-typing when not clearly inside key
and add alt code to emoji and clipboard keys fixes #630
This commit is contained in:
parent
181ea3b586
commit
61cff40d3c
2 changed files with 15 additions and 2 deletions
|
@ -524,6 +524,13 @@ public class Key implements Comparable<Key> {
|
|||
return (mActionFlags & ACTION_FLAGS_NO_KEY_PREVIEW) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* altCodeWhileTyping is a weird thing.
|
||||
* When user pressed a typing key less than ignoreAltCodeKeyTimeout (config_ignore_alt_code_key_timeout / 350 ms) ago,
|
||||
* this code will be used instead. There is no documentation, but it appears the purpose is to avoid unintentional layout switches.
|
||||
* Assuming this is true, the key still is used now if pressed near the center, where we assume it's less likely to be accidental.
|
||||
* See PointerTracker.isClearlyInsideKey
|
||||
*/
|
||||
public final boolean altCodeWhileTyping() {
|
||||
return (mActionFlags & ACTION_FLAGS_ALT_CODE_WHILE_TYPING) != 0;
|
||||
}
|
||||
|
@ -1165,7 +1172,7 @@ public class Key implements Comparable<Key> {
|
|||
mActionFlags = actionFlags;
|
||||
|
||||
final int altCodeInAttr; // settings and language switch keys have alt code space, all others nothing
|
||||
if (mCode == KeyCode.SETTINGS || mCode == KeyCode.LANGUAGE_SWITCH)
|
||||
if (mCode == KeyCode.SETTINGS || mCode == KeyCode.LANGUAGE_SWITCH || mCode == KeyCode.EMOJI || mCode == KeyCode.CLIPBOARD)
|
||||
altCodeInAttr = Constants.CODE_SPACE;
|
||||
else
|
||||
altCodeInAttr = KeyCode.NOT_SPECIFIED;
|
||||
|
|
|
@ -270,7 +270,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
private void callListenerOnCodeInput(final Key key, final int primaryCode, final int x,
|
||||
final int y, final long eventTime, final boolean isKeyRepeat) {
|
||||
final boolean ignoreModifierKey = mIsInDraggingFinger && key.isModifier();
|
||||
final boolean altersCode = key.altCodeWhileTyping() && sTimerProxy.isTypingState();
|
||||
final boolean altersCode = key.altCodeWhileTyping() && sTimerProxy.isTypingState() && !isClearlyInsideKey(key, x, y);
|
||||
final int code = altersCode ? key.getAltCode() : primaryCode;
|
||||
if (DEBUG_LISTENER) {
|
||||
final String output = code == KeyCode.MULTIPLE_CODE_POINTS
|
||||
|
@ -1186,6 +1186,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
return longpressTimeout;
|
||||
}
|
||||
|
||||
private boolean isClearlyInsideKey(final Key key, final int x, final int y) {
|
||||
// less than 15% of width from edge
|
||||
return x > key.getX() + key.getWidth() * 0.15 && x < key.getX() + key.getWidth() * 0.85
|
||||
&& y > key.getY() + key.getHeight() * 0.15 && y < key.getY() + key.getHeight() * 0.85;
|
||||
}
|
||||
|
||||
private void detectAndSendKey(final Key key, final int x, final int y, final long eventTime) {
|
||||
if (key == null) {
|
||||
callListenerOnCancelInput();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue