Fix null KeyDetector reference

This change must be checked in together with I737c266c45.

Bug: 13011041
Change-Id: Ia3d25be6de47fa16ab7156a25641e53a23948ff4
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 149f10f..282c8e8 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -18,7 +18,9 @@
 
 import com.android.inputmethod.latin.Constants;
 
-
+/**
+ * This class handles key detection.
+ */
 public class KeyDetector {
     private final int mKeyHysteresisDistanceSquared;
     private final int mKeyHysteresisDistanceForSlidingModifierSquared;
@@ -27,18 +29,12 @@
     private int mCorrectionX;
     private int mCorrectionY;
 
-    /**
-     * This class handles key detection.
-     *
-     * @param keyHysteresisDistance if the pointer movement distance is smaller than this, the
-     * movement will not be handled as meaningful movement. The unit is pixel.
-     */
-    public KeyDetector(float keyHysteresisDistance) {
-        this(keyHysteresisDistance, keyHysteresisDistance);
+    public KeyDetector() {
+        this(0.0f /* keyHysteresisDistance */, 0.0f /* keyHysteresisDistanceForSlidingModifier */);
     }
 
     /**
-     * This class handles key detection.
+     * Key detection object constructor with key hysteresis distances.
      *
      * @param keyHysteresisDistance if the pointer movement distance is smaller than this, the
      * movement will not be handled as meaningful movement. The unit is pixel.
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
index 81b8f04..4a80279 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
@@ -21,7 +21,7 @@
     private final int mSlideAllowanceSquareTop;
 
     public MoreKeysDetector(float slideAllowance) {
-        super(/* keyHysteresisDistance */0);
+        super();
         mSlideAllowanceSquare = (int)(slideAllowance * slideAllowance);
         // Top slide allowance is slightly longer (sqrt(2) times) than other edges.
         mSlideAllowanceSquareTop = mSlideAllowanceSquare * 2;
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index b5d82fa..befc4e6 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -155,7 +155,7 @@
 
     // The {@link KeyDetector} is set whenever the down event is processed. Also this is updated
     // when new {@link Keyboard} is set by {@link #setKeyDetector(KeyDetector)}.
-    private KeyDetector mKeyDetector;
+    private KeyDetector mKeyDetector = new KeyDetector();
     private Keyboard mKeyboard;
     private int mPhantomSuddenMoveThreshold;
     private final BogusMoveEventDetector mBogusMoveEventDetector = new BogusMoveEventDetector();
@@ -1124,9 +1124,6 @@
 
     private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime,
             final Key newKey) {
-        if (mKeyDetector == null) {
-            throw new NullPointerException("keyboard and/or key detector not set");
-        }
         final Key curKey = mCurrentKey;
         if (newKey == curKey) {
             return false;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java b/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java
index be73965..e175a05 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/EmojiPageKeyboardView.java
@@ -52,7 +52,7 @@
     };
 
     private OnKeyEventListener mListener = EMPTY_LISTENER;
-    private final KeyDetector mKeyDetector = new KeyDetector(0.0f /*keyHysteresisDistance */);
+    private final KeyDetector mKeyDetector = new KeyDetector();
     private final GestureDetector mGestureDetector;
 
     public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) {