From 4f8e451d0c5bb522eedc00a30f7b519ccfe5b704 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 19 Sep 2012 18:12:39 +0900 Subject: [PATCH] Show gesture floating preview text is off by default Bug: 7043127 Change-Id: Icabf080f43a5934fef3824919bb03229522d5e5a --- java/res/xml/prefs.xml | 4 +-- .../keyboard/internal/PreviewPlacerView.java | 32 ++++++++++++------- .../android/inputmethod/latin/Settings.java | 8 ++--- .../inputmethod/latin/SettingsValues.java | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index ef6be3eed..f7c993d9d 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -138,11 +138,11 @@ android:persistent="true" android:defaultValue="true" /> + android:defaultValue="false" /> diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java index 3a850096f..915ce1f36 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java +++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java @@ -189,22 +189,29 @@ public class PreviewPlacerView extends RelativeLayout { } public void invalidatePointer(final PointerTracker tracker, final boolean isOldestTracker) { - GesturePreviewTrail trail; - synchronized (mGesturePreviewTrails) { - trail = mGesturePreviewTrails.get(tracker.mPointerId); - if (trail == null) { - trail = new GesturePreviewTrail(); - mGesturePreviewTrails.put(tracker.mPointerId, trail); - } - } - trail.addStroke(tracker.getGestureStrokeWithPreviewTrail(), tracker.getDownTime()); - - if (isOldestTracker) { + final boolean needsToUpdateLastPointer = + isOldestTracker && mDrawsGestureFloatingPreviewText; + if (needsToUpdateLastPointer) { mLastPointerX = tracker.getLastX(); mLastPointerY = tracker.getLastY(); } + + if (mDrawsGesturePreviewTrail) { + GesturePreviewTrail trail; + synchronized (mGesturePreviewTrails) { + trail = mGesturePreviewTrails.get(tracker.mPointerId); + if (trail == null) { + trail = new GesturePreviewTrail(); + mGesturePreviewTrails.put(tracker.mPointerId, trail); + } + } + trail.addStroke(tracker.getGestureStrokeWithPreviewTrail(), tracker.getDownTime()); + } + // TODO: Should narrow the invalidate region. - invalidate(); + if (mDrawsGesturePreviewTrail || needsToUpdateLastPointer) { + invalidate(); + } } @Override @@ -262,6 +269,7 @@ public class PreviewPlacerView extends RelativeLayout { } public void setGestureFloatingPreviewText(final String gestureFloatingPreviewText) { + if (!mDrawsGestureFloatingPreviewText) return; mGestureFloatingPreviewText = gestureFloatingPreviewText; invalidate(); } diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 180f6c56f..c2dec2593 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -77,8 +77,8 @@ public class Settings extends InputMethodSettingsFragment public static final String PREF_KEYPRESS_SOUND_VOLUME = "pref_keypress_sound_volume"; public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail"; - public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = - "pref_gesture_floating_preview_text"; + public static final String PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT = + "pref_show_gesture_floating_preview_text"; public static final String PREF_INPUT_LANGUAGE = "input_language"; public static final String PREF_SELECTED_LANGUAGES = "selected_languages"; @@ -207,7 +207,7 @@ public class Settings extends InputMethodSettingsFragment R.bool.config_gesture_input_enabled_by_build_config); final Preference gesturePreviewTrail = findPreference(PREF_GESTURE_PREVIEW_TRAIL); final Preference gestureFloatingPreviewText = findPreference( - PREF_GESTURE_FLOATING_PREVIEW_TEXT); + PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT); if (!gestureInputEnabledByBuildConfig) { miscSettings.removePreference(findPreference(PREF_GESTURE_INPUT)); miscSettings.removePreference(gesturePreviewTrail); @@ -304,7 +304,7 @@ public class Settings extends InputMethodSettingsFragment PREF_GESTURE_INPUT, true); setPreferenceEnabled(findPreference(PREF_GESTURE_PREVIEW_TRAIL), gestureInputEnabledByUser); - setPreferenceEnabled(findPreference(PREF_GESTURE_FLOATING_PREVIEW_TEXT), + setPreferenceEnabled(findPreference(PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT), gestureInputEnabledByUser); } } diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 5e9c870d4..d9cf2700b 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -178,7 +178,7 @@ public final class SettingsValues { && prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true); mGesturePreviewTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true); mGestureFloatingPreviewTextEnabled = prefs.getBoolean( - Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true); + Settings.PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT, false); mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect; mSuggestionVisibility = createSuggestionVisibility(res); }