Pass KeyboardView to PointerTracker on down event
Bug: 4768084 Change-Id: I446b98daef8c9ec2408481e59cb2a88754ef9e01main
parent
952266674a
commit
0efe174ea4
|
@ -200,7 +200,7 @@ public class AccessibleKeyboardViewProxy {
|
|||
}
|
||||
|
||||
private void fireKeyPressEvent(PointerTracker tracker, int x, int y, long eventTime) {
|
||||
tracker.onDownEvent(x, y, eventTime);
|
||||
tracker.onDownEvent(x, y, eventTime, mView);
|
||||
tracker.onUpEvent(x, y, eventTime + DELAY_KEY_PRESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.android.inputmethod.compat.FrameLayoutCompatUtils;
|
||||
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
||||
|
@ -72,7 +73,7 @@ import java.util.HashMap;
|
|||
* @attr ref R.styleable#KeyboardView_shadowColor
|
||||
* @attr ref R.styleable#KeyboardView_shadowRadius
|
||||
*/
|
||||
public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||
public abstract class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||
private static final boolean DEBUG_KEYBOARD_GRID = false;
|
||||
|
||||
// Miscellaneous constants
|
||||
|
@ -917,4 +918,23 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
super.onDetachedFromWindow();
|
||||
closing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get KeyDetector object that is used for the Keyboard of this KeyboardView.
|
||||
* @return the KeyDetector object that is used for the Keyboard
|
||||
*/
|
||||
public abstract KeyDetector getKeyDetector();
|
||||
|
||||
/**
|
||||
* Get KeyboardActionListener object that is used to register key code and so on.
|
||||
* @return the KeyboardActionListner for this KeyboardView
|
||||
*/
|
||||
public abstract KeyboardActionListener getKeyboardActionListener();
|
||||
|
||||
/**
|
||||
* Get TimerProxy object that handles key repeat and long press timer event for the Keyboard
|
||||
* of this KeyboardView.
|
||||
* @return the TimerProxy object that handles key repeat and long press timer event.
|
||||
*/
|
||||
public abstract TimerProxy getTimerProxy();
|
||||
}
|
||||
|
|
|
@ -267,10 +267,21 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
|||
* Returns the {@link KeyboardActionListener} object.
|
||||
* @return the listener attached to this keyboard
|
||||
*/
|
||||
protected KeyboardActionListener getKeyboardActionListener() {
|
||||
@Override
|
||||
public KeyboardActionListener getKeyboardActionListener() {
|
||||
return mKeyboardActionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyDetector getKeyDetector() {
|
||||
return mKeyDetector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimerProxy getTimerProxy() {
|
||||
return mKeyTimerHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
// TODO: Should notify InputMethodService instead?
|
||||
|
@ -545,7 +556,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
|||
// previous key.
|
||||
final int newKeyIndex = tracker.getKeyIndexOn(x, y);
|
||||
if (mOldKeyIndex != newKeyIndex) {
|
||||
tracker.onDownEvent(x, y, eventTime);
|
||||
tracker.onDownEvent(x, y, eventTime, this);
|
||||
if (action == MotionEvent.ACTION_UP)
|
||||
tracker.onUpEvent(x, y, eventTime);
|
||||
}
|
||||
|
@ -557,7 +568,7 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
|||
mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY);
|
||||
tracker.onUpEvent(lastX, lastY, eventTime);
|
||||
} else if (pointerCount == 1 && oldPointerCount == 1) {
|
||||
processMotionEvent(tracker, action, x, y, eventTime);
|
||||
processMotionEvent(tracker, action, x, y, eventTime, this);
|
||||
} else {
|
||||
Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount
|
||||
+ " (old " + oldPointerCount + ")");
|
||||
|
@ -571,18 +582,18 @@ public class LatinKeyboardBaseView extends KeyboardView {
|
|||
tracker.onMoveEvent((int)me.getX(i), (int)me.getY(i), eventTime);
|
||||
}
|
||||
} else {
|
||||
processMotionEvent(getPointerTracker(id), action, x, y, eventTime);
|
||||
processMotionEvent(getPointerTracker(id), action, x, y, eventTime, this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void processMotionEvent(PointerTracker tracker, int action, int x, int y,
|
||||
long eventTime) {
|
||||
long eventTime, KeyboardView keyboardView) {
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
tracker.onDownEvent(x, y, eventTime);
|
||||
tracker.onDownEvent(x, y, eventTime, keyboardView);
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.content.Context;
|
|||
import android.content.res.Resources;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
||||
|
@ -59,8 +58,8 @@ public class PointerTracker {
|
|||
private final int mLongPressKeyTimeout;
|
||||
private final int mLongPressShiftKeyTimeout;
|
||||
|
||||
private final DrawingProxy mDrawingProxy;
|
||||
private final TimerProxy mTimerProxy;
|
||||
private DrawingProxy mDrawingProxy;
|
||||
private TimerProxy mTimerProxy;
|
||||
private final PointerTrackerQueue mPointerTrackerQueue;
|
||||
private KeyDetector mKeyDetector;
|
||||
private KeyboardActionListener mListener = EMPTY_LISTENER;
|
||||
|
@ -330,10 +329,13 @@ public class PointerTracker {
|
|||
return onMoveKeyInternal(x, y);
|
||||
}
|
||||
|
||||
public void onDownEvent(int x, int y, long eventTime) {
|
||||
public void onDownEvent(int x, int y, long eventTime, KeyboardView keyboardView) {
|
||||
if (DEBUG_EVENT)
|
||||
printTouchEvent("onDownEvent:", x, y, eventTime);
|
||||
|
||||
mDrawingProxy = keyboardView;
|
||||
setKeyboardActionListener(keyboardView.getKeyboardActionListener());
|
||||
setKeyDetectorInner(keyboardView.getKeyDetector());
|
||||
// Naive up-to-down noise filter.
|
||||
final long deltaT = eventTime - mUpTime;
|
||||
if (deltaT < mTouchNoiseThresholdMillis) {
|
||||
|
|
Loading…
Reference in New Issue