diff options
Diffstat (limited to 'java/src')
5 files changed, 53 insertions, 18 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/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java index 0a09c845e..34308dfb3 100644 --- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java @@ -214,6 +214,10 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { return false; } if (contactCount != sContactCountAtLastRebuild) { + if (DEBUG) { + Log.d(TAG, "Contact count changed: " + sContactCountAtLastRebuild + " to " + + contactCount); + } return true; } // Check all contacts since it's not possible to find out which names have changed. diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 08f585485..c65404cbc 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -294,7 +294,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { */ protected void loadBinaryDictionary() { if (DEBUG) { - Log.d(TAG, "Loading binary dictionary: request=" + Log.d(TAG, "Loading binary dictionary: " + mFilename + " request=" + mSharedDictionaryController.mLastUpdateRequestTime + " update=" + mSharedDictionaryController.mLastUpdateTime); } @@ -326,7 +326,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { */ private void generateBinaryDictionary() { if (DEBUG) { - Log.d(TAG, "Generating binary dictionary: request=" + Log.d(TAG, "Generating binary dictionary: " + mFilename + " request=" + mSharedDictionaryController.mLastUpdateRequestTime + " update=" + mSharedDictionaryController.mLastUpdateTime); } @@ -371,7 +371,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { mLocalDictionaryController.mLastUpdateRequestTime = time; mSharedDictionaryController.mLastUpdateRequestTime = time; if (DEBUG) { - Log.d(TAG, "Reload request: request=" + time + " update=" + Log.d(TAG, "Reload request: " + mFilename + ": request=" + time + " update=" + mSharedDictionaryController.mLastUpdateTime); } } @@ -380,28 +380,46 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { * Reloads the dictionary if required. Reload will occur asynchronously in a separate thread. */ void asyncReloadDictionaryIfRequired() { + if (!isReloadRequired()) return; + if (DEBUG) { + Log.d(TAG, "Starting AsyncReloadDictionaryTask: " + mFilename); + } new AsyncReloadDictionaryTask().start(); } /** - * Reloads the dictionary if required. Access is controlled on a per dictionary file basis and - * supports concurrent calls from multiple instances that share the same dictionary file. + * Reloads the dictionary if required. */ protected final void syncReloadDictionaryIfRequired() { - if (mBinaryDictionary != null && !mLocalDictionaryController.isOutOfDate()) { - return; - } + if (!isReloadRequired()) return; + syncReloadDictionaryInternal(); + } + + /** + * Returns whether a dictionary reload is required. + */ + private boolean isReloadRequired() { + return mBinaryDictionary == null || mLocalDictionaryController.isOutOfDate(); + } + /** + * Reloads the dictionary. Access is controlled on a per dictionary file basis and supports + * concurrent calls from multiple instances that share the same dictionary file. + */ + private final void syncReloadDictionaryInternal() { // Ensure that only one thread attempts to read or write to the shared binary dictionary // file at the same time. mSharedDictionaryController.lock(); try { final long time = SystemClock.uptimeMillis(); - if (mSharedDictionaryController.isOutOfDate() || !dictionaryFileExists()) { + final boolean dictionaryFileExists = dictionaryFileExists(); + if (mSharedDictionaryController.isOutOfDate() || !dictionaryFileExists) { // If the shared dictionary file does not exist or is out of date, the first // instance that acquires the lock will generate a new one. - if (hasContentChanged()) { - // If the source content has changed, rebuild the binary dictionary. + if (hasContentChanged() || !dictionaryFileExists) { + // If the source content has changed or the dictionary does not exist, rebuild + // the binary dictionary. Empty dictionaries are supported (in the case where + // loadDictionaryAsync() adds nothing) in order to provide a uniform framework. mSharedDictionaryController.mLastUpdateTime = time; generateBinaryDictionary(); loadBinaryDictionary(); @@ -435,7 +453,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { private class AsyncReloadDictionaryTask extends Thread { @Override public void run() { - syncReloadDictionaryIfRequired(); + syncReloadDictionaryInternal(); } } 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( |