diff options
Diffstat (limited to 'java/src')
5 files changed, 24 insertions, 12 deletions
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<PointerTracker> sTrackers = new ArrayList<PointerTracker>(); 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); } diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index 9d8bace71..1207c3fcd 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -168,15 +168,13 @@ public class ProximityInfo { final Rect hitBox = key.mHitBox; final int row = hitBox.top / mKeyHeight; if (row < touchPositionCorrection.mRadii.length) { - final float hitBoxCenterX = (hitBox.left + hitBox.right) * 0.5f; - final float hitBoxCenterY = (hitBox.top + hitBox.bottom) * 0.5f; - final float hitBoxWidth = hitBox.right - hitBox.left; - final float hitBoxHeight = hitBox.bottom - hitBox.top; + final int hitBoxWidth = hitBox.width(); + final int hitBoxHeight = hitBox.height(); final float x = touchPositionCorrection.mXs[row]; final float y = touchPositionCorrection.mYs[row]; final float radius = touchPositionCorrection.mRadii[row]; - sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth; - sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight; + sweetSpotCenterXs[i] = hitBox.exactCenterX() + x * hitBoxWidth; + sweetSpotCenterYs[i] = hitBox.exactCenterY() + y * hitBoxHeight; sweetSpotRadii[i] = radius * FloatMath.sqrt( hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight); } diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 08f3e8456..c9ff0a5a8 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -151,6 +151,11 @@ public class Settings extends InputMethodSettingsFragment if (!VibratorUtils.getInstance(context).hasVibrator()) { generalSettings.removePreference(findPreference(PREF_VIBRATE_ON)); + final PreferenceGroup advancedSettings = + (PreferenceGroup) findPreference(PREF_ADVANCED_SETTINGS); + if (null != advancedSettings) { // Theoretically advancedSettings cannot be null + advancedSettings.removePreference(findPreference(PREF_VIBRATION_DURATION_SETTINGS)); + } } final boolean showPopupOption = res.getBoolean( diff --git a/java/src/com/android/inputmethod/latin/TargetApplicationGetter.java b/java/src/com/android/inputmethod/latin/TargetApplicationGetter.java index 4fb2e9704..4265309e5 100644 --- a/java/src/com/android/inputmethod/latin/TargetApplicationGetter.java +++ b/java/src/com/android/inputmethod/latin/TargetApplicationGetter.java @@ -29,6 +29,7 @@ public class TargetApplicationGetter extends AsyncTask<String, Void, Application new LruCache<String, ApplicationInfo>(MAX_CACHE_ENTRIES); public static ApplicationInfo getCachedApplicationInfo(final String packageName) { + if (null == packageName) return null; return sCache.get(packageName); } public static void removeApplicationInfoCache(final String packageName) { |