aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/values/strings.xml5
-rw-r--r--java/res/xml/prefs.xml6
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java16
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java7
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java5
8 files changed, 43 insertions, 15 deletions
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index cf7c1c5bd..98c891894 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -111,6 +111,11 @@
<!-- Description for "next word suggestion" option. This displays suggestions even when there is no input, based on the previous word. -->
<string name="bigram_prediction_summary">Based on previous word</string>
+ <!-- Option to enable gesture input. The user can input a word by tracing the letters of a word without releasing the finger from the screen. [CHAR LIMIT=20]-->
+ <string name="gesture_input">Gesture input</string>
+ <!-- Description for "gesture_input" option. The user can input a word by tracing the letters of a word without releasing the finger from the screen. [CHAR LIMIT=65]-->
+ <string name="gesture_input_summary">Input a word by tracing the letters of a word</string>
+
<!-- Indicates that a word has been added to the dictionary -->
<string name="added_word"><xliff:g id="word">%s</xliff:g> : Saved</string>
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index bf8805875..4f11cb7e5 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -87,6 +87,12 @@
android:persistent="true"
android:defaultValue="true" />
<CheckBoxPreference
+ android:key="gesture_input"
+ android:title="@string/gesture_input"
+ android:summary="@string/gesture_input_summary"
+ android:persistent="true"
+ android:defaultValue="true" />
+ <CheckBoxPreference
android:key="usability_study_mode"
android:title="@string/prefs_usability_study_mode"
android:persistent="true"
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);
}