Add gesture input enable settings
Bug: 6845325 Change-Id: I3165465b0b280e32a9288da16abb75baa67288dcmain
parent
b8bd45a22a
commit
62b8dddb6d
|
@ -111,6 +111,11 @@
|
||||||
<!-- Description for "next word suggestion" option. This displays suggestions even when there is no input, based on the previous word. -->
|
<!-- 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>
|
<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 -->
|
<!-- Indicates that a word has been added to the dictionary -->
|
||||||
<string name="added_word"><xliff:g id="word">%s</xliff:g> : Saved</string>
|
<string name="added_word"><xliff:g id="word">%s</xliff:g> : Saved</string>
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,12 @@
|
||||||
android:summary="@string/bigram_prediction_summary"
|
android:summary="@string/bigram_prediction_summary"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:defaultValue="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
|
<CheckBoxPreference
|
||||||
android:key="usability_study_mode"
|
android:key="usability_study_mode"
|
||||||
android:title="@string/prefs_usability_study_mode"
|
android:title="@string/prefs_usability_study_mode"
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
new KeyboardTheme("Basic", 0, R.style.KeyboardTheme),
|
new KeyboardTheme("Basic", 0, R.style.KeyboardTheme),
|
||||||
new KeyboardTheme("HighContrast", 1, R.style.KeyboardTheme_HighContrast),
|
new KeyboardTheme("HighContrast", 1, R.style.KeyboardTheme_HighContrast),
|
||||||
new KeyboardTheme("Stone", 6, R.style.KeyboardTheme_Stone),
|
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("GingerBread", 8, R.style.KeyboardTheme_Gingerbread),
|
||||||
new KeyboardTheme("IceCreamSandwich", 5, R.style.KeyboardTheme_IceCreamSandwich),
|
new KeyboardTheme("IceCreamSandwich", 5, R.style.KeyboardTheme_IceCreamSandwich),
|
||||||
};
|
};
|
||||||
|
@ -74,6 +74,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
private LatinKeyboardView mKeyboardView;
|
private LatinKeyboardView mKeyboardView;
|
||||||
private LatinIME mLatinIME;
|
private LatinIME mLatinIME;
|
||||||
private Resources mResources;
|
private Resources mResources;
|
||||||
|
private SettingsValues mCurrentSettingsValues;
|
||||||
|
|
||||||
private KeyboardState mState;
|
private KeyboardState mState;
|
||||||
|
|
||||||
|
@ -135,6 +136,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadKeyboard(EditorInfo editorInfo, SettingsValues settingsValues) {
|
public void loadKeyboard(EditorInfo editorInfo, SettingsValues settingsValues) {
|
||||||
|
mCurrentSettingsValues = settingsValues;
|
||||||
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
|
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
|
||||||
mThemeContext, editorInfo);
|
mThemeContext, editorInfo);
|
||||||
builder.setScreenGeometry(mThemeContext.getResources().getConfiguration().orientation,
|
builder.setScreenGeometry(mThemeContext.getResources().getConfiguration().orientation,
|
||||||
|
@ -170,6 +172,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
|
||||||
private void setKeyboard(final Keyboard keyboard) {
|
private void setKeyboard(final Keyboard keyboard) {
|
||||||
final Keyboard oldKeyboard = mKeyboardView.getKeyboard();
|
final Keyboard oldKeyboard = mKeyboardView.getKeyboard();
|
||||||
|
mKeyboardView.setGestureInputEnabled(mCurrentSettingsValues.mGestureInputEnabled);
|
||||||
mKeyboardView.setKeyboard(keyboard);
|
mKeyboardView.setKeyboard(keyboard);
|
||||||
mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding);
|
mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding);
|
||||||
mKeyboardView.setKeyPreviewPopupEnabled(
|
mKeyboardView.setKeyPreviewPopupEnabled(
|
||||||
|
|
|
@ -109,6 +109,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
private int mDelayAfterPreview;
|
private int mDelayAfterPreview;
|
||||||
private ViewGroup mPreviewPlacer;
|
private ViewGroup mPreviewPlacer;
|
||||||
|
|
||||||
|
/** True if the gesture input is enabled. */
|
||||||
|
protected boolean mGestureInputEnabled;
|
||||||
|
|
||||||
// Drawing
|
// Drawing
|
||||||
/** True if the entire keyboard needs to be dimmed. */
|
/** True if the entire keyboard needs to be dimmed. */
|
||||||
private boolean mNeedsToDimEntireKeyboard;
|
private boolean mNeedsToDimEntireKeyboard;
|
||||||
|
@ -438,6 +441,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
return mShowKeyPreviewPopup;
|
return mShowKeyPreviewPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGestureInputEnabled(boolean gestureInputEnabled) {
|
||||||
|
mGestureInputEnabled = gestureInputEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
if (mKeyboard != null) {
|
if (mKeyboard != null) {
|
||||||
|
|
|
@ -345,10 +345,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
|
final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
|
||||||
Utils.getDeviceOverrideValue(res,
|
Utils.getDeviceOverrideValue(res,
|
||||||
R.array.phantom_sudden_move_event_device_list, "false"));
|
R.array.phantom_sudden_move_event_device_list, "false"));
|
||||||
final boolean gestureInputEnabledByBuildConfig = res.getBoolean(
|
PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack);
|
||||||
R.bool.config_gesture_input_enabled_by_build_config);
|
|
||||||
PointerTracker.init(mHasDistinctMultitouch, needsPhantomSuddenMoveEventHack,
|
|
||||||
gestureInputEnabledByBuildConfig);
|
|
||||||
|
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView);
|
attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView);
|
||||||
|
@ -464,7 +461,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
super.setKeyboard(keyboard);
|
super.setKeyboard(keyboard);
|
||||||
mKeyDetector.setKeyboard(
|
mKeyDetector.setKeyboard(
|
||||||
keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection);
|
keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection);
|
||||||
PointerTracker.setKeyDetector(mKeyDetector);
|
PointerTracker.setKeyDetector(mKeyDetector, mGestureInputEnabled);
|
||||||
mTouchScreenRegulator.setKeyboard(keyboard);
|
mTouchScreenRegulator.setKeyboard(keyboard);
|
||||||
mMoreKeysPanelCache.clear();
|
mMoreKeysPanelCache.clear();
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,6 @@ public class PointerTracker {
|
||||||
private static LatinKeyboardView.PointerTrackerParams sParams;
|
private static LatinKeyboardView.PointerTrackerParams sParams;
|
||||||
private static int sTouchNoiseThresholdDistanceSquared;
|
private static int sTouchNoiseThresholdDistanceSquared;
|
||||||
private static boolean sNeedsPhantomSuddenMoveEventHack;
|
private static boolean sNeedsPhantomSuddenMoveEventHack;
|
||||||
private static boolean sConfigGestureInputEnabledByBuildConfig;
|
|
||||||
|
|
||||||
private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
|
private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
|
||||||
private static final InputPointers sAggregratedPointers = new InputPointers(
|
private static final InputPointers sAggregratedPointers = new InputPointers(
|
||||||
|
@ -191,18 +190,16 @@ public class PointerTracker {
|
||||||
private final GestureStroke mGestureStroke;
|
private final GestureStroke mGestureStroke;
|
||||||
|
|
||||||
public static void init(boolean hasDistinctMultitouch,
|
public static void init(boolean hasDistinctMultitouch,
|
||||||
boolean needsPhantomSuddenMoveEventHack,
|
boolean needsPhantomSuddenMoveEventHack) {
|
||||||
boolean gestureInputEnabledByBuildConfig) {
|
|
||||||
if (hasDistinctMultitouch) {
|
if (hasDistinctMultitouch) {
|
||||||
sPointerTrackerQueue = new PointerTrackerQueue();
|
sPointerTrackerQueue = new PointerTrackerQueue();
|
||||||
} else {
|
} else {
|
||||||
sPointerTrackerQueue = null;
|
sPointerTrackerQueue = null;
|
||||||
}
|
}
|
||||||
sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack;
|
sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack;
|
||||||
sConfigGestureInputEnabledByBuildConfig = gestureInputEnabledByBuildConfig;
|
|
||||||
|
|
||||||
setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT);
|
setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT);
|
||||||
updateGestureInputEnabledState(null);
|
updateGestureInputEnabledState(null, false /* gestureInputEnabled */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setParameters(LatinKeyboardView.PointerTrackerParams params) {
|
public static void setParameters(LatinKeyboardView.PointerTrackerParams params) {
|
||||||
|
@ -211,8 +208,9 @@ public class PointerTracker {
|
||||||
params.mTouchNoiseThresholdDistance * params.mTouchNoiseThresholdDistance);
|
params.mTouchNoiseThresholdDistance * params.mTouchNoiseThresholdDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateGestureInputEnabledState(Keyboard keyboard) {
|
private static void updateGestureInputEnabledState(Keyboard keyboard,
|
||||||
if (!sConfigGestureInputEnabledByBuildConfig
|
boolean gestureInputEnabled) {
|
||||||
|
if (!gestureInputEnabled
|
||||||
|| AccessibilityUtils.getInstance().isTouchExplorationEnabled()
|
|| AccessibilityUtils.getInstance().isTouchExplorationEnabled()
|
||||||
|| (keyboard != null && keyboard.mId.passwordInput())) {
|
|| (keyboard != null && keyboard.mId.passwordInput())) {
|
||||||
sIsGestureEnabled = false;
|
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();
|
final int trackersSize = sTrackers.size();
|
||||||
for (int i = 0; i < trackersSize; ++i) {
|
for (int i = 0; i < trackersSize; ++i) {
|
||||||
final PointerTracker tracker = sTrackers.get(i);
|
final PointerTracker tracker = sTrackers.get(i);
|
||||||
|
@ -254,7 +252,7 @@ public class PointerTracker {
|
||||||
tracker.mKeyboardLayoutHasBeenChanged = true;
|
tracker.mKeyboardLayoutHasBeenChanged = true;
|
||||||
}
|
}
|
||||||
final Keyboard keyboard = keyDetector.getKeyboard();
|
final Keyboard keyboard = keyDetector.getKeyboard();
|
||||||
updateGestureInputEnabledState(keyboard);
|
updateGestureInputEnabledState(keyboard, gestureInputEnabledByUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dismissAllKeyPreviews() {
|
public static void dismissAllKeyPreviews() {
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class Settings extends InputMethodSettingsFragment
|
||||||
"pref_key_preview_popup_dismiss_delay";
|
"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_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict";
|
||||||
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
|
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 =
|
public static final String PREF_VIBRATION_DURATION_SETTINGS =
|
||||||
"pref_vibration_duration_settings";
|
"pref_vibration_duration_settings";
|
||||||
public static final String PREF_KEYPRESS_SOUND_VOLUME =
|
public static final String PREF_KEYPRESS_SOUND_VOLUME =
|
||||||
|
@ -196,6 +197,12 @@ public class Settings extends InputMethodSettingsFragment
|
||||||
textCorrectionGroup.removePreference(dictionaryLink);
|
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 =
|
final boolean showUsabilityStudyModeOption =
|
||||||
res.getBoolean(R.bool.config_enable_usability_study_mode_option)
|
res.getBoolean(R.bool.config_enable_usability_study_mode_option)
|
||||||
|| ProductionFlag.IS_EXPERIMENTAL || ENABLE_EXPERIMENTAL_SETTINGS;
|
|| ProductionFlag.IS_EXPERIMENTAL || ENABLE_EXPERIMENTAL_SETTINGS;
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class SettingsValues {
|
||||||
@SuppressWarnings("unused") // TODO: Use this
|
@SuppressWarnings("unused") // TODO: Use this
|
||||||
private final float mKeypressSoundVolumeRawValue;
|
private final float mKeypressSoundVolumeRawValue;
|
||||||
private final InputMethodSubtype[] mAdditionalSubtypes;
|
private final InputMethodSubtype[] mAdditionalSubtypes;
|
||||||
|
public final boolean mGestureInputEnabled;
|
||||||
|
|
||||||
// From the input box
|
// From the input box
|
||||||
private final InputAttributes mInputAttributes;
|
private final InputAttributes mInputAttributes;
|
||||||
|
@ -169,6 +170,10 @@ public class SettingsValues {
|
||||||
mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain);
|
mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain);
|
||||||
mAdditionalSubtypes = AdditionalSubtype.createAdditionalSubtypesArray(
|
mAdditionalSubtypes = AdditionalSubtype.createAdditionalSubtypesArray(
|
||||||
getPrefAdditionalSubtypes(prefs, res));
|
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;
|
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
|
||||||
mSuggestionVisibility = createSuggestionVisibility(res);
|
mSuggestionVisibility = createSuggestionVisibility(res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue