am 718a0744: am 0cbc19b0: Merge "Restrict bogus move event detector to a horizontal movement" into jb-mr1-dev
* commit '718a07441ee27c0ba66d3d7aa9d1299c39e7f8b1': Restrict bogus move event detector to a horizontal movementmain
commit
6b169dc91d
|
@ -180,8 +180,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
|
|
||||||
static final class BogusMoveEventDetector {
|
static final class BogusMoveEventDetector {
|
||||||
// Move these thresholds to resource.
|
// Move these thresholds to resource.
|
||||||
private static final float BOGUS_MOVE_ACCUMULATED_DISTANCE_THRESHOLD = 0.70f; // in keyWidth
|
// These thresholds' unit is a diagonal length of a key.
|
||||||
private static final float BOGUS_MOVE_RADIUS_THRESHOLD = 1.50f; // in keyWidth
|
private static final float BOGUS_MOVE_ACCUMULATED_DISTANCE_THRESHOLD = 0.53f;
|
||||||
|
private static final float BOGUS_MOVE_RADIUS_THRESHOLD = 1.14f;
|
||||||
|
|
||||||
private int mAccumulatedDistanceThreshold;
|
private int mAccumulatedDistanceThreshold;
|
||||||
private int mRadiusThreshold;
|
private int mRadiusThreshold;
|
||||||
|
@ -191,10 +192,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
private int mActualDownX;
|
private int mActualDownX;
|
||||||
private int mActualDownY;
|
private int mActualDownY;
|
||||||
|
|
||||||
public void setKeyboardGeometry(final int keyWidth) {
|
public void setKeyboardGeometry(final int keyWidth, final int keyHeight) {
|
||||||
|
final float keyDiagonal = (float)Math.hypot(keyWidth, keyHeight);
|
||||||
mAccumulatedDistanceThreshold = (int)(
|
mAccumulatedDistanceThreshold = (int)(
|
||||||
keyWidth * BOGUS_MOVE_ACCUMULATED_DISTANCE_THRESHOLD);
|
keyDiagonal * BOGUS_MOVE_ACCUMULATED_DISTANCE_THRESHOLD);
|
||||||
mRadiusThreshold = (int)(keyWidth * BOGUS_MOVE_RADIUS_THRESHOLD);
|
mRadiusThreshold = (int)(keyDiagonal * BOGUS_MOVE_RADIUS_THRESHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onActualDownEvent(final int x, final int y) {
|
public void onActualDownEvent(final int x, final int y) {
|
||||||
|
@ -210,8 +212,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
mAccumulatedDistanceFromDownKey += distance;
|
mAccumulatedDistanceFromDownKey += distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTraveledLongDistance() {
|
public boolean hasTraveledLongDistance(final int x, final int y) {
|
||||||
return mAccumulatedDistanceFromDownKey >= mAccumulatedDistanceThreshold;
|
final int dx = Math.abs(x - mActualDownX);
|
||||||
|
final int dy = Math.abs(y - mActualDownY);
|
||||||
|
// A bogus move event should be a horizontal movement. A vertical movement might be
|
||||||
|
// a sloppy typing and should be ignored.
|
||||||
|
return dx >= dy && mAccumulatedDistanceFromDownKey >= mAccumulatedDistanceThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ int getDistanceFromDownEvent(final int x, final int y) {
|
/* package */ int getDistanceFromDownEvent(final int x, final int y) {
|
||||||
|
@ -514,7 +520,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
mKeyDetector = keyDetector;
|
mKeyDetector = keyDetector;
|
||||||
mKeyboard = keyDetector.getKeyboard();
|
mKeyboard = keyDetector.getKeyboard();
|
||||||
mGestureStrokeWithPreviewPoints.setKeyboardGeometry(mKeyboard.mMostCommonKeyWidth);
|
final int keyWidth = mKeyboard.mMostCommonKeyWidth;
|
||||||
|
final int keyHeight = mKeyboard.mMostCommonKeyHeight;
|
||||||
|
mGestureStrokeWithPreviewPoints.setKeyboardGeometry(keyWidth);
|
||||||
final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
|
final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
|
||||||
if (newKey != mCurrentKey) {
|
if (newKey != mCurrentKey) {
|
||||||
if (mDrawingProxy != null) {
|
if (mDrawingProxy != null) {
|
||||||
|
@ -522,9 +530,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
// Keep {@link #mCurrentKey} that comes from previous keyboard.
|
// Keep {@link #mCurrentKey} that comes from previous keyboard.
|
||||||
}
|
}
|
||||||
final int keyWidth = mKeyboard.mMostCommonKeyWidth;
|
|
||||||
mPhantonSuddenMoveThreshold = (int)(keyWidth * PHANTOM_SUDDEN_MOVE_THRESHOLD);
|
mPhantonSuddenMoveThreshold = (int)(keyWidth * PHANTOM_SUDDEN_MOVE_THRESHOLD);
|
||||||
mBogusMoveEventDetector.setKeyboardGeometry(keyWidth);
|
mBogusMoveEventDetector.setKeyboardGeometry(keyWidth, keyHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -962,11 +969,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
&& sTimeRecorder.isInFastTyping(eventTime)
|
&& sTimeRecorder.isInFastTyping(eventTime)
|
||||||
&& mBogusMoveEventDetector.isCloseToActualDownEvent(x, y)) {
|
&& mBogusMoveEventDetector.isCloseToActualDownEvent(x, y)) {
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
|
final float keyDiagonal = (float)Math.hypot(
|
||||||
|
mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
|
||||||
final float radiusRatio =
|
final float radiusRatio =
|
||||||
(float)mBogusMoveEventDetector.getDistanceFromDownEvent(x, y)
|
mBogusMoveEventDetector.getDistanceFromDownEvent(x, y)
|
||||||
/ mKeyboard.mMostCommonKeyWidth;
|
/ keyDiagonal;
|
||||||
Log.w(TAG, String.format("[%d] onMoveEvent:"
|
Log.w(TAG, String.format("[%d] onMoveEvent:"
|
||||||
+ " bogus down-move-up event (raidus=%.2f keyWidth) is "
|
+ " bogus down-move-up event (raidus=%.2f key diagonal) is "
|
||||||
+ " translated to up[%d,%d,%s]/down[%d,%d,%s] events",
|
+ " translated to up[%d,%d,%s]/down[%d,%d,%s] events",
|
||||||
mPointerId, radiusRatio,
|
mPointerId, radiusRatio,
|
||||||
lastX, lastY, Keyboard.printableCode(oldKey.mCode),
|
lastX, lastY, Keyboard.printableCode(oldKey.mCode),
|
||||||
|
@ -1146,24 +1155,24 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
final int distanceFromKeyEdgeSquared = curKey.squaredDistanceToEdge(x, y);
|
final int distanceFromKeyEdgeSquared = curKey.squaredDistanceToEdge(x, y);
|
||||||
if (distanceFromKeyEdgeSquared >= keyHysteresisDistanceSquared) {
|
if (distanceFromKeyEdgeSquared >= keyHysteresisDistanceSquared) {
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
final int keyWidth = mKeyboard.mMostCommonKeyWidth;
|
final float distanceToEdgeRatio = (float)Math.sqrt(distanceFromKeyEdgeSquared)
|
||||||
final float distanceToEdgeRatio = (float)distanceFromKeyEdgeSquared
|
/ mKeyboard.mMostCommonKeyWidth;
|
||||||
/ (keyWidth * keyWidth);
|
|
||||||
Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
|
Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
|
||||||
+" %.2f keyWidth from key edge",
|
+" %.2f key width from key edge",
|
||||||
mPointerId, distanceToEdgeRatio));
|
mPointerId, distanceToEdgeRatio));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sNeedsProximateBogusDownMoveUpEventHack && !mIsAllowedSlidingKeyInput
|
if (sNeedsProximateBogusDownMoveUpEventHack && !mIsAllowedSlidingKeyInput
|
||||||
&& sTimeRecorder.isInFastTyping(eventTime)
|
&& sTimeRecorder.isInFastTyping(eventTime)
|
||||||
&& mBogusMoveEventDetector.hasTraveledLongDistance()) {
|
&& mBogusMoveEventDetector.hasTraveledLongDistance(x, y)) {
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
|
final float keyDiagonal = (float)Math.hypot(
|
||||||
|
mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
|
||||||
final float lengthFromDownRatio =
|
final float lengthFromDownRatio =
|
||||||
(float)mBogusMoveEventDetector.mAccumulatedDistanceFromDownKey
|
mBogusMoveEventDetector.mAccumulatedDistanceFromDownKey / keyDiagonal;
|
||||||
/ mKeyboard.mMostCommonKeyWidth;
|
|
||||||
Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
|
Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
|
||||||
+ " %.2f keyWidth from virtual down point",
|
+ " %.2f key diagonal from virtual down point",
|
||||||
mPointerId, lengthFromDownRatio));
|
mPointerId, lengthFromDownRatio));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue