aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-07-19 12:33:51 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-07-19 16:33:09 +0900
commit918e420d1becc1389b9895538eceff85fe882c99 (patch)
treee8ee6c97574f51a469c18c6fc5042fa2ebeb85ec /java/src
parent57f7de0ba664187e13bcea5adff7f5f65eddd823 (diff)
downloadlatinime-918e420d1becc1389b9895538eceff85fe882c99.tar.gz
latinime-918e420d1becc1389b9895538eceff85fe882c99.tar.xz
latinime-918e420d1becc1389b9895538eceff85fe882c99.zip
Gesture input should be turned off depending on the configuration
The gesture input will be disabled when * It is AOSP build. * Accessibility mode is on. * The input field is password mode. Bug: 6844755 Bug: 6844763 Bug: 6845011 Change-Id: I74972cc765d15c08059e0c9014f863ffb2a57c6c
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java8
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java26
2 files changed, 28 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 7714ba892..1eae2c1d4 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -341,10 +341,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
mHasDistinctMultitouch = context.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
+ final Resources res = getResources();
final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
- Utils.getDeviceOverrideValue(context.getResources(),
+ Utils.getDeviceOverrideValue(res,
R.array.phantom_sudden_move_event_device_list, "false"));
- PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack);
+ final boolean gestureInputEnabledByBuildConfig = res.getBoolean(
+ R.bool.config_gesture_input_enabled_by_build_config);
+ PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack,
+ gestureInputEnabledByBuildConfig);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView);
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index cc6789d13..c925227b9 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -22,6 +22,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
+import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.keyboard.internal.GestureStroke;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.latin.InputPointers;
@@ -39,7 +40,8 @@ public class PointerTracker {
private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
// TODO: There should be an option to turn on/off the gesture input.
- private static final boolean GESTURE_ON = true;
+ private static boolean sIsGestureEnabled = true;
+
private static final int MIN_RECOGNITION_TIME = 100; // msec
public interface KeyEventHandler {
@@ -116,6 +118,7 @@ public class PointerTracker {
private static LatinKeyboardView.PointerTrackerParams sParams;
private static int sTouchNoiseThresholdDistanceSquared;
private static boolean sNeedsPhantomSuddenMoveEventHack;
+ private static boolean sConfigGestureInputEnabledByBuildConfig;
private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
private static PointerTrackerQueue sPointerTrackerQueue;
@@ -177,15 +180,18 @@ public class PointerTracker {
private final GestureStroke mGestureStroke;
public static void init(boolean hasDistinctMultitouch,
- boolean needsPhantomSuddenMoveEventHack) {
+ boolean needsPhantomSuddenMoveEventHack,
+ boolean gestureInputEnabledByBuildConfig) {
if (hasDistinctMultitouch) {
sPointerTrackerQueue = new PointerTrackerQueue();
} else {
sPointerTrackerQueue = null;
}
sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack;
+ sConfigGestureInputEnabledByBuildConfig = gestureInputEnabledByBuildConfig;
setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT);
+ updateGestureInputEnabledState(null);
}
public static void setParameters(LatinKeyboardView.PointerTrackerParams params) {
@@ -194,6 +200,16 @@ public class PointerTracker {
params.mTouchNoiseThresholdDistance * params.mTouchNoiseThresholdDistance);
}
+ private static void updateGestureInputEnabledState(Keyboard keyboard) {
+ if (!sConfigGestureInputEnabledByBuildConfig
+ || AccessibilityUtils.getInstance().isTouchExplorationEnabled()
+ || (keyboard != null && keyboard.mId.passwordInput())) {
+ sIsGestureEnabled = false;
+ } else {
+ sIsGestureEnabled = true;
+ }
+ }
+
public static PointerTracker getPointerTracker(final int id, KeyEventHandler handler) {
final ArrayList<PointerTracker> trackers = sTrackers;
@@ -222,6 +238,8 @@ public class PointerTracker {
// Mark that keyboard layout has been changed.
tracker.mKeyboardLayoutHasBeenChanged = true;
}
+ final Keyboard keyboard = keyDetector.getKeyboard();
+ updateGestureInputEnabledState(keyboard);
}
public static void dismissAllKeyPreviews() {
@@ -611,7 +629,7 @@ public class PointerTracker {
if (queue != null && queue.size() == 1) {
mIsPossibleGesture = false;
// A gesture should start only from the letter key.
- if (GESTURE_ON && mIsAlphabetKeyboard && key != null
+ if (sIsGestureEnabled && mIsAlphabetKeyboard && key != null
&& Keyboard.isLetterCode(key.mCode)) {
mIsPossibleGesture = true;
mGestureStroke.addPoint(x, y, 0, false);
@@ -654,7 +672,7 @@ public class PointerTracker {
private void onGestureMoveEvent(PointerTracker tracker, int x, int y, long eventTime,
boolean isHistorical, Key key) {
final int gestureTime = (int)(eventTime - tracker.getDownTime());
- if (GESTURE_ON && mIsPossibleGesture) {
+ if (sIsGestureEnabled && mIsPossibleGesture) {
final GestureStroke stroke = mGestureStroke;
stroke.addPoint(x, y, gestureTime, isHistorical);
if (!mInGesture && stroke.isStartOfAGesture(gestureTime)) {