Merge "Add KeyEventHandler interface"
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index de1e396..8ca8341 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -29,7 +29,7 @@
 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 @@
     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 @@
         return sInstance;
     }
 
-    public static void setView(KeyboardView view) {
+    public static void setView(LatinKeyboardBaseView view) {
         sInstance.mView = view;
     }
 
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 56e4dc8..e31aa84 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -38,7 +38,6 @@
 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 @@
  * @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 @@
         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();
 }
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
index 318e454..c4e37ff 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
@@ -33,6 +33,7 @@
 
 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 @@
  * @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;
@@ -278,6 +279,11 @@
     }
 
     @Override
+    public DrawingProxy getDrawingProxy() {
+        return this;
+    }
+
+    @Override
     public TimerProxy getTimerProxy() {
         return mKeyTimerHandler;
     }
@@ -589,11 +595,11 @@
     }
 
     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:
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 9557425..29a575a 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -36,6 +36,33 @@
     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 @@
         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) {
diff --git a/java/src/com/android/inputmethod/keyboard/PopupPanel.java b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
index 386e11f..2d9130f 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupPanel.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
@@ -19,7 +19,7 @@
 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.