reduce sensitivty of space / delete gestures

This commit is contained in:
Helium314 2022-03-12 18:13:57 +01:00 committed by GitHub
parent 25d5510f18
commit 8938e2d3ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,8 @@
package org.dslul.openboard.inputmethod.keyboard; package org.dslul.openboard.inputmethod.keyboard;
import static java.lang.Math.abs;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.os.SystemClock; import android.os.SystemClock;
@ -907,7 +909,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (oldKey != null && oldKey.getCode() == Constants.CODE_SPACE && Settings.getInstance().getCurrent().mSpaceTrackpadEnabled) { if (oldKey != null && oldKey.getCode() == Constants.CODE_SPACE && Settings.getInstance().getCurrent().mSpaceTrackpadEnabled) {
//Pointer slider //Pointer slider
int steps = (x - mStartX) / sPointerStep; int steps = (x - mStartX) / sPointerStep;
final int longpressTimeout = Settings.getInstance().getCurrent().mKeyLongpressTimeout / MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT; final int longpressTimeout = 2 * Settings.getInstance().getCurrent().mKeyLongpressTimeout / MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT;
if (steps != 0 && mStartTime + longpressTimeout < System.currentTimeMillis()) { if (steps != 0 && mStartTime + longpressTimeout < System.currentTimeMillis()) {
mCursorMoved = true; mCursorMoved = true;
mStartX += steps * sPointerStep; mStartX += steps * sPointerStep;
@ -919,7 +921,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (oldKey != null && oldKey.getCode() == Constants.CODE_DELETE && Settings.getInstance().getCurrent().mDeleteSwipeEnabled) { if (oldKey != null && oldKey.getCode() == Constants.CODE_DELETE && Settings.getInstance().getCurrent().mDeleteSwipeEnabled) {
//Delete slider //Delete slider
int steps = (x - mStartX) / sPointerStep; int steps = (x - mStartX) / sPointerStep;
if (steps != 0) { if (abs(steps) > 2 || (mCursorMoved && steps != 0)) {
sTimerProxy.cancelKeyTimersOf(this); sTimerProxy.cancelKeyTimersOf(this);
mCursorMoved = true; mCursorMoved = true;
mStartX += steps * sPointerStep; mStartX += steps * sPointerStep;