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: I74972cc765d15c08059e0c9014f863ffb2a57c6cmain
parent
57f7de0ba6
commit
918e420d1b
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2012, 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.
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<bool name="config_gesture_input_enabled_by_build_config">false</bool>
|
||||
</resources>
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue