Merge "Fix null KeyDetector reference"
commit
17993ed4ef
|
@ -18,7 +18,9 @@ package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class handles key detection.
|
||||||
|
*/
|
||||||
public class KeyDetector {
|
public class KeyDetector {
|
||||||
private final int mKeyHysteresisDistanceSquared;
|
private final int mKeyHysteresisDistanceSquared;
|
||||||
private final int mKeyHysteresisDistanceForSlidingModifierSquared;
|
private final int mKeyHysteresisDistanceForSlidingModifierSquared;
|
||||||
|
@ -27,18 +29,12 @@ public class KeyDetector {
|
||||||
private int mCorrectionX;
|
private int mCorrectionX;
|
||||||
private int mCorrectionY;
|
private int mCorrectionY;
|
||||||
|
|
||||||
/**
|
public KeyDetector() {
|
||||||
* This class handles key detection.
|
this(0.0f /* keyHysteresisDistance */, 0.0f /* keyHysteresisDistanceForSlidingModifier */);
|
||||||
*
|
|
||||||
* @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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @param keyHysteresisDistance if the pointer movement distance is smaller than this, the
|
||||||
* movement will not be handled as meaningful movement. The unit is pixel.
|
* movement will not be handled as meaningful movement. The unit is pixel.
|
||||||
|
|
|
@ -21,7 +21,7 @@ public final class MoreKeysDetector extends KeyDetector {
|
||||||
private final int mSlideAllowanceSquareTop;
|
private final int mSlideAllowanceSquareTop;
|
||||||
|
|
||||||
public MoreKeysDetector(float slideAllowance) {
|
public MoreKeysDetector(float slideAllowance) {
|
||||||
super(/* keyHysteresisDistance */0);
|
super();
|
||||||
mSlideAllowanceSquare = (int)(slideAllowance * slideAllowance);
|
mSlideAllowanceSquare = (int)(slideAllowance * slideAllowance);
|
||||||
// Top slide allowance is slightly longer (sqrt(2) times) than other edges.
|
// Top slide allowance is slightly longer (sqrt(2) times) than other edges.
|
||||||
mSlideAllowanceSquareTop = mSlideAllowanceSquare * 2;
|
mSlideAllowanceSquareTop = mSlideAllowanceSquare * 2;
|
||||||
|
|
|
@ -155,7 +155,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
||||||
|
|
||||||
// The {@link KeyDetector} is set whenever the down event is processed. Also this is updated
|
// 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)}.
|
// when new {@link Keyboard} is set by {@link #setKeyDetector(KeyDetector)}.
|
||||||
private KeyDetector mKeyDetector;
|
private KeyDetector mKeyDetector = new KeyDetector();
|
||||||
private Keyboard mKeyboard;
|
private Keyboard mKeyboard;
|
||||||
private int mPhantomSuddenMoveThreshold;
|
private int mPhantomSuddenMoveThreshold;
|
||||||
private final BogusMoveEventDetector mBogusMoveEventDetector = new BogusMoveEventDetector();
|
private final BogusMoveEventDetector mBogusMoveEventDetector = new BogusMoveEventDetector();
|
||||||
|
@ -1124,9 +1124,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
||||||
|
|
||||||
private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime,
|
private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime,
|
||||||
final Key newKey) {
|
final Key newKey) {
|
||||||
if (mKeyDetector == null) {
|
|
||||||
throw new NullPointerException("keyboard and/or key detector not set");
|
|
||||||
}
|
|
||||||
final Key curKey = mCurrentKey;
|
final Key curKey = mCurrentKey;
|
||||||
if (newKey == curKey) {
|
if (newKey == curKey) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
|
||||||
};
|
};
|
||||||
|
|
||||||
private OnKeyEventListener mListener = EMPTY_LISTENER;
|
private OnKeyEventListener mListener = EMPTY_LISTENER;
|
||||||
private final KeyDetector mKeyDetector = new KeyDetector(0.0f /*keyHysteresisDistance */);
|
private final KeyDetector mKeyDetector = new KeyDetector();
|
||||||
private final GestureDetector mGestureDetector;
|
private final GestureDetector mGestureDetector;
|
||||||
|
|
||||||
public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) {
|
public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) {
|
||||||
|
|
Loading…
Reference in New Issue