Skip to content

Commit a99fb0a

Browse files
committed
fix(KeyboardView): multpoint touch wrongly recognized as swipe
1 parent 04c9591 commit a99fb0a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public interface OnKeyboardActionListener {
165165
private int mStartX;
166166
private int mStartY;
167167
private int touchX0, touchY0;
168+
private boolean touchOnePoint;
168169

169170
private boolean mProximityCorrectOn;
170171

@@ -1356,6 +1357,7 @@ else if (action == MotionEvent.ACTION_UP)
13561357
case MotionEvent.ACTION_DOWN:
13571358
touchX0 = touchX;
13581359
touchY0 = touchY;
1360+
touchOnePoint = true;
13591361
case MotionEvent.ACTION_POINTER_DOWN:
13601362
mAbortKey = false;
13611363
mStartX = touchX;
@@ -1369,6 +1371,7 @@ else if (action == MotionEvent.ACTION_UP)
13691371
mDownKey = keyIndex;
13701372
mDownTime = me.getEventTime();
13711373
mLastMoveTime = mDownTime;
1374+
touchOnePoint = false;
13721375
if (action == MotionEvent.ACTION_POINTER_DOWN) break; // 並擊鬆開前的虛擬按鍵事件
13731376
checkMultiTap(eventTime, keyIndex);
13741377
mKeyboardActionListener.onPress(keyIndex != NOT_A_KEY ? mKeys[keyIndex].getCode() : 0);
@@ -1444,7 +1447,7 @@ else if (action == MotionEvent.ACTION_UP)
14441447
int absY = Math.abs(dy);
14451448
int travel = getPrefs().getKeyboard().getSwipeTravel();
14461449

1447-
if (Math.max(absY, absX) > travel) {
1450+
if (Math.max(absY, absX) > travel && touchOnePoint) {
14481451
int type;
14491452
if (absX < absY) {
14501453
Timber.d("swipeDebug.ext y, dX=%d, dY=%d", dx, dy);

0 commit comments

Comments
 (0)