Add gesture input enable settings

Bug: 6845325
Change-Id: I3165465b0b280e32a9288da16abb75baa67288dc
This commit is contained in:
Tadashi G. Takaoka 2012-07-20 17:49:06 +09:00
parent b8bd45a22a
commit 62b8dddb6d
8 changed files with 43 additions and 15 deletions

View file

@ -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>

View file

@ -86,6 +86,12 @@
android:summary="@string/bigram_prediction_summary"
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"

View file

@ -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(

View file

@ -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) {

View file

@ -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();

View file

@ -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() {

View file

@ -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;

View file

@ -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);
}