Record down point as gesture preview trail for sure

Change-Id: Ic712a6af8229a9a1aa4a5419d779927f1ef8be67
main
Tadashi G. Takaoka 2013-05-07 15:51:23 +09:00
parent 4ddf1e47a7
commit ce67b41661
1 changed files with 5 additions and 5 deletions

View File

@ -65,15 +65,15 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
@Override
public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
super.setKeyboardGeometry(keyWidth, keyboardHeight);
final float samplingRatioToKeyWidth = MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
mMinPreviewSamplingDistance = keyWidth * samplingRatioToKeyWidth;
mMinPreviewSamplingDistance = keyWidth * MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
}
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);
mLastX = x;
mLastY = y;
if (mDistanceFromLastSample >= mMinPreviewSamplingDistance) {
final boolean isDownEvent = (mPreviewEventTimes.getLength() == 0);
if (mDistanceFromLastSample >= mMinPreviewSamplingDistance || isDownEvent) {
mDistanceFromLastSample = 0.0d;
return true;
}
@ -83,7 +83,7 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
@Override
public boolean addPointOnKeyboard(final int x, final int y, final int time,
final boolean isMajorEvent) {
if (needsSampling(x, y, isMajorEvent)) {
if (needsSampling(x, y)) {
mPreviewEventTimes.add(time);
mPreviewXCoordinates.add(x);
mPreviewYCoordinates.add(y);