am ce67b416: Record down point as gesture preview trail for sure
* commit 'ce67b4166188a1ce0a3a54420843b7e4192607e3': Record down point as gesture preview trail for suremain
commit
c8dcf48e02
|
@ -65,15 +65,15 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
|
||||||
@Override
|
@Override
|
||||||
public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
|
public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
|
||||||
super.setKeyboardGeometry(keyWidth, keyboardHeight);
|
super.setKeyboardGeometry(keyWidth, keyboardHeight);
|
||||||
final float samplingRatioToKeyWidth = MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
|
mMinPreviewSamplingDistance = keyWidth * MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
|
||||||
mMinPreviewSamplingDistance = keyWidth * samplingRatioToKeyWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean needsSampling(final int x, final int y, final boolean isMajorEvent) {
|
private boolean needsSampling(final int x, final int y) {
|
||||||
mDistanceFromLastSample += Math.hypot(x - mLastX, y - mLastY);
|
mDistanceFromLastSample += Math.hypot(x - mLastX, y - mLastY);
|
||||||
mLastX = x;
|
mLastX = x;
|
||||||
mLastY = y;
|
mLastY = y;
|
||||||
if (mDistanceFromLastSample >= mMinPreviewSamplingDistance) {
|
final boolean isDownEvent = (mPreviewEventTimes.getLength() == 0);
|
||||||
|
if (mDistanceFromLastSample >= mMinPreviewSamplingDistance || isDownEvent) {
|
||||||
mDistanceFromLastSample = 0.0d;
|
mDistanceFromLastSample = 0.0d;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
|
||||||
@Override
|
@Override
|
||||||
public boolean addPointOnKeyboard(final int x, final int y, final int time,
|
public boolean addPointOnKeyboard(final int x, final int y, final int time,
|
||||||
final boolean isMajorEvent) {
|
final boolean isMajorEvent) {
|
||||||
if (needsSampling(x, y, isMajorEvent)) {
|
if (needsSampling(x, y)) {
|
||||||
mPreviewEventTimes.add(time);
|
mPreviewEventTimes.add(time);
|
||||||
mPreviewXCoordinates.add(x);
|
mPreviewXCoordinates.add(x);
|
||||||
mPreviewYCoordinates.add(y);
|
mPreviewYCoordinates.add(y);
|
||||||
|
|
Loading…
Reference in New Issue