More processTouchEvent from LatinKeyboardView to PointerTracker

Bug: 5241105
Change-Id: I8a5d15f43e2c9f294e78127eda68b0f85da5ad15
main
Tadashi G. Takaoka 2011-09-06 15:25:58 +09:00
parent ea0c567f86
commit 8ac6d505b7
3 changed files with 32 additions and 41 deletions

View File

@ -552,7 +552,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY);
tracker.onUpEvent(lastX, lastY, eventTime);
} else if (pointerCount == 1 && oldPointerCount == 1) {
processMotionEvent(tracker, action, x, y, eventTime, this);
tracker.processMotionEvent(action, x, y, eventTime, this);
} else {
Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount
+ " (old " + oldPointerCount + ")");
@ -575,32 +575,12 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
tracker.onMoveEvent(px, py, eventTime);
}
} else {
processMotionEvent(getPointerTracker(id), action, x, y, eventTime, this);
getPointerTracker(id).processMotionEvent(action, x, y, eventTime, this);
}
return true;
}
private static void processMotionEvent(PointerTracker tracker, int action, int x, int y,
long eventTime, PointerTracker.KeyEventHandler handler) {
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
tracker.onDownEvent(x, y, eventTime, handler);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
tracker.onUpEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_MOVE:
tracker.onMoveEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_CANCEL:
tracker.onCancelEvent(x, y, eventTime);
break;
}
}
@Override
public void closing() {
super.closing();

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.TextView;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
@ -398,6 +399,26 @@ public class PointerTracker {
return onMoveKeyInternal(x, y);
}
public void processMotionEvent(int action, int x, int y, long eventTime,
KeyEventHandler handler) {
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
onDownEvent(x, y, eventTime, handler);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
onUpEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_MOVE:
onMoveEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_CANCEL:
onCancelEvent(x, y, eventTime);
break;
}
}
public void onDownEvent(int x, int y, long eventTime, KeyEventHandler handler) {
if (DEBUG_EVENT)
printTouchEvent("onDownEvent:", x, y, eventTime);

View File

@ -762,29 +762,19 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
if (!mMoreSuggestionsWindow.isShowing()) {
return super.dispatchTouchEvent(me);
}
final MoreKeysPanel moreKeysPanel = mMoreSuggestionsView;
final int action = me.getAction();
final long eventTime = me.getEventTime();
final int index = me.getActionIndex();
final int id = me.getPointerId(index);
final PointerTracker tracker = PointerTracker.getPointerTracker(id, mMoreSuggestionsView);
final int x = mMoreSuggestionsView.translateX((int)me.getX(index));
final int y = mMoreSuggestionsView.translateY((int)me.getY(index));
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
tracker.onDownEvent(x, y, eventTime, mMoreSuggestionsView);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
tracker.onUpEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_MOVE:
tracker.onMoveEvent(x, y, eventTime);
break;
case MotionEvent.ACTION_CANCEL:
tracker.onCancelEvent(x, y, eventTime);
break;
}
final PointerTracker tracker = PointerTracker.getPointerTracker(id, moreKeysPanel);
final int x = (int)me.getX(index);
final int y = (int)me.getY(index);
final int translatedX = moreKeysPanel.translateX(x);
final int translatedY = moreKeysPanel.translateY(y);
tracker.processMotionEvent(action, translatedX, translatedY, eventTime, moreKeysPanel);
return true;
}