mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix possible NPE and IndexOutOfBoundsException.
Bug: 2868304 Change-Id: I2c474736fb9bb95da9e04bdeb9b9b641e7c3adda
This commit is contained in:
parent
bc305c21bf
commit
35f6cd905d
@ -320,7 +320,8 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
|
|||||||
};
|
};
|
||||||
|
|
||||||
static class KeyDebouncer {
|
static class KeyDebouncer {
|
||||||
private Key[] mKeys;
|
private final Key[] mKeys;
|
||||||
|
private final int mKeyDebounceThresholdSquared;
|
||||||
|
|
||||||
// for move de-bouncing
|
// for move de-bouncing
|
||||||
private int mLastCodeX;
|
private int mLastCodeX;
|
||||||
@ -334,9 +335,9 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
|
|||||||
private long mLastMoveTime;
|
private long mLastMoveTime;
|
||||||
private long mCurrentKeyTime;
|
private long mCurrentKeyTime;
|
||||||
|
|
||||||
private final int mKeyDebounceThresholdSquared;
|
|
||||||
|
|
||||||
KeyDebouncer(Key[] keys, float hysteresisPixel) {
|
KeyDebouncer(Key[] keys, float hysteresisPixel) {
|
||||||
|
if (keys == null || hysteresisPixel < 1.0f)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
mKeys = keys;
|
mKeys = keys;
|
||||||
mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel);
|
mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel);
|
||||||
}
|
}
|
||||||
@ -379,11 +380,11 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
|
|||||||
public boolean isMinorMoveBounce(int x, int y, int newKey, int curKey) {
|
public boolean isMinorMoveBounce(int x, int y, int newKey, int curKey) {
|
||||||
if (newKey == curKey) {
|
if (newKey == curKey) {
|
||||||
return true;
|
return true;
|
||||||
} else if (curKey == NOT_A_KEY) {
|
} else if (curKey >= 0 && curKey < mKeys.length) {
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return getSquareDistanceToKeyEdge(x, y, mKeys[curKey])
|
return getSquareDistanceToKeyEdge(x, y, mKeys[curKey])
|
||||||
< mKeyDebounceThresholdSquared;
|
< mKeyDebounceThresholdSquared;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user