diff options
author | 2010-08-26 15:22:18 +0900 | |
---|---|---|
committer | 2010-08-26 15:54:50 +0900 | |
commit | 0c5480989186c884a1a296ac2f46132235d02d45 (patch) | |
tree | 8ff08ca67ad771252fba60959d2f7f138fce91ef /java/src | |
parent | 0d098c514eac2da144dcb856d9aa870bbe5be8c8 (diff) | |
download | latinime-0c5480989186c884a1a296ac2f46132235d02d45.tar.gz latinime-0c5480989186c884a1a296ac2f46132235d02d45.tar.xz latinime-0c5480989186c884a1a296ac2f46132235d02d45.zip |
Refactor gesture detector logic
GestureDetector listener's onFling method will not call detectAndSendKey
anymore.
Make gesture detector be ignoring multitouch. Refactoring
GestureDetector out of LatinKeyboardBaseView class change will follow.
Bug: 2910379
Change-Id: I0b2a9c4cf7d432f89f9085f3c2bdf3a3757a8903
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 8e55c8e3c..8a8a12c80 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -204,7 +204,6 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener private boolean mAbortKey; private Key mInvalidatedKey; private Rect mClipRegion = new Rect(0, 0, 0, 0); - private boolean mCancelGestureDetector; private SwipeTracker mSwipeTracker = new SwipeTracker(); private int mSwipeThreshold; private boolean mDisambiguateSwipe; @@ -544,12 +543,11 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener } private void initGestureDetector() { - mGestureDetector = new GestureDetector( - getContext(), new GestureDetector.SimpleOnGestureListener() { + GestureDetector.SimpleOnGestureListener listener = + new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY) { - if (mCancelGestureDetector) return false; final float absX = Math.abs(velocityX); final float absY = Math.abs(velocityY); float deltaX = me2.getX() - me1.getX(); @@ -559,44 +557,33 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener mSwipeTracker.computeCurrentVelocity(1000); final float endingVelocityX = mSwipeTracker.getXVelocity(); final float endingVelocityY = mSwipeTracker.getYVelocity(); - boolean sendDownKey = false; if (velocityX > mSwipeThreshold && absY < absX && deltaX > travelX) { - if (mDisambiguateSwipe && endingVelocityX < velocityX / 4) { - sendDownKey = true; - } else { + if (mDisambiguateSwipe && endingVelocityX >= velocityX / 4) { swipeRight(); return true; } } else if (velocityX < -mSwipeThreshold && absY < absX && deltaX < -travelX) { - if (mDisambiguateSwipe && endingVelocityX > velocityX / 4) { - sendDownKey = true; - } else { + if (mDisambiguateSwipe && endingVelocityX <= velocityX / 4) { swipeLeft(); return true; } } else if (velocityY < -mSwipeThreshold && absX < absY && deltaY < -travelY) { - if (mDisambiguateSwipe && endingVelocityY > velocityY / 4) { - sendDownKey = true; - } else { + if (mDisambiguateSwipe && endingVelocityY <= velocityY / 4) { swipeUp(); return true; } } else if (velocityY > mSwipeThreshold && absX < absY / 2 && deltaY > travelY) { - if (mDisambiguateSwipe && endingVelocityY < velocityY / 4) { - sendDownKey = true; - } else { + if (mDisambiguateSwipe && endingVelocityY >= velocityY / 4) { swipeDown(); return true; } } - - if (sendDownKey) { - detectAndSendKey(mDownKey, mStartX, mStartY, me1.getEventTime()); - } return false; } - }); + }; + final boolean ignoreMultitouch = true; + mGestureDetector = new GestureDetector(getContext(), listener, null, ignoreMultitouch); mGestureDetector.setIsLongpressEnabled(false); } @@ -1299,7 +1286,6 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener return true; } - mCancelGestureDetector = (pointerCount > 1); if (mGestureDetector.onTouchEvent(me)) { showPreview(NOT_A_KEY); mHandler.cancelKeyTimers(); |