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

View File

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