From d438fcaca2a35ace4fee5b7a469596bfe2d1b025 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 30 May 2012 19:29:57 +0900 Subject: [PATCH] Restrict phantom sudden move event hack to specific device Bug: 6571778 Change-Id: I4306af387074d34db68a9bb16ae41debcfc36bfd --- .../phantom_sudden_move_event_device_list.xml | 26 +++++++++++++++++++ .../keyboard/LatinKeyboardView.java | 6 +++-- .../inputmethod/keyboard/PointerTracker.java | 14 +++++++--- 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 java/res/values/phantom_sudden_move_event_device_list.xml diff --git a/java/res/values/phantom_sudden_move_event_device_list.xml b/java/res/values/phantom_sudden_move_event_device_list.xml new file mode 100644 index 000000000..63d12e96e --- /dev/null +++ b/java/res/values/phantom_sudden_move_event_device_list.xml @@ -0,0 +1,26 @@ + + + + + + stingray,true + + diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index b1599937b..e917a8128 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -338,8 +338,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke mHasDistinctMultitouch = context.getPackageManager() .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT); - - PointerTracker.init(mHasDistinctMultitouch); + final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean( + Utils.getDeviceOverrideValue(context.getResources(), + R.array.phantom_sudden_move_event_device_list, "false")); + PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack); 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 59f53fc21..0f8f6cd91 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -108,6 +108,7 @@ public class PointerTracker { // Parameters for pointer handling. private static LatinKeyboardView.PointerTrackerParams sParams; private static int sTouchNoiseThresholdDistanceSquared; + private static boolean sNeedsPhantomSuddenMoveEventHack; private static final ArrayList sTrackers = new ArrayList(); private static PointerTrackerQueue sPointerTrackerQueue; @@ -162,12 +163,14 @@ public class PointerTracker { private static final KeyboardActionListener EMPTY_LISTENER = new KeyboardActionListener.Adapter(); - public static void init(boolean hasDistinctMultitouch) { + public static void init(boolean hasDistinctMultitouch, + boolean needsPhantomSuddenMoveEventHack) { if (hasDistinctMultitouch) { sPointerTrackerQueue = new PointerTrackerQueue(); } else { sPointerTrackerQueue = null; } + sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack; setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT); } @@ -593,10 +596,13 @@ public class PointerTracker { final int dx = x - lastX; final int dy = y - lastY; final int lastMoveSquared = dx * dx + dy * dy; - if (lastMoveSquared >= mKeyQuarterWidthSquared) { - if (DEBUG_MODE) - Log.w(TAG, String.format("onMoveEvent: sudden move is translated to " + if (sNeedsPhantomSuddenMoveEventHack + && lastMoveSquared >= mKeyQuarterWidthSquared) { + 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)); + } if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.pointerTracker_onMoveEvent(x, y, lastX, lastY); }