diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 9a66e00f2..1066c08d5 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1326,10 +1326,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // Not a tld: do nothing. return text; } + // We have a TLD (or something that looks like this): make sure we don't add + // a space even if currently in phantom mode. + mSpaceState = SPACE_STATE_NONE; final CharSequence lastOne = ic.getTextBeforeCursor(1, 0); if (lastOne != null && lastOne.length() == 1 && lastOne.charAt(0) == Keyboard.CODE_PERIOD) { - mSpaceState = SPACE_STATE_NONE; return text.subSequence(1, text.length()); } else { return text; @@ -1398,7 +1400,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } if (SPACE_STATE_DOUBLE == spaceState) { - if (revertDoubleSpace(ic)) { + if (revertDoubleSpaceWhileInBatchEdit(ic)) { // No need to reset mSpaceState, it has already be done (that's why we // receive it as a parameter) return; @@ -1531,11 +1533,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar sendKeyChar((char)code); } - if (mSettingsValues.isWordSeparator(code)) { - Utils.Stats.onSeparator((char)code, x, y); - } else { - Utils.Stats.onNonSeparator((char)code, x, y); - } + Utils.Stats.onNonSeparator((char)code, x, y); } // Returns true if we did an autocorrection, false otherwise. @@ -1868,20 +1866,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } @Override - public void pickSuggestionManually(int index, CharSequence suggestion) { + public void pickSuggestionManually(final int index, final CharSequence suggestion) { mComposingStateManager.onFinishComposingText(); - SuggestedWords suggestions = mSuggestionsView.getSuggestions(); + final SuggestedWords suggestions = mSuggestionsView.getSuggestions(); mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion, mSettingsValues.mWordSeparators); - final InputConnection ic = getCurrentInputConnection(); - if (ic != null) { - ic.beginBatchEdit(); - } if (mInputAttributes.mApplicationSpecifiedCompletionOn && mApplicationSpecifiedCompletions != null && index >= 0 && index < mApplicationSpecifiedCompletions.length) { + final InputConnection ic = getCurrentInputConnection(); if (ic != null) { + ic.beginBatchEdit(); final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index]; ic.commitCompletion(completionInfo); } @@ -1902,18 +1898,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // So, LatinImeLogger logs "" as a user's input. LatinImeLogger.logOnManualSuggestion( "", suggestion.toString(), index, suggestions.mWords); - final CharSequence outputText = mSettingsValues.mSuggestPuncOutputTextList - .getWord(index); - final int primaryCode = outputText.charAt(0); + final int primaryCode = suggestion.charAt(0); // Find out whether the previous character is a space. If it is, as a special case // for punctuation entered through the suggestion strip, it should be swapped // if it was a magic or a weak space. This is meant to help in case the user // pressed space on purpose of displaying the suggestion strip punctuation. insertPunctuationFromSuggestionStrip(primaryCode); - // TODO: the following endBatchEdit seems useless, check - if (ic != null) { - ic.endBatchEdit(); - } return; } // We need to log before we commit, because the word composer will store away the user @@ -1966,9 +1956,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mHandler.postUpdateSuggestions(); } } - if (ic != null) { - ic.endBatchEdit(); - } } /** @@ -2218,7 +2205,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } // "ic" must not be null - private boolean revertDoubleSpace(final InputConnection ic) { + private boolean revertDoubleSpaceWhileInBatchEdit(final InputConnection ic) { mHandler.cancelDoubleSpacesTimer(); // Here we test whether we indeed have a period and a space before us. This should not // be needed, but it's there just in case something went wrong. @@ -2231,10 +2218,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar + "\". \" just before the cursor."); return false; } - ic.beginBatchEdit(); ic.deleteSurroundingText(2, 0); ic.commitText(" ", 1); - ic.endBatchEdit(); return true; } |