diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 6b4e9469f..cf8458978 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -22,6 +22,7 @@ import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; import android.content.res.Resources; +import android.os.SystemClock; import android.util.Log; import android.view.MotionEvent; @@ -540,8 +541,11 @@ public class PointerTracker { public void onLongPressed(PointerTrackerQueue queue) { mKeyAlreadyProcessed = true; - if (queue != null) + if (queue != null) { + // TODO: Support chording + long-press input. + queue.releaseAllPointersExcept(this, SystemClock.uptimeMillis(), true); queue.remove(this); + } } public void onCancelEvent(int x, int y, long eventTime, PointerTrackerQueue queue) { diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java index 60d87f789..ff64c73cd 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java @@ -37,7 +37,6 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { private int mOriginX; private int mOriginY; - private int mTrackerId; private long mDownTime; public PopupMiniKeyboardView(Context context, AttributeSet attrs) { @@ -98,30 +97,19 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { mOriginX = x + container.getPaddingLeft() - mCoordinates[0]; mOriginY = y + container.getPaddingTop() - mCoordinates[1]; - mTrackerId = tracker.mPointerId; mDownTime = SystemClock.uptimeMillis(); // Inject down event on the key to mini keyboard. - final MotionEvent downEvent = translateMotionEvent(MotionEvent.ACTION_DOWN, pointX, - pointY + parentKey.mHeight / 2, mDownTime); + final MotionEvent downEvent = MotionEvent.obtain(mDownTime, mDownTime, + MotionEvent.ACTION_DOWN, pointX - mOriginX, + pointY + parentKey.mHeight / 2 - mOriginY, 0); onTouchEvent(downEvent); downEvent.recycle(); } - private MotionEvent translateMotionEvent(int action, float x, float y, long eventTime) { - return MotionEvent.obtain(mDownTime, eventTime, action, x - mOriginX, y - mOriginY, 0); - } - @Override public boolean onTouchEvent(MotionEvent me) { - final int index = me.getActionIndex(); - final int id = me.getPointerId(index); - if (id == mTrackerId) { - final MotionEvent translated = translateMotionEvent(me.getAction(), me.getX(index), - me.getY(index), me.getEventTime()); - super.onTouchEvent(translated); - translated.recycle(); - } - return true; + me.offsetLocation(-mOriginX, -mOriginY); + return super.onTouchEvent(me); } }