Rename SuddenJumpingTouchEventHandler to TouchSCreenRegulator

Change-Id: Ia4fb5b3612ff78ed1b243c80a03294b829470f5c
main
Tadashi G. Takaoka 2012-11-01 14:51:53 +09:00
parent ffb0c093d1
commit 081fedc422
2 changed files with 15 additions and 15 deletions

View File

@ -47,7 +47,7 @@ import com.android.inputmethod.annotations.ExternallyReferenced;
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
import com.android.inputmethod.keyboard.internal.SuddenJumpingTouchEventHandler;
import com.android.inputmethod.keyboard.internal.TouchScreenRegulator;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.DebugSettings;
import com.android.inputmethod.latin.LatinIME;
@ -99,7 +99,7 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#MainKeyboardView_suppressKeyPreviewAfterBatchInputDuration
*/
public final class MainKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler,
SuddenJumpingTouchEventHandler.ProcessMotionEvent {
TouchScreenRegulator.ProcessMotionEvent {
private static final String TAG = MainKeyboardView.class.getSimpleName();
// TODO: Kill process when the usability study mode was changed.
@ -142,7 +142,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
new WeakHashMap<Key, MoreKeysPanel>();
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
private final TouchScreenRegulator mTouchScreenRegulator;
protected KeyDetector mKeyDetector;
private final boolean mHasDistinctMultitouch;
@ -362,7 +362,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
public MainKeyboardView(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
mTouchScreenRegulator = new SuddenJumpingTouchEventHandler(getContext(), this);
mTouchScreenRegulator = new TouchScreenRegulator(context, this);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
final boolean forceNonDistinctMultitouch = prefs.getBoolean(
@ -495,7 +495,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mKeyDetector.setKeyboard(
keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection);
PointerTracker.setKeyDetector(mKeyDetector);
mTouchScreenRegulator.setKeyboard(keyboard);
mTouchScreenRegulator.setKeyboardGeometry(keyboard.mOccupiedWidth);
mMoreKeysPanelCache.clear();
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);

View File

@ -20,7 +20,6 @@ import android.content.Context;
import android.util.Log;
import android.view.MotionEvent;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
@ -28,8 +27,8 @@ import com.android.inputmethod.latin.ResourceUtils;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.research.ResearchLogger;
public final class SuddenJumpingTouchEventHandler {
private static final String TAG = SuddenJumpingTouchEventHandler.class.getSimpleName();
public final class TouchScreenRegulator {
private static final String TAG = TouchScreenRegulator.class.getSimpleName();
private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
public interface ProcessMotionEvent {
@ -50,17 +49,18 @@ public final class SuddenJumpingTouchEventHandler {
private int mJumpThresholdSquare = Integer.MAX_VALUE;
private int mLastX;
private int mLastY;
// One-seventh of the keyboard width seems like a reasonable threshold
private static final float JUMP_THRESHOLD_RATIO_TO_KEYBOARD_WIDTH = 1.0f / 7.0f;
public SuddenJumpingTouchEventHandler(Context context, ProcessMotionEvent view) {
public TouchScreenRegulator(final Context context, final ProcessMotionEvent view) {
mView = view;
mNeedsSuddenJumpingHack = Boolean.parseBoolean(ResourceUtils.getDeviceOverrideValue(
context.getResources(), R.array.sudden_jumping_touch_event_device_list, "false"));
}
public void setKeyboard(Keyboard newKeyboard) {
// One-seventh of the keyboard width seems like a reasonable threshold
final int jumpThreshold = newKeyboard.mOccupiedWidth / 7;
mJumpThresholdSquare = jumpThreshold * jumpThreshold;
public void setKeyboardGeometry(final int keyboardWidth) {
final float jumpThreshold = keyboardWidth * JUMP_THRESHOLD_RATIO_TO_KEYBOARD_WIDTH;
mJumpThresholdSquare = (int)(jumpThreshold * jumpThreshold);
}
/**
@ -74,7 +74,7 @@ public final class SuddenJumpingTouchEventHandler {
* @return true if the event was consumed, so that it doesn't continue to be handled by
* {@link MainKeyboardView}.
*/
private boolean handleSuddenJumping(MotionEvent me) {
private boolean handleSuddenJumping(final MotionEvent me) {
if (!mNeedsSuddenJumpingHack)
return false;
final int action = me.getAction();
@ -140,7 +140,7 @@ public final class SuddenJumpingTouchEventHandler {
return result;
}
public boolean onTouchEvent(MotionEvent me) {
public boolean onTouchEvent(final MotionEvent me) {
// If there was a sudden jump, return without processing the actual motion event.
if (handleSuddenJumping(me)) {
if (DEBUG_MODE)