Merge "Add KeyEventHandler interface"

main
Tadashi G. Takaoka 2011-07-11 10:54:31 -07:00 committed by Android (Google) Code Review
commit 08eea95650
5 changed files with 45 additions and 32 deletions

View File

@ -29,7 +29,7 @@ import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
import com.android.inputmethod.compat.MotionEventCompatUtils;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
import com.android.inputmethod.keyboard.PointerTracker;
public class AccessibleKeyboardViewProxy {
@ -40,7 +40,7 @@ public class AccessibleKeyboardViewProxy {
private static final long DELAY_KEY_PRESS = 10;
private int mScaledEdgeSlop;
private KeyboardView mView;
private LatinKeyboardBaseView mView;
private AccessibleKeyboardActionListener mListener;
private FlickGestureDetector mGestureDetector;
@ -57,7 +57,7 @@ public class AccessibleKeyboardViewProxy {
return sInstance;
}
public static void setView(KeyboardView view) {
public static void setView(LatinKeyboardBaseView view) {
sInstance.mView = view;
}

View File

@ -38,7 +38,6 @@ 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;
@ -73,7 +72,7 @@ import java.util.HashMap;
* @attr ref R.styleable#KeyboardView_shadowColor
* @attr ref R.styleable#KeyboardView_shadowRadius
*/
public abstract class KeyboardView extends View implements PointerTracker.DrawingProxy {
public class KeyboardView extends View implements PointerTracker.DrawingProxy {
private static final boolean DEBUG_KEYBOARD_GRID = false;
// Miscellaneous constants
@ -918,23 +917,4 @@ public abstract class KeyboardView extends View implements PointerTracker.Drawin
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();
}

View File

@ -33,6 +33,7 @@ import android.widget.PopupWindow;
import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
@ -49,7 +50,7 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#KeyboardView_verticalCorrection
* @attr ref R.styleable#KeyboardView_popupLayout
*/
public class LatinKeyboardBaseView extends KeyboardView {
public class LatinKeyboardBaseView extends KeyboardView implements PointerTracker.KeyEventHandler {
private static final String TAG = LatinKeyboardBaseView.class.getSimpleName();
private static final boolean ENABLE_CAPSLOCK_BY_LONGPRESS = true;
@ -277,6 +278,11 @@ public class LatinKeyboardBaseView extends KeyboardView {
return mKeyDetector;
}
@Override
public DrawingProxy getDrawingProxy() {
return this;
}
@Override
public TimerProxy getTimerProxy() {
return mKeyTimerHandler;
@ -589,11 +595,11 @@ public class LatinKeyboardBaseView extends KeyboardView {
}
private static void processMotionEvent(PointerTracker tracker, int action, int x, int y,
long eventTime, KeyboardView keyboardView) {
long eventTime, PointerTracker.KeyEventHandler handler) {
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
tracker.onDownEvent(x, y, eventTime, keyboardView);
tracker.onDownEvent(x, y, eventTime, handler);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:

View File

@ -36,6 +36,33 @@ public class PointerTracker {
private static final boolean DEBUG_LISTENER = false;
private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
public interface KeyEventHandler {
/**
* Get KeyDetector object that is used for this PointerTracker.
* @return the KeyDetector object that is used for this PointerTracker
*/
public KeyDetector getKeyDetector();
/**
* Get KeyboardActionListener object that is used to register key code and so on.
* @return the KeyboardActionListner for this PointerTracker
*/
public KeyboardActionListener getKeyboardActionListener();
/**
* Get DrawingProxy object that is used for this PointerTracker.
* @return the DrawingProxy object that is used for this PointerTracker
*/
public DrawingProxy getDrawingProxy();
/**
* Get TimerProxy object that handles key repeat and long press timer event for this
* PointerTracker.
* @return the TimerProxy object that handles key repeat and long press timer event.
*/
public TimerProxy getTimerProxy();
}
public interface DrawingProxy {
public void invalidateKey(Key key);
public void showKeyPreview(int keyIndex, PointerTracker tracker);
@ -329,13 +356,13 @@ public class PointerTracker {
return onMoveKeyInternal(x, y);
}
public void onDownEvent(int x, int y, long eventTime, KeyboardView keyboardView) {
public void onDownEvent(int x, int y, long eventTime, KeyEventHandler handler) {
if (DEBUG_EVENT)
printTouchEvent("onDownEvent:", x, y, eventTime);
mDrawingProxy = keyboardView;
setKeyboardActionListener(keyboardView.getKeyboardActionListener());
setKeyDetectorInner(keyboardView.getKeyDetector());
mDrawingProxy = handler.getDrawingProxy();
setKeyboardActionListener(handler.getKeyboardActionListener());
setKeyDetectorInner(handler.getKeyDetector());
// Naive up-to-down noise filter.
final long deltaT = eventTime - mUpTime;
if (deltaT < mTouchNoiseThresholdMillis) {

View File

@ -19,7 +19,7 @@ package com.android.inputmethod.keyboard;
import android.view.MotionEvent;
import android.widget.PopupWindow;
public interface PopupPanel {
public interface PopupPanel extends PointerTracker.KeyEventHandler {
/**
* Show popup panel.
* @param parentKeyboardView the parent KeyboardView that has the parent key.