diff options
author | 2010-08-24 18:27:47 -0700 | |
---|---|---|
committer | 2010-08-24 18:27:47 -0700 | |
commit | edadd2661b40979dc79b659e38ffe30059192693 (patch) | |
tree | 54b1c3df8dd098d9301619a9266825d439aa20e7 /java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java | |
parent | 525141a402ac9a3fb3495cb069ad25b9ba1fc970 (diff) | |
parent | 8b0cb128bec774057934d7b913c4358981b4d4d1 (diff) | |
download | latinime-edadd2661b40979dc79b659e38ffe30059192693.tar.gz latinime-edadd2661b40979dc79b659e38ffe30059192693.tar.xz latinime-edadd2661b40979dc79b659e38ffe30059192693.zip |
Merge "Refactor onModifiedTouchEvent of LatinKeyboardBaseView" into gingerbread
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 665c641c2..d22d88f10 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -205,7 +205,7 @@ 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 mPossiblePoly; + private boolean mCancelGestureDetector; private SwipeTracker mSwipeTracker = new SwipeTracker(); private int mSwipeThreshold; private boolean mDisambiguateSwipe; @@ -545,7 +545,7 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener @Override public boolean onFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY) { - if (mPossiblePoly) return false; + if (mCancelGestureDetector) return false; final float absX = Math.abs(velocityX); final float absY = Math.abs(velocityY); float deltaX = me2.getX() - me1.getX(); @@ -1279,68 +1279,70 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener boolean result = false; final long now = me.getEventTime(); + if (pointerCount > 1 && mOldPointerCount > 1) { + // Don't do anything when 2 or more pointers are down and moving. + return true; + } + + // Track the last few movements to look for spurious swipes. + if (action == MotionEvent.ACTION_DOWN) mSwipeTracker.clear(); + mSwipeTracker.addMovement(me); + + // Ignore all motion events until a DOWN. + if (mAbortKey + && action != MotionEvent.ACTION_DOWN && action != MotionEvent.ACTION_CANCEL) { + return true; + } + + mCancelGestureDetector = (pointerCount > 1); + if (mGestureDetector.onTouchEvent(me)) { + showPreview(NOT_A_KEY); + mHandler.cancelKeyTimers(); + return true; + } + + // Needs to be called after the gesture detector gets a turn, as it may have + // displayed the mini keyboard + if (mMiniKeyboardOnScreen && action != MotionEvent.ACTION_CANCEL) { + return true; + } + if (pointerCount != mOldPointerCount) { if (pointerCount == 1) { // Send a down event for the latest pointer MotionEvent down = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, me.getX(), me.getY(), me.getMetaState()); - result = onModifiedTouchEvent(down, false); + result = onModifiedTouchEvent(down); down.recycle(); // If it's an up action, then deliver the up as well. if (action == MotionEvent.ACTION_UP) { - result = onModifiedTouchEvent(me, true); + result = onModifiedTouchEvent(me); } } else { // Send an up event for the last pointer MotionEvent up = MotionEvent.obtain(now, now, MotionEvent.ACTION_UP, mOldPointerX, mOldPointerY, me.getMetaState()); - result = onModifiedTouchEvent(up, true); + result = onModifiedTouchEvent(up); up.recycle(); } + mOldPointerCount = pointerCount; } else { if (pointerCount == 1) { - result = onModifiedTouchEvent(me, false); + result = onModifiedTouchEvent(me); mOldPointerX = me.getX(); mOldPointerY = me.getY(); - } else { - // Don't do anything when 2 pointers are down and moving. - result = true; } } - mOldPointerCount = pointerCount; return result; } - private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) { + private boolean onModifiedTouchEvent(MotionEvent me) { int touchX = (int) me.getX() - getPaddingLeft(); int touchY = (int) me.getY() + mVerticalCorrection - getPaddingTop(); final int action = me.getAction(); final long eventTime = me.getEventTime(); int keyIndex = getKeyIndexAndNearbyCodes(touchX, touchY, null); - mPossiblePoly = possiblePoly; - - // Track the last few movements to look for spurious swipes. - if (action == MotionEvent.ACTION_DOWN) mSwipeTracker.clear(); - mSwipeTracker.addMovement(me); - - // Ignore all motion events until a DOWN. - if (mAbortKey - && action != MotionEvent.ACTION_DOWN && action != MotionEvent.ACTION_CANCEL) { - return true; - } - - if (mGestureDetector.onTouchEvent(me)) { - showPreview(NOT_A_KEY); - mHandler.cancelKeyTimers(); - return true; - } - - // Needs to be called after the gesture detector gets a turn, as it may have - // displayed the mini keyboard - if (mMiniKeyboardOnScreen && action != MotionEvent.ACTION_CANCEL) { - return true; - } switch (action) { case MotionEvent.ACTION_DOWN: |