diff options
Diffstat (limited to 'java/src')
6 files changed, 32 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 2e4ce199e..38d78da93 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -61,7 +61,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { new KeyboardTheme("Basic", 0, R.style.KeyboardTheme), new KeyboardTheme("HighContrast", 1, R.style.KeyboardTheme_HighContrast), new KeyboardTheme("Stone", 6, R.style.KeyboardTheme_Stone), - new KeyboardTheme("Stne.Bold", 7, R.style.KeyboardTheme_Stone_Bold), + new KeyboardTheme("Stone.Bold", 7, R.style.KeyboardTheme_Stone_Bold), new KeyboardTheme("GingerBread", 8, R.style.KeyboardTheme_Gingerbread), new KeyboardTheme("IceCreamSandwich", 5, R.style.KeyboardTheme_IceCreamSandwich), }; @@ -74,6 +74,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { private LatinKeyboardView mKeyboardView; private LatinIME mLatinIME; private Resources mResources; + private SettingsValues mCurrentSettingsValues; private KeyboardState mState; @@ -135,6 +136,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { } public void loadKeyboard(EditorInfo editorInfo, SettingsValues settingsValues) { + mCurrentSettingsValues = settingsValues; final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder( mThemeContext, editorInfo); builder.setScreenGeometry(mThemeContext.getResources().getConfiguration().orientation, @@ -170,6 +172,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { private void setKeyboard(final Keyboard keyboard) { final Keyboard oldKeyboard = mKeyboardView.getKeyboard(); + mKeyboardView.setGestureInputEnabled(mCurrentSettingsValues.mGestureInputEnabled); mKeyboardView.setKeyboard(keyboard); mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding); mKeyboardView.setKeyPreviewPopupEnabled( diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 62696219b..61ed26b06 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -109,6 +109,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { private int mDelayAfterPreview; private ViewGroup mPreviewPlacer; + /** True if the gesture input is enabled. */ + protected boolean mGestureInputEnabled; + // Drawing /** True if the entire keyboard needs to be dimmed. */ private boolean mNeedsToDimEntireKeyboard; @@ -438,6 +441,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { return mShowKeyPreviewPopup; } + public void setGestureInputEnabled(boolean gestureInputEnabled) { + mGestureInputEnabled = gestureInputEnabled; + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mKeyboard != null) { diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 8e904c6f9..537b4e245 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -345,10 +345,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean( Utils.getDeviceOverrideValue(res, R.array.phantom_sudden_move_event_device_list, "false")); - final boolean gestureInputEnabledByBuildConfig = res.getBoolean( - R.bool.config_gesture_input_enabled_by_build_config); - PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack, - gestureInputEnabledByBuildConfig); + PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack); final TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView); @@ -464,7 +461,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke super.setKeyboard(keyboard); mKeyDetector.setKeyboard( keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection); - PointerTracker.setKeyDetector(mKeyDetector); + PointerTracker.setKeyDetector(mKeyDetector, mGestureInputEnabled); mTouchScreenRegulator.setKeyboard(keyboard); mMoreKeysPanelCache.clear(); diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 9b14210aa..1c84cb947 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -122,7 +122,6 @@ public class PointerTracker { private static LatinKeyboardView.PointerTrackerParams sParams; private static int sTouchNoiseThresholdDistanceSquared; private static boolean sNeedsPhantomSuddenMoveEventHack; - private static boolean sConfigGestureInputEnabledByBuildConfig; private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>(); private static final InputPointers sAggregratedPointers = new InputPointers( @@ -191,18 +190,16 @@ public class PointerTracker { private final GestureStroke mGestureStroke; public static void init(boolean hasDistinctMultitouch, - boolean needsPhantomSuddenMoveEventHack, - boolean gestureInputEnabledByBuildConfig) { + boolean needsPhantomSuddenMoveEventHack) { if (hasDistinctMultitouch) { sPointerTrackerQueue = new PointerTrackerQueue(); } else { sPointerTrackerQueue = null; } sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack; - sConfigGestureInputEnabledByBuildConfig = gestureInputEnabledByBuildConfig; setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT); - updateGestureInputEnabledState(null); + updateGestureInputEnabledState(null, false /* gestureInputEnabled */); } public static void setParameters(LatinKeyboardView.PointerTrackerParams params) { @@ -211,8 +208,9 @@ public class PointerTracker { params.mTouchNoiseThresholdDistance * params.mTouchNoiseThresholdDistance); } - private static void updateGestureInputEnabledState(Keyboard keyboard) { - if (!sConfigGestureInputEnabledByBuildConfig + private static void updateGestureInputEnabledState(Keyboard keyboard, + boolean gestureInputEnabled) { + if (!gestureInputEnabled || AccessibilityUtils.getInstance().isTouchExplorationEnabled() || (keyboard != null && keyboard.mId.passwordInput())) { sIsGestureEnabled = false; @@ -245,7 +243,7 @@ public class PointerTracker { } } - public static void setKeyDetector(KeyDetector keyDetector) { + public static void setKeyDetector(KeyDetector keyDetector, boolean gestureInputEnabledByUser) { final int trackersSize = sTrackers.size(); for (int i = 0; i < trackersSize; ++i) { final PointerTracker tracker = sTrackers.get(i); @@ -254,7 +252,7 @@ public class PointerTracker { tracker.mKeyboardLayoutHasBeenChanged = true; } final Keyboard keyboard = keyDetector.getKeyboard(); - updateGestureInputEnabledState(keyboard); + updateGestureInputEnabledState(keyboard, gestureInputEnabledByUser); } public static void dismissAllKeyPreviews() { diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index a07d286b8..b67cc852e 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -70,6 +70,7 @@ public class Settings extends InputMethodSettingsFragment "pref_key_preview_popup_dismiss_delay"; public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict"; public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction"; + public static final String PREF_GESTURE_INPUT = "gesture_input"; public static final String PREF_VIBRATION_DURATION_SETTINGS = "pref_vibration_duration_settings"; public static final String PREF_KEYPRESS_SOUND_VOLUME = @@ -196,6 +197,12 @@ public class Settings extends InputMethodSettingsFragment textCorrectionGroup.removePreference(dictionaryLink); } + final boolean gestureInputEnabledByBuildConfig = res.getBoolean( + R.bool.config_gesture_input_enabled_by_build_config); + if (!gestureInputEnabledByBuildConfig) { + final Preference gestureInputPref = findPreference(PREF_GESTURE_INPUT); + miscSettings.removePreference(gestureInputPref); + } final boolean showUsabilityStudyModeOption = res.getBoolean(R.bool.config_enable_usability_study_mode_option) || ProductionFlag.IS_EXPERIMENTAL || ENABLE_EXPERIMENTAL_SETTINGS; diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 10025daf8..3ed981375 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -83,6 +83,7 @@ public class SettingsValues { @SuppressWarnings("unused") // TODO: Use this private final float mKeypressSoundVolumeRawValue; private final InputMethodSubtype[] mAdditionalSubtypes; + public final boolean mGestureInputEnabled; // From the input box private final InputAttributes mInputAttributes; @@ -169,6 +170,10 @@ public class SettingsValues { mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain); mAdditionalSubtypes = AdditionalSubtype.createAdditionalSubtypesArray( getPrefAdditionalSubtypes(prefs, res)); + final boolean gestureInputEnabledByBuildConfig = res.getBoolean( + R.bool.config_gesture_input_enabled_by_build_config); + mGestureInputEnabled = gestureInputEnabledByBuildConfig + && prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true); mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect; mSuggestionVisibility = createSuggestionVisibility(res); } |