Merge remote-tracking branch 'goog/master' into mergescriptpackage

main
Ken Wakasa 2012-12-06 12:24:05 +09:00
commit 12445fd8f6
2 changed files with 23 additions and 23 deletions

View File

@ -41,7 +41,7 @@
<integer name="config_more_keys_keyboard_fadeout_anim_time">100</integer> <integer name="config_more_keys_keyboard_fadeout_anim_time">100</integer>
<integer name="config_keyboard_grid_width">32</integer> <integer name="config_keyboard_grid_width">32</integer>
<integer name="config_keyboard_grid_height">16</integer> <integer name="config_keyboard_grid_height">16</integer>
<integer name="config_double_spaces_turn_into_period_timeout">1100</integer> <integer name="config_double_space_period_timeout">1100</integer>
<!-- 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_index" translatable="false">5</string> <string name="config_default_keyboard_theme_index" translatable="false">5</string>
<integer name="config_max_more_keys_column">5</integer> <integer name="config_max_more_keys_column">5</integer>

View File

@ -193,8 +193,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private int mDelayUpdateSuggestions; private int mDelayUpdateSuggestions;
private int mDelayUpdateShiftState; private int mDelayUpdateShiftState;
private long mDoubleSpacesTurnIntoPeriodTimeout; private long mDoubleSpacePeriodTimeout;
private long mDoubleSpaceTimerStart; private long mDoubleSpacePeriodTimerStart;
public UIHandler(final LatinIME outerInstance) { public UIHandler(final LatinIME outerInstance) {
super(outerInstance); super(outerInstance);
@ -206,8 +206,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
res.getInteger(R.integer.config_delay_update_suggestions); res.getInteger(R.integer.config_delay_update_suggestions);
mDelayUpdateShiftState = mDelayUpdateShiftState =
res.getInteger(R.integer.config_delay_update_shift_state); res.getInteger(R.integer.config_delay_update_shift_state);
mDoubleSpacesTurnIntoPeriodTimeout = res.getInteger( mDoubleSpacePeriodTimeout =
R.integer.config_double_spaces_turn_into_period_timeout); res.getInteger(R.integer.config_double_space_period_timeout);
} }
@Override @Override
@ -258,17 +258,17 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
.sendToTarget(); .sendToTarget();
} }
public void startDoubleSpacesTimer() { public void startDoubleSpacePeriodTimer() {
mDoubleSpaceTimerStart = SystemClock.uptimeMillis(); mDoubleSpacePeriodTimerStart = SystemClock.uptimeMillis();
} }
public void cancelDoubleSpacesTimer() { public void cancelDoubleSpacePeriodTimer() {
mDoubleSpaceTimerStart = 0; mDoubleSpacePeriodTimerStart = 0;
} }
public boolean isAcceptingDoubleSpaces() { public boolean isAcceptingDoubleSpacePeriod() {
return SystemClock.uptimeMillis() - mDoubleSpaceTimerStart return SystemClock.uptimeMillis() - mDoubleSpacePeriodTimerStart
< mDoubleSpacesTurnIntoPeriodTimeout; < mDoubleSpacePeriodTimeout;
} }
// Working variables for the following methods. // Working variables for the following methods.
@ -770,7 +770,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mLastSelectionEnd = editorInfo.initialSelEnd; mLastSelectionEnd = editorInfo.initialSelEnd;
mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelUpdateSuggestionStrip();
mHandler.cancelDoubleSpacesTimer(); mHandler.cancelDoubleSpacePeriodTimer();
mainKeyboardView.setMainDictionaryAvailability(mIsMainDictionaryAvailable); mainKeyboardView.setMainDictionaryAvailability(mIsMainDictionaryAvailable);
mainKeyboardView.setKeyPreviewPopupEnabled(mCurrentSettings.mKeyPreviewPopupOn, mainKeyboardView.setKeyPreviewPopupEnabled(mCurrentSettings.mKeyPreviewPopupOn,
@ -1175,16 +1175,16 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
} }
} }
private boolean maybeDoubleSpace() { private boolean maybeDoubleSpacePeriod() {
if (!mCurrentSettings.mCorrectionEnabled) return false; if (!mCurrentSettings.mCorrectionEnabled) return false;
if (!mCurrentSettings.mUseDoubleSpacePeriod) return false; if (!mCurrentSettings.mUseDoubleSpacePeriod) return false;
if (!mHandler.isAcceptingDoubleSpaces()) return false; if (!mHandler.isAcceptingDoubleSpacePeriod()) return false;
final CharSequence lastThree = mConnection.getTextBeforeCursor(3, 0); final CharSequence lastThree = mConnection.getTextBeforeCursor(3, 0);
if (lastThree != null && lastThree.length() == 3 if (lastThree != null && lastThree.length() == 3
&& canBeFollowedByPeriod(lastThree.charAt(0)) && canBeFollowedByDoubleSpacePeriod(lastThree.charAt(0))
&& lastThree.charAt(1) == Constants.CODE_SPACE && lastThree.charAt(1) == Constants.CODE_SPACE
&& lastThree.charAt(2) == Constants.CODE_SPACE) { && lastThree.charAt(2) == Constants.CODE_SPACE) {
mHandler.cancelDoubleSpacesTimer(); mHandler.cancelDoubleSpacePeriodTimer();
mConnection.deleteSurroundingText(2, 0); mConnection.deleteSurroundingText(2, 0);
mConnection.commitText(". ", 1); mConnection.commitText(". ", 1);
mKeyboardSwitcher.updateShiftState(); mKeyboardSwitcher.updateShiftState();
@ -1193,7 +1193,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
return false; return false;
} }
private static boolean canBeFollowedByPeriod(final int codePoint) { private static boolean canBeFollowedByDoubleSpacePeriod(final int codePoint) {
// TODO: Check again whether there really ain't a better way to check this. // TODO: Check again whether there really ain't a better way to check this.
// TODO: This should probably be language-dependant... // TODO: This should probably be language-dependant...
return Character.isLetterOrDigit(codePoint) return Character.isLetterOrDigit(codePoint)
@ -1315,9 +1315,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
final int spaceState = mSpaceState; final int spaceState = mSpaceState;
if (!mWordComposer.isComposingWord()) mIsAutoCorrectionIndicatorOn = false; if (!mWordComposer.isComposingWord()) mIsAutoCorrectionIndicatorOn = false;
// TODO: Consolidate the double space timer, mLastKeyTime, and the space state. // TODO: Consolidate the double-space period timer, mLastKeyTime, and the space state.
if (primaryCode != Constants.CODE_SPACE) { if (primaryCode != Constants.CODE_SPACE) {
mHandler.cancelDoubleSpacesTimer(); mHandler.cancelDoubleSpacePeriodTimer();
} }
boolean didAutoCorrect = false; boolean didAutoCorrect = false;
@ -1661,7 +1661,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
return; return;
} }
if (SPACE_STATE_DOUBLE == spaceState) { if (SPACE_STATE_DOUBLE == spaceState) {
mHandler.cancelDoubleSpacesTimer(); mHandler.cancelDoubleSpacePeriodTimer();
if (mConnection.revertDoubleSpace()) { if (mConnection.revertDoubleSpace()) {
// No need to reset mSpaceState, it has already be done (that's why we // No need to reset mSpaceState, it has already be done (that's why we
// receive it as a parameter) // receive it as a parameter)
@ -1823,14 +1823,14 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
if (Constants.CODE_SPACE == primaryCode) { if (Constants.CODE_SPACE == primaryCode) {
if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) { if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) {
if (maybeDoubleSpace()) { if (maybeDoubleSpacePeriod()) {
mSpaceState = SPACE_STATE_DOUBLE; mSpaceState = SPACE_STATE_DOUBLE;
} else if (!isShowingPunctuationList()) { } else if (!isShowingPunctuationList()) {
mSpaceState = SPACE_STATE_WEAK; mSpaceState = SPACE_STATE_WEAK;
} }
} }
mHandler.startDoubleSpacesTimer(); mHandler.startDoubleSpacePeriodTimer();
if (!mConnection.isCursorTouchingWord(mCurrentSettings)) { if (!mConnection.isCursorTouchingWord(mCurrentSettings)) {
mHandler.postUpdateSuggestionStrip(); mHandler.postUpdateSuggestionStrip();
} }