am 9f41befb: am 9afafd0e: Merge "Restrict phantom sudden move event hack to specific device" into jb-dev
* commit '9f41befb8b5f4d86a03f9eb7e2d80148e9b55428': Restrict phantom sudden move event hack to specific devicemain
commit
4e3d9d375e
|
@ -0,0 +1,26 @@
|
||||||
|
<?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>
|
||||||
|
<string-array name="phantom_sudden_move_event_device_list" translatable="false">
|
||||||
|
<!-- "Build.HARDWARE,true" that needs "phantom sudden move event" hack.
|
||||||
|
See {@link com.android.inputmethod.keyboard.PointerTracker}. -->
|
||||||
|
<item>stingray,true</item> <!-- Xoom -->
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
|
@ -338,8 +338,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
|
|
||||||
mHasDistinctMultitouch = context.getPackageManager()
|
mHasDistinctMultitouch = context.getPackageManager()
|
||||||
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
|
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
|
||||||
|
final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
|
||||||
PointerTracker.init(mHasDistinctMultitouch);
|
Utils.getDeviceOverrideValue(context.getResources(),
|
||||||
|
R.array.phantom_sudden_move_event_device_list, "false"));
|
||||||
|
PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack);
|
||||||
|
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView);
|
attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView);
|
||||||
|
|
|
@ -108,6 +108,7 @@ public class PointerTracker {
|
||||||
// Parameters for pointer handling.
|
// Parameters for pointer handling.
|
||||||
private static LatinKeyboardView.PointerTrackerParams sParams;
|
private static LatinKeyboardView.PointerTrackerParams sParams;
|
||||||
private static int sTouchNoiseThresholdDistanceSquared;
|
private static int sTouchNoiseThresholdDistanceSquared;
|
||||||
|
private static boolean sNeedsPhantomSuddenMoveEventHack;
|
||||||
|
|
||||||
private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
|
private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
|
||||||
private static PointerTrackerQueue sPointerTrackerQueue;
|
private static PointerTrackerQueue sPointerTrackerQueue;
|
||||||
|
@ -162,12 +163,14 @@ public class PointerTracker {
|
||||||
private static final KeyboardActionListener EMPTY_LISTENER =
|
private static final KeyboardActionListener EMPTY_LISTENER =
|
||||||
new KeyboardActionListener.Adapter();
|
new KeyboardActionListener.Adapter();
|
||||||
|
|
||||||
public static void init(boolean hasDistinctMultitouch) {
|
public static void init(boolean hasDistinctMultitouch,
|
||||||
|
boolean needsPhantomSuddenMoveEventHack) {
|
||||||
if (hasDistinctMultitouch) {
|
if (hasDistinctMultitouch) {
|
||||||
sPointerTrackerQueue = new PointerTrackerQueue();
|
sPointerTrackerQueue = new PointerTrackerQueue();
|
||||||
} else {
|
} else {
|
||||||
sPointerTrackerQueue = null;
|
sPointerTrackerQueue = null;
|
||||||
}
|
}
|
||||||
|
sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack;
|
||||||
|
|
||||||
setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT);
|
setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT);
|
||||||
}
|
}
|
||||||
|
@ -589,10 +592,13 @@ public class PointerTracker {
|
||||||
final int dx = x - lastX;
|
final int dx = x - lastX;
|
||||||
final int dy = y - lastY;
|
final int dy = y - lastY;
|
||||||
final int lastMoveSquared = dx * dx + dy * dy;
|
final int lastMoveSquared = dx * dx + dy * dy;
|
||||||
if (lastMoveSquared >= mKeyQuarterWidthSquared) {
|
if (sNeedsPhantomSuddenMoveEventHack
|
||||||
if (DEBUG_MODE)
|
&& lastMoveSquared >= mKeyQuarterWidthSquared) {
|
||||||
Log.w(TAG, String.format("onMoveEvent: sudden move is translated to "
|
if (DEBUG_MODE) {
|
||||||
|
Log.w(TAG, String.format("onMoveEvent:"
|
||||||
|
+ " phantom sudden move event is translated to "
|
||||||
+ "up[%d,%d]/down[%d,%d] events", lastX, lastY, x, y));
|
+ "up[%d,%d]/down[%d,%d] events", lastX, lastY, x, y));
|
||||||
|
}
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
ResearchLogger.pointerTracker_onMoveEvent(x, y, lastX, lastY);
|
ResearchLogger.pointerTracker_onMoveEvent(x, y, lastX, lastY);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue