Introduce timeout for "." shortcut
Bug: 3294239 Change-Id: I1832be8b54cd4d55cd504a3e1e0434aa284f9592main
parent
db241a1038
commit
fc20f2198d
|
@ -60,6 +60,7 @@
|
||||||
<integer name="config_long_press_key_timeout">400</integer>
|
<integer name="config_long_press_key_timeout">400</integer>
|
||||||
<integer name="config_long_press_shift_key_timeout">1200</integer>
|
<integer name="config_long_press_shift_key_timeout">1200</integer>
|
||||||
<integer name="config_touch_noise_threshold_millis">40</integer>
|
<integer name="config_touch_noise_threshold_millis">40</integer>
|
||||||
|
<integer name="config_double_spaces_turn_into_period_timeout">1100</integer>
|
||||||
<dimen name="config_touch_noise_threshold_distance">2.0mm</dimen>
|
<dimen name="config_touch_noise_threshold_distance">2.0mm</dimen>
|
||||||
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
|
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
|
||||||
<string name="config_default_keyboard_theme_id" translatable="false">4</string>
|
<string name="config_default_keyboard_theme_id" translatable="false">4</string>
|
||||||
|
|
|
@ -181,6 +181,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private int mConfigDelayBeforeFadeoutLanguageOnSpacebar;
|
private int mConfigDelayBeforeFadeoutLanguageOnSpacebar;
|
||||||
private int mConfigDurationOfFadeoutLanguageOnSpacebar;
|
private int mConfigDurationOfFadeoutLanguageOnSpacebar;
|
||||||
private float mConfigFinalFadeoutFactorOfLanguageOnSpacebar;
|
private float mConfigFinalFadeoutFactorOfLanguageOnSpacebar;
|
||||||
|
private long mConfigDoubleSpacesTurnIntoPeriodTimeout;
|
||||||
|
|
||||||
private int mCorrectionMode;
|
private int mCorrectionMode;
|
||||||
private int mCommittedLength;
|
private int mCommittedLength;
|
||||||
|
@ -269,6 +270,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private static final int MSG_VOICE_RESULTS = 3;
|
private static final int MSG_VOICE_RESULTS = 3;
|
||||||
private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 4;
|
private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 4;
|
||||||
private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 5;
|
private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 5;
|
||||||
|
private static final int MSG_SPACE_TYPED = 6;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
@ -357,6 +359,20 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startDoubleSpacesTimer() {
|
||||||
|
removeMessages(MSG_SPACE_TYPED);
|
||||||
|
sendMessageDelayed(obtainMessage(MSG_SPACE_TYPED),
|
||||||
|
mConfigDoubleSpacesTurnIntoPeriodTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelDoubleSpacesTimer() {
|
||||||
|
removeMessages(MSG_SPACE_TYPED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAcceptingDoubleSpaces() {
|
||||||
|
return hasMessages(MSG_SPACE_TYPED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -398,6 +414,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
R.integer.config_duration_of_fadeout_language_on_spacebar);
|
R.integer.config_duration_of_fadeout_language_on_spacebar);
|
||||||
mConfigFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger(
|
mConfigFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger(
|
||||||
R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
|
R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
|
||||||
|
mConfigDoubleSpacesTurnIntoPeriodTimeout = res.getInteger(
|
||||||
|
R.integer.config_double_spaces_turn_into_period_timeout);
|
||||||
|
|
||||||
Utils.GCUtils.getInstance().reset();
|
Utils.GCUtils.getInstance().reset();
|
||||||
boolean tryGC = true;
|
boolean tryGC = true;
|
||||||
|
@ -1004,7 +1022,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doubleSpace() {
|
private void doubleSpace() {
|
||||||
//if (!mAutoPunctuate) return;
|
|
||||||
if (mCorrectionMode == Suggest.CORRECTION_NONE) return;
|
if (mCorrectionMode == Suggest.CORRECTION_NONE) return;
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic == null) return;
|
if (ic == null) return;
|
||||||
|
@ -1012,13 +1029,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (lastThree != null && lastThree.length() == 3
|
if (lastThree != null && lastThree.length() == 3
|
||||||
&& Character.isLetterOrDigit(lastThree.charAt(0))
|
&& Character.isLetterOrDigit(lastThree.charAt(0))
|
||||||
&& lastThree.charAt(1) == Keyboard.CODE_SPACE
|
&& lastThree.charAt(1) == Keyboard.CODE_SPACE
|
||||||
&& lastThree.charAt(2) == Keyboard.CODE_SPACE) {
|
&& lastThree.charAt(2) == Keyboard.CODE_SPACE
|
||||||
|
&& mHandler.isAcceptingDoubleSpaces()) {
|
||||||
|
mHandler.cancelDoubleSpacesTimer();
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
ic.deleteSurroundingText(2, 0);
|
ic.deleteSurroundingText(2, 0);
|
||||||
ic.commitText(". ", 1);
|
ic.commitText(". ", 1);
|
||||||
ic.endBatchEdit();
|
ic.endBatchEdit();
|
||||||
mKeyboardSwitcher.updateShiftState();
|
mKeyboardSwitcher.updateShiftState();
|
||||||
mJustAddedAutoSpace = true;
|
mJustAddedAutoSpace = true;
|
||||||
|
} else {
|
||||||
|
mHandler.startDoubleSpacesTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue