feat: Add spacebar language-swipe sensitivity setting - #2131
feat: Add spacebar language-swipe sensitivity setting#2131skorokithakis wants to merge 2 commits into
Conversation
The spacebar language-switch swipe used a hardcoded 128dp step. Expose it as an adjustable distance on the Spacebar settings screen; the default keeps the original behaviour.
|
i think this has a weird edge case though, it's possible to change layouts multiple times in one swipe. Because now I either have a low enough sensitivity so that never happens (but that's a trade-off because i can't make it trigger as fast as i want) or i just have to not swipe for too long. |
|
Ahh you're right, thanks, I'll test and make it only switch once. |
|
this patch makes it work as a latch, so that it only switches one layout at time diff --git a/java/src/org/futo/inputmethod/keyboard/PointerTracker.java b/java/src/org/futo/inputmethod/keyboard/PointerTracker.java
--- a/java/src/org/futo/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/org/futo/inputmethod/keyboard/PointerTracker.java
@@ -156,6 +156,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private boolean mStartedOnFastLongPress;
private boolean mCursorMoved = false;
private boolean mSpacebarLongPressed = false;
+ private boolean mSpacebarLanguageSwipeTriggered = false;
// true if keyboard layout has been changed.
private boolean mKeyboardLayoutHasBeenChanged;
@@ -757,6 +758,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
mStartTime = System.currentTimeMillis();
mStartedOnFastLongPress = key.isFastLongPress();
mSpacebarLongPressed = false;
+ mSpacebarLanguageSwipeTriggered = false;
mIsSlidingCursor = key.getCode() == Constants.CODE_DELETE || key.getCode() == Constants.CODE_SPACE;
mIsFlickingKey = !mIsSlidingCursor && key.getHasFlick();
@@ -973,28 +975,36 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|| (!mSpacebarLongPressed && settingsValues.mSpacebarSwipeMode != Settings.SPACEBAR_MODE_OFF);
if(allowedBySettings) {
+ final boolean isLanguageSwipe = settingsValues.mSpacebarSwipeMode == Settings.SPACEBAR_MODE_LANGUAGE
+ && !mSpacebarLongPressed;
int pointerStep = sPointerStep;
- if (settingsValues.mSpacebarSwipeMode == Settings.SPACEBAR_MODE_LANGUAGE && !mSpacebarLongPressed) {
+ if (isLanguageSwipe) {
// The language-switch step distance is user-configurable in dp. The
// widthPixels*3/2 clamp is a safety bound for narrow screens.
final DisplayMetrics displayMetrics =
Resources.getSystem().getDisplayMetrics();
pointerStep = Integer.min(
(int)(settingsValues.mSpacebarLanguageSwipeStepDp * displayMetrics.density),
displayMetrics.widthPixels * 3 / 2
);
}
int steps = (x - mStartX) / pointerStep;
final int swipeIgnoreTime = settingsValues.mKeyLongpressTimeout / MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT;
if (steps != 0 && mStartTime + swipeIgnoreTime < System.currentTimeMillis()) {
- mCursorMoved = true;
- mStartX += steps * pointerStep;
-
- if (settingsValues.mSpacebarSwipeMode == Settings.SPACEBAR_MODE_LANGUAGE && !mSpacebarLongPressed) {
- sListener.onSwipeLanguage(steps);
+ if (isLanguageSwipe) {
+ if (!mSpacebarLanguageSwipeTriggered) {
+ mCursorMoved = true;
+ mSpacebarLanguageSwipeTriggered = true;
+ sListener.onSwipeLanguage(steps > 0 ? 1 : -1);
+ }
} else {
+ mCursorMoved = true;
+ mStartX += steps * pointerStep;
sListener.onMovePointer(steps);
}
}
|
|
I've implemented the gating on a single language. I'm not sure what the original intent was (to be able to switch multiple languages or not), but it seems more confusing to be able to switch more than one language, so I've added the constraint here, especially since the added sensitivity makes it very easy to overshoot. |
|
Do you think it would make more sense to adjust the default rather than adding an option for this? It feels like it would be a strangely specific setting |
|
Depends on how the maintainers want it. |
|
@skorokithakis @FarisZR What values have you guys settled on for the setting? |
|
72 DPI for me. |
|
I have it set to the minimum, so 24dp, because now we don't have that bug that switches multiple times in one swipe and i want it to react asap.
Still doesn't feel as seamless as something like Swiftkey, but it's much better now.
…-------- Original Message --------
On Monday, 06/29/26 at 15:31 abb128 - notifications at github.com ***@***.***> wrote:
abb128 left a comment [(futo-org/android-keyboard#2131)](#2131 (comment))
***@***.***(https://github.com/skorokithakis) ***@***.***(https://github.com/FarisZR) What values have you guys settled on for the setting?
—
Reply to this email directly, [view it on GitHub](#2131?email_source=notifications&email_token=AIPXADTMR7QF6OHOXVLK6R35CJVRHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOBTGMYTIOBWGMYKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4833148630), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AIPXADQGB2XQTF7HOFMC3L35CJVRHAVCNFSNUABFKJSXA33TNF2G64TZHM3TSNZTG4ZDENRUHNEXG43VMU5TINZUHAYTAMZVGQ4KC5QC).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
|
Please try nightly 0.1.29.1-3-g9f05e86ac and tell me what you think. I added some visual and haptic feedback, made the switch more instantaneous, and reduced the threshold to 64dp |
|
64dp is still too much imo, at least from trying out this PR, i haven't tested your version yet
… |
The spacebar language-switch swipe used a hardcoded 128dp step. I exposed it as an adjustable distance on the Spacebar settings screen with an 128dp default.