Merge "Cleaup non-distinct multitouch related stuff"

This commit is contained in:
Tadashi G. Takaoka 2012-10-31 21:14:36 -07:00 committed by Android (Google) Code Review
commit c770c252a6
3 changed files with 17 additions and 31 deletions

View file

@ -30,7 +30,6 @@ import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetExcep
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.KeyboardState; import com.android.inputmethod.keyboard.internal.KeyboardState;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.DebugSettings;
import com.android.inputmethod.latin.ImfUtils; import com.android.inputmethod.latin.ImfUtils;
import com.android.inputmethod.latin.InputView; import com.android.inputmethod.latin.InputView;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;
@ -69,7 +68,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private AudioAndHapticFeedbackManager mFeedbackManager; private AudioAndHapticFeedbackManager mFeedbackManager;
private SubtypeSwitcher mSubtypeSwitcher; private SubtypeSwitcher mSubtypeSwitcher;
private SharedPreferences mPrefs; private SharedPreferences mPrefs;
private boolean mForceNonDistinctMultitouch;
private InputView mCurrentInputView; private InputView mCurrentInputView;
private MainKeyboardView mKeyboardView; private MainKeyboardView mKeyboardView;
@ -109,8 +107,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mState = new KeyboardState(this); mState = new KeyboardState(this);
setContextThemeWrapper(latinIme, getKeyboardTheme(latinIme, prefs)); setContextThemeWrapper(latinIme, getKeyboardTheme(latinIme, prefs));
mForceNonDistinctMultitouch = prefs.getBoolean(
DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false);
} }
private static KeyboardTheme getKeyboardTheme(Context context, SharedPreferences prefs) { private static KeyboardTheme getKeyboardTheme(Context context, SharedPreferences prefs) {
@ -341,10 +337,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
return mKeyboardView != null && mKeyboardView.getPointerCount() == 1; return mKeyboardView != null && mKeyboardView.getPointerCount() == 1;
} }
public boolean hasDistinctMultitouch() {
return mKeyboardView != null && mKeyboardView.hasDistinctMultitouch();
}
/** /**
* Updates state machine to figure out when to automatically switch back to the previous mode. * Updates state machine to figure out when to automatically switch back to the previous mode.
*/ */
@ -371,9 +363,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
// TODO: Should use LAYER_TYPE_SOFTWARE when hardware acceleration is off? // TODO: Should use LAYER_TYPE_SOFTWARE when hardware acceleration is off?
} }
mKeyboardView.setKeyboardActionListener(mLatinIME); mKeyboardView.setKeyboardActionListener(mLatinIME);
if (mForceNonDistinctMultitouch) {
mKeyboardView.setDistinctMultitouch(false);
}
// This always needs to be set since the accessibility state can // This always needs to be set since the accessibility state can
// potentially change without the input view being re-created. // potentially change without the input view being re-created.

View file

@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard;
import android.animation.AnimatorInflater; import android.animation.AnimatorInflater;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@ -28,6 +29,7 @@ import android.graphics.Paint.Align;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Message; import android.os.Message;
import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
@ -47,6 +49,7 @@ 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.SuddenJumpingTouchEventHandler;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.DebugSettings;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
@ -142,7 +145,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator; private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
protected KeyDetector mKeyDetector; protected KeyDetector mKeyDetector;
private boolean mHasDistinctMultitouch; private final boolean mHasDistinctMultitouch;
private int mOldPointerCount = 1; private int mOldPointerCount = 1;
private Key mOldKey; private Key mOldKey;
@ -359,8 +362,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mTouchScreenRegulator = new SuddenJumpingTouchEventHandler(getContext(), this); mTouchScreenRegulator = new SuddenJumpingTouchEventHandler(getContext(), this);
mHasDistinctMultitouch = context.getPackageManager() final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
final boolean forceNonDistinctMultitouch = prefs.getBoolean(
DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false);
final boolean hasDistinctMultitouch = context.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT); .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
mHasDistinctMultitouch = hasDistinctMultitouch && !forceNonDistinctMultitouch;
final Resources res = getResources(); final Resources res = getResources();
final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean( final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
ResourceUtils.getDeviceOverrideValue(res, ResourceUtils.getDeviceOverrideValue(res,
@ -510,18 +517,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
PointerTracker.setGestureHandlingEnabledByUser(gestureHandlingEnabledByUser); PointerTracker.setGestureHandlingEnabledByUser(gestureHandlingEnabledByUser);
} }
/**
* Returns whether the device has distinct multi-touch panel.
* @return true if the device has distinct multi-touch panel.
*/
public boolean hasDistinctMultitouch() {
return mHasDistinctMultitouch;
}
public void setDistinctMultitouch(final boolean hasDistinctMultitouch) {
mHasDistinctMultitouch = hasDistinctMultitouch;
}
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();

View file

@ -686,6 +686,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
return (sPointerTrackerQueue == null) ? 1 : sPointerTrackerQueue.size(); return (sPointerTrackerQueue == null) ? 1 : sPointerTrackerQueue.size();
} }
private static boolean isOldestTrackerInQueue(final PointerTracker tracker) {
return sPointerTrackerQueue == null
|| sPointerTrackerQueue.getOldestElement() == tracker;
}
private void mayStartBatchInput(final Key key) { private void mayStartBatchInput(final Key key) {
if (sInGesture || !mGestureStrokeWithPreviewPoints.isStartOfAGesture()) { if (sInGesture || !mGestureStrokeWithPreviewPoints.isStartOfAGesture()) {
return; return;
@ -704,8 +709,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
mListener.onStartBatchInput(); mListener.onStartBatchInput();
} }
mTimerProxy.cancelLongPressTimer(); mTimerProxy.cancelLongPressTimer();
final boolean isOldestTracker = sPointerTrackerQueue.getOldestElement() == this; mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker);
} }
private void mayUpdateBatchInput(final long eventTime, final Key key) { private void mayUpdateBatchInput(final long eventTime, final Key key) {
@ -726,8 +730,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
} }
} }
} }
final boolean isOldestTracker = sPointerTrackerQueue.getOldestElement() == this; mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker);
} }
private void mayEndBatchInput(final long eventTime) { private void mayEndBatchInput(final long eventTime) {
@ -743,8 +746,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
mListener.onEndBatchInput(sAggregratedPointers); mListener.onEndBatchInput(sAggregratedPointers);
} }
} }
final boolean isOldestTracker = sPointerTrackerQueue.getOldestElement() == this; mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker);
} }
public void processMotionEvent(final int action, final int x, final int y, final long eventTime, public void processMotionEvent(final int action, final int x, final int y, final long eventTime,