Skip to content

Commit

Permalink
fix(KeyboardView): multpoint touch wrongly recognized as swipe
Browse files Browse the repository at this point in the history
  • Loading branch information
tumuyan committed Oct 25, 2021
1 parent 04c9591 commit a99fb0a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public interface OnKeyboardActionListener {
private int mStartX;
private int mStartY;
private int touchX0, touchY0;
private boolean touchOnePoint;

private boolean mProximityCorrectOn;

Expand Down Expand Up @@ -1356,6 +1357,7 @@ else if (action == MotionEvent.ACTION_UP)
case MotionEvent.ACTION_DOWN:
touchX0 = touchX;
touchY0 = touchY;
touchOnePoint = true;
case MotionEvent.ACTION_POINTER_DOWN:
mAbortKey = false;
mStartX = touchX;
Expand All @@ -1369,6 +1371,7 @@ else if (action == MotionEvent.ACTION_UP)
mDownKey = keyIndex;
mDownTime = me.getEventTime();
mLastMoveTime = mDownTime;
touchOnePoint = false;
if (action == MotionEvent.ACTION_POINTER_DOWN) break; // 並擊鬆開前的虛擬按鍵事件
checkMultiTap(eventTime, keyIndex);
mKeyboardActionListener.onPress(keyIndex != NOT_A_KEY ? mKeys[keyIndex].getCode() : 0);
Expand Down Expand Up @@ -1444,7 +1447,7 @@ else if (action == MotionEvent.ACTION_UP)
int absY = Math.abs(dy);
int travel = getPrefs().getKeyboard().getSwipeTravel();

if (Math.max(absY, absX) > travel) {
if (Math.max(absY, absX) > travel && touchOnePoint) {
int type;
if (absX < absY) {
Timber.d("swipeDebug.ext y, dX=%d, dY=%d", dx, dy);
Expand Down

0 comments on commit a99fb0a

Please sign in to comment.