Merge "Configurable key long press timeout"
commit
9dc85a673e
|
@ -87,10 +87,8 @@
|
||||||
<attr name="keyRepeatStartTimeout" format="integer" />
|
<attr name="keyRepeatStartTimeout" format="integer" />
|
||||||
<!-- Key repeat interval in millisecond. -->
|
<!-- Key repeat interval in millisecond. -->
|
||||||
<attr name="keyRepeatInterval" format="integer" />
|
<attr name="keyRepeatInterval" format="integer" />
|
||||||
<!-- Long press timeout of letter key in millisecond. -->
|
<!-- Long press timeout of shift key to shift lock in millisecond. -->
|
||||||
<attr name="longPressKeyTimeout" format="integer" />
|
<attr name="longPressShiftLockTimeout" format="integer" />
|
||||||
<!-- Long press timeout of shift key in millisecond. -->
|
|
||||||
<attr name="longPressShiftKeyTimeout" format="integer" />
|
|
||||||
<!-- Ignore special key timeout while typing in millisecond. -->
|
<!-- Ignore special key timeout while typing in millisecond. -->
|
||||||
<attr name="ignoreAltCodeKeyTimeout" format="integer" />
|
<attr name="ignoreAltCodeKeyTimeout" format="integer" />
|
||||||
<!-- Layout resource for key press feedback.-->
|
<!-- Layout resource for key press feedback.-->
|
||||||
|
|
|
@ -64,10 +64,13 @@
|
||||||
<bool name="config_sliding_key_input_enabled">true</bool>
|
<bool name="config_sliding_key_input_enabled">true</bool>
|
||||||
<integer name="config_key_repeat_start_timeout">400</integer>
|
<integer name="config_key_repeat_start_timeout">400</integer>
|
||||||
<integer name="config_key_repeat_interval">50</integer>
|
<integer name="config_key_repeat_interval">50</integer>
|
||||||
<integer name="config_long_press_key_timeout">400</integer>
|
<integer name="config_default_longpress_key_timeout">300</integer> <!-- milliseconds -->
|
||||||
|
<integer name="config_longpress_timeout_step">10</integer> <!-- milliseconds -->
|
||||||
|
<integer name="config_min_longpress_timeout">100</integer> <!-- milliseconds -->
|
||||||
|
<integer name="config_max_longpress_timeout">700</integer> <!-- milliseconds -->
|
||||||
<!-- Long pressing shift will invoke caps-lock if > 0, never invoke caps-lock if == 0 -->
|
<!-- Long pressing shift will invoke caps-lock if > 0, never invoke caps-lock if == 0 -->
|
||||||
<integer name="config_long_press_shift_key_timeout">1200</integer>
|
<integer name="config_longpress_shift_lock_timeout">1200</integer> <!-- milliseconds -->
|
||||||
<integer name="config_ignore_alt_code_key_timeout">350</integer>
|
<integer name="config_ignore_alt_code_key_timeout">350</integer> <!-- milliseconds -->
|
||||||
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
|
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
|
||||||
false -->
|
false -->
|
||||||
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
|
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
|
||||||
|
|
|
@ -374,6 +374,8 @@
|
||||||
|
|
||||||
<!-- Title of an option for usability study mode -->
|
<!-- Title of an option for usability study mode -->
|
||||||
<string name="prefs_usability_study_mode">Usability study mode</string>
|
<string name="prefs_usability_study_mode">Usability study mode</string>
|
||||||
|
<!-- Title of the settings for key long press delay -->
|
||||||
|
<string name="prefs_key_longpress_timeout_settings">Key long press delay settings</string>
|
||||||
<!-- Title of the settings for keypress vibration duration -->
|
<!-- Title of the settings for keypress vibration duration -->
|
||||||
<string name="prefs_keypress_vibration_duration_settings">Keypress vibration duration settings</string>
|
<string name="prefs_keypress_vibration_duration_settings">Keypress vibration duration settings</string>
|
||||||
<!-- Title of the settings for keypress sound volume -->
|
<!-- Title of the settings for keypress sound volume -->
|
||||||
|
|
|
@ -80,8 +80,7 @@
|
||||||
<item name="slidingKeyInputEnable">@bool/config_sliding_key_input_enabled</item>
|
<item name="slidingKeyInputEnable">@bool/config_sliding_key_input_enabled</item>
|
||||||
<item name="keyRepeatStartTimeout">@integer/config_key_repeat_start_timeout</item>
|
<item name="keyRepeatStartTimeout">@integer/config_key_repeat_start_timeout</item>
|
||||||
<item name="keyRepeatInterval">@integer/config_key_repeat_interval</item>
|
<item name="keyRepeatInterval">@integer/config_key_repeat_interval</item>
|
||||||
<item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item>
|
<item name="longPressShiftLockTimeout">@integer/config_longpress_shift_lock_timeout</item>
|
||||||
<item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item>
|
|
||||||
<item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item>
|
<item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item>
|
||||||
<item name="keyPreviewLayout">@layout/key_preview</item>
|
<item name="keyPreviewLayout">@layout/key_preview</item>
|
||||||
<item name="keyPreviewOffset">@dimen/key_preview_offset</item>
|
<item name="keyPreviewOffset">@dimen/key_preview_offset</item>
|
||||||
|
|
|
@ -145,6 +145,13 @@
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="pref_key_preview_popup_dismiss_delay"
|
android:key="pref_key_preview_popup_dismiss_delay"
|
||||||
android:title="@string/key_preview_popup_dismiss_delay" />
|
android:title="@string/key_preview_popup_dismiss_delay" />
|
||||||
|
<com.android.inputmethod.latin.SeekBarDialogPreference
|
||||||
|
android:key="pref_key_longpress_timeout"
|
||||||
|
android:title="@string/prefs_key_longpress_timeout_settings"
|
||||||
|
latin:valueFormatText="@string/abbreviation_unit_milliseconds"
|
||||||
|
latin:minValue="@integer/config_min_longpress_timeout"
|
||||||
|
latin:maxValue="@integer/config_max_longpress_timeout"
|
||||||
|
latin:stepValue="@integer/config_longpress_timeout_step" />
|
||||||
<com.android.inputmethod.latin.SeekBarDialogPreference
|
<com.android.inputmethod.latin.SeekBarDialogPreference
|
||||||
android:key="pref_vibration_duration_settings"
|
android:key="pref_vibration_duration_settings"
|
||||||
android:title="@string/prefs_keypress_vibration_duration_settings"
|
android:title="@string/prefs_keypress_vibration_duration_settings"
|
||||||
|
|
|
@ -65,6 +65,7 @@ import com.android.inputmethod.latin.LatinIME;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.ResourceUtils;
|
import com.android.inputmethod.latin.ResourceUtils;
|
||||||
|
import com.android.inputmethod.latin.Settings;
|
||||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
||||||
import com.android.inputmethod.latin.StringUtils;
|
import com.android.inputmethod.latin.StringUtils;
|
||||||
import com.android.inputmethod.latin.SubtypeLocale;
|
import com.android.inputmethod.latin.SubtypeLocale;
|
||||||
|
@ -205,8 +206,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
private final int mKeyRepeatStartTimeout;
|
private final int mKeyRepeatStartTimeout;
|
||||||
private final int mKeyRepeatInterval;
|
private final int mKeyRepeatInterval;
|
||||||
private final int mLongPressKeyTimeout;
|
private final int mLongPressShiftLockTimeout;
|
||||||
private final int mLongPressShiftKeyTimeout;
|
|
||||||
private final int mIgnoreAltCodeKeyTimeout;
|
private final int mIgnoreAltCodeKeyTimeout;
|
||||||
private final int mGestureRecognitionUpdateTime;
|
private final int mGestureRecognitionUpdateTime;
|
||||||
|
|
||||||
|
@ -218,10 +218,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
R.styleable.MainKeyboardView_keyRepeatStartTimeout, 0);
|
R.styleable.MainKeyboardView_keyRepeatStartTimeout, 0);
|
||||||
mKeyRepeatInterval = mainKeyboardViewAttr.getInt(
|
mKeyRepeatInterval = mainKeyboardViewAttr.getInt(
|
||||||
R.styleable.MainKeyboardView_keyRepeatInterval, 0);
|
R.styleable.MainKeyboardView_keyRepeatInterval, 0);
|
||||||
mLongPressKeyTimeout = mainKeyboardViewAttr.getInt(
|
mLongPressShiftLockTimeout = mainKeyboardViewAttr.getInt(
|
||||||
R.styleable.MainKeyboardView_longPressKeyTimeout, 0);
|
R.styleable.MainKeyboardView_longPressShiftLockTimeout, 0);
|
||||||
mLongPressShiftKeyTimeout = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_longPressShiftKeyTimeout, 0);
|
|
||||||
mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
|
mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
|
||||||
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
||||||
mGestureRecognitionUpdateTime = mainKeyboardViewAttr.getInt(
|
mGestureRecognitionUpdateTime = mainKeyboardViewAttr.getInt(
|
||||||
|
@ -285,7 +283,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
final int delay;
|
final int delay;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case Constants.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
delay = mLongPressShiftKeyTimeout;
|
delay = mLongPressShiftLockTimeout;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
delay = 0;
|
delay = 0;
|
||||||
|
@ -306,15 +304,17 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
final int delay;
|
final int delay;
|
||||||
switch (key.mCode) {
|
switch (key.mCode) {
|
||||||
case Constants.CODE_SHIFT:
|
case Constants.CODE_SHIFT:
|
||||||
delay = mLongPressShiftKeyTimeout;
|
delay = mLongPressShiftLockTimeout;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
final int longpressTimeout =
|
||||||
|
Settings.getInstance().getCurrent().mKeyLongpressTimeout;
|
||||||
if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
|
if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
|
||||||
// We use longer timeout for sliding finger input started from the symbols
|
// We use longer timeout for sliding finger input started from the symbols
|
||||||
// mode key.
|
// mode key.
|
||||||
delay = mLongPressKeyTimeout * 3;
|
delay = longpressTimeout * 3;
|
||||||
} else {
|
} else {
|
||||||
delay = mLongPressKeyTimeout;
|
delay = longpressTimeout;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
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_SETTINGS = "gesture_typing_settings";
|
public static final String PREF_GESTURE_SETTINGS = "gesture_typing_settings";
|
||||||
public static final String PREF_GESTURE_INPUT = "gesture_input";
|
public static final String PREF_GESTURE_INPUT = "gesture_input";
|
||||||
|
public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout";
|
||||||
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 =
|
||||||
|
@ -175,6 +176,16 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
ResourceUtils.getDeviceOverrideValue(res, R.array.keypress_volumes));
|
ResourceUtils.getDeviceOverrideValue(res, R.array.keypress_volumes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int readKeyLongpressTimeout(final SharedPreferences prefs,
|
||||||
|
final Resources res) {
|
||||||
|
final int ms = prefs.getInt(PREF_KEY_LONGPRESS_TIMEOUT, -1);
|
||||||
|
return (ms >= 0) ? ms : readDefaultKeyLongpressTimeout(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int readDefaultKeyLongpressTimeout(final Resources res) {
|
||||||
|
return res.getInteger(R.integer.config_default_longpress_key_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
public static int readKeypressVibrationDuration(final SharedPreferences prefs,
|
public static int readKeypressVibrationDuration(final SharedPreferences prefs,
|
||||||
final Resources res) {
|
final Resources res) {
|
||||||
final int ms = prefs.getInt(PREF_VIBRATION_DURATION_SETTINGS, -1);
|
final int ms = prefs.getInt(PREF_VIBRATION_DURATION_SETTINGS, -1);
|
||||||
|
|
|
@ -164,6 +164,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
||||||
getPreferenceScreen().removePreference(gestureTypingSettings);
|
getPreferenceScreen().removePreference(gestureTypingSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupKeyLongpressTimeoutSettings(prefs, res);
|
||||||
setupKeypressVibrationDurationSettings(prefs, res);
|
setupKeypressVibrationDurationSettings(prefs, res);
|
||||||
setupKeypressSoundVolumeSettings(prefs, res);
|
setupKeypressSoundVolumeSettings(prefs, res);
|
||||||
refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, res);
|
refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, res);
|
||||||
|
@ -298,6 +299,34 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupKeyLongpressTimeoutSettings(final SharedPreferences sp,
|
||||||
|
final Resources res) {
|
||||||
|
final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(
|
||||||
|
Settings.PREF_KEY_LONGPRESS_TIMEOUT);
|
||||||
|
if (pref == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pref.setInterface(new SeekBarDialogPreference.ValueProxy() {
|
||||||
|
@Override
|
||||||
|
public void writeValue(final int value, final String key) {
|
||||||
|
sp.edit().putInt(key, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int readValue(final String key) {
|
||||||
|
return Settings.readKeyLongpressTimeout(sp, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int readDefaultValue(final String key) {
|
||||||
|
return Settings.readDefaultKeyLongpressTimeout(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void feedbackValue(final int value) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void setupKeypressSoundVolumeSettings(final SharedPreferences sp, final Resources res) {
|
private void setupKeypressSoundVolumeSettings(final SharedPreferences sp, final Resources res) {
|
||||||
final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(
|
final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(
|
||||||
Settings.PREF_KEYPRESS_SOUND_VOLUME);
|
Settings.PREF_KEYPRESS_SOUND_VOLUME);
|
||||||
|
|
|
@ -59,6 +59,7 @@ public final class SettingsValues {
|
||||||
public final boolean mGestureInputEnabled;
|
public final boolean mGestureInputEnabled;
|
||||||
public final boolean mGesturePreviewTrailEnabled;
|
public final boolean mGesturePreviewTrailEnabled;
|
||||||
public final boolean mGestureFloatingPreviewTextEnabled;
|
public final boolean mGestureFloatingPreviewTextEnabled;
|
||||||
|
public final int mKeyLongpressTimeout;
|
||||||
|
|
||||||
// From the input box
|
// From the input box
|
||||||
public final InputAttributes mInputAttributes;
|
public final InputAttributes mInputAttributes;
|
||||||
|
@ -121,6 +122,7 @@ public final class SettingsValues {
|
||||||
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
|
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
|
||||||
|
|
||||||
// Compute other readable settings
|
// Compute other readable settings
|
||||||
|
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
|
||||||
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);
|
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);
|
||||||
mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res);
|
mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res);
|
||||||
mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res);
|
mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res);
|
||||||
|
|
Loading…
Reference in New Issue