am e8220078: Separate GestureStrokePreviewParams to top level class

* commit 'e82200787c662488c908c7973b9857ee6ce037b3':
  Separate GestureStrokePreviewParams to top level class
main
Tadashi G. Takaoka 2013-12-24 00:33:41 -08:00 committed by Android Git Automerger
commit f732734318
3 changed files with 51 additions and 37 deletions

View File

@ -26,8 +26,8 @@ import com.android.inputmethod.keyboard.internal.BogusMoveEventDetector;
import com.android.inputmethod.keyboard.internal.GestureEnabler; import com.android.inputmethod.keyboard.internal.GestureEnabler;
import com.android.inputmethod.keyboard.internal.GestureStroke; import com.android.inputmethod.keyboard.internal.GestureStroke;
import com.android.inputmethod.keyboard.internal.GestureStrokeParams; import com.android.inputmethod.keyboard.internal.GestureStrokeParams;
import com.android.inputmethod.keyboard.internal.GestureStrokePreviewParams;
import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints; import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints;
import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints.GestureStrokePreviewParams;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.keyboard.internal.TypingTimeRecorder; import com.android.inputmethod.keyboard.internal.TypingTimeRecorder;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.inputmethod.keyboard.internal;
import android.content.res.TypedArray;
import com.android.inputmethod.latin.R;
public final class GestureStrokePreviewParams {
public final double mMinSamplingDistance; // in pixel
public final double mMaxInterpolationAngularThreshold; // in radian
public final double mMaxInterpolationDistanceThreshold; // in pixel
public final int mMaxInterpolationSegments;
private static final float DEFAULT_MIN_SAMPLING_DISTANCE = 0.0f; // dp
private static final int DEFAULT_MAX_INTERPOLATION_ANGULAR_THRESHOLD = 15; // in degree
private static final float DEFAULT_MAX_INTERPOLATION_DISTANCE_THRESHOLD = 0.0f; // dp
private static final int DEFAULT_MAX_INTERPOLATION_SEGMENTS = 4;
public GestureStrokePreviewParams(final TypedArray mainKeyboardViewAttr) {
mMinSamplingDistance = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureTrailMinSamplingDistance,
DEFAULT_MIN_SAMPLING_DISTANCE);
final int interpolationAngularDegree = mainKeyboardViewAttr.getInteger(R.styleable
.MainKeyboardView_gestureTrailMaxInterpolationAngularThreshold, 0);
mMaxInterpolationAngularThreshold = (interpolationAngularDegree <= 0)
? Math.toRadians(DEFAULT_MAX_INTERPOLATION_ANGULAR_THRESHOLD)
: Math.toRadians(interpolationAngularDegree);
mMaxInterpolationDistanceThreshold = mainKeyboardViewAttr.getDimension(R.styleable
.MainKeyboardView_gestureTrailMaxInterpolationDistanceThreshold,
DEFAULT_MAX_INTERPOLATION_DISTANCE_THRESHOLD);
mMaxInterpolationSegments = mainKeyboardViewAttr.getInteger(
R.styleable.MainKeyboardView_gestureTrailMaxInterpolationSegments,
DEFAULT_MAX_INTERPOLATION_SEGMENTS);
}
}

View File

@ -16,9 +16,6 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
import android.content.res.TypedArray;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.ResizableIntArray; import com.android.inputmethod.latin.utils.ResizableIntArray;
public final class GestureStrokeWithPreviewPoints extends GestureStroke { public final class GestureStrokeWithPreviewPoints extends GestureStroke {
@ -39,39 +36,6 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
private int mLastY; private int mLastY;
private double mDistanceFromLastSample; private double mDistanceFromLastSample;
public static final class GestureStrokePreviewParams {
public final double mMinSamplingDistance; // in pixel
public final double mMaxInterpolationAngularThreshold; // in radian
public final double mMaxInterpolationDistanceThreshold; // in pixel
public final int mMaxInterpolationSegments;
private static final float DEFAULT_MIN_SAMPLING_DISTANCE = 0.0f; // dp
private static final int DEFAULT_MAX_INTERPOLATION_ANGULAR_THRESHOLD = 15; // in degree
private static final float DEFAULT_MAX_INTERPOLATION_DISTANCE_THRESHOLD = 0.0f; // dp
private static final int DEFAULT_MAX_INTERPOLATION_SEGMENTS = 4;
private static double degreeToRadian(final int degree) {
return degree / 180.0d * Math.PI;
}
public GestureStrokePreviewParams(final TypedArray mainKeyboardViewAttr) {
mMinSamplingDistance = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureTrailMinSamplingDistance,
DEFAULT_MIN_SAMPLING_DISTANCE);
final int interpolationAngularDegree = mainKeyboardViewAttr.getInteger(R.styleable
.MainKeyboardView_gestureTrailMaxInterpolationAngularThreshold, 0);
mMaxInterpolationAngularThreshold = (interpolationAngularDegree <= 0)
? degreeToRadian(DEFAULT_MAX_INTERPOLATION_ANGULAR_THRESHOLD)
: degreeToRadian(interpolationAngularDegree);
mMaxInterpolationDistanceThreshold = mainKeyboardViewAttr.getDimension(R.styleable
.MainKeyboardView_gestureTrailMaxInterpolationDistanceThreshold,
DEFAULT_MAX_INTERPOLATION_DISTANCE_THRESHOLD);
mMaxInterpolationSegments = mainKeyboardViewAttr.getInteger(
R.styleable.MainKeyboardView_gestureTrailMaxInterpolationSegments,
DEFAULT_MAX_INTERPOLATION_SEGMENTS);
}
}
public GestureStrokeWithPreviewPoints(final int pointerId, public GestureStrokeWithPreviewPoints(final int pointerId,
final GestureStrokeParams strokeParams, final GestureStrokeParams strokeParams,
final GestureStrokePreviewParams previewParams) { final GestureStrokePreviewParams previewParams) {