Merge "Code cleanup"
commit
656a35f9df
|
@ -740,12 +740,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
ic.finishComposingText();
|
||||
}
|
||||
mVoiceProxy.setVoiceInputHighlighted(false);
|
||||
} else if (!mHasUncommittedTypedChars && !mExpectingUpdateSelection) {
|
||||
if (TextEntryState.isAcceptedDefault() || TextEntryState.isSpaceAfterPicked()) {
|
||||
if (TextEntryState.isAcceptedDefault())
|
||||
} else if (!mHasUncommittedTypedChars && !mExpectingUpdateSelection
|
||||
&& TextEntryState.isAcceptedDefault()) {
|
||||
TextEntryState.reset();
|
||||
}
|
||||
}
|
||||
if (!mExpectingUpdateSelection) {
|
||||
mJustAddedMagicSpace = false; // The user moved the cursor.
|
||||
mJustReplacedDoubleSpace = false;
|
||||
|
@ -945,7 +943,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
|
||||
public void commitTyped(InputConnection inputConnection) {
|
||||
if (mHasUncommittedTypedChars) {
|
||||
if (!mHasUncommittedTypedChars) return;
|
||||
mHasUncommittedTypedChars = false;
|
||||
if (mComposingStringBuilder.length() > 0) {
|
||||
if (inputConnection != null) {
|
||||
|
@ -958,7 +956,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
updateSuggestions();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getCurrentAutoCapsState() {
|
||||
InputConnection ic = getCurrentInputConnection();
|
||||
|
@ -1500,18 +1497,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
|
||||
mKeyboardSwitcher.getKeyboardView(), wordComposer, prevWord);
|
||||
|
||||
boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection();
|
||||
boolean autoCorrectionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection();
|
||||
final CharSequence typedWord = wordComposer.getTypedWord();
|
||||
// Here, we want to promote a whitelisted word if exists.
|
||||
final boolean typedWordValid = AutoCorrection.isValidWordForAutoCorrection(
|
||||
mSuggest.getUnigramDictionaries(), typedWord, preferCapitalization());
|
||||
if (mCorrectionMode == Suggest.CORRECTION_FULL
|
||||
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
||||
correctionAvailable |= typedWordValid;
|
||||
autoCorrectionAvailable |= typedWordValid;
|
||||
}
|
||||
// Don't auto-correct words with multiple capital letter
|
||||
correctionAvailable &= !wordComposer.isMostlyCaps();
|
||||
correctionAvailable &= !TextEntryState.isRecorrecting();
|
||||
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
|
||||
autoCorrectionAvailable &= !TextEntryState.isRecorrecting();
|
||||
|
||||
// Basically, we update the suggestion strip only when suggestion count > 1. However,
|
||||
// there is an exception: We update the suggestion strip whenever typed word's length
|
||||
|
@ -1523,7 +1520,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
if (builder.size() > 1 || typedWord.length() == 1 || typedWordValid
|
||||
|| mCandidateView.isShowingAddToDictionaryHint()) {
|
||||
builder.setTypedWordValid(typedWordValid).setHasMinimalSuggestion(
|
||||
correctionAvailable);
|
||||
autoCorrectionAvailable);
|
||||
} else {
|
||||
final SuggestedWords previousSuggestions = mCandidateView.getSuggestions();
|
||||
if (previousSuggestions == mSettingsValues.mSuggestPuncList)
|
||||
|
@ -1681,8 +1678,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
|
||||
/**
|
||||
* Commits the chosen word to the text field and saves it for later
|
||||
* retrieval.
|
||||
* Commits the chosen word to the text field and saves it for later retrieval.
|
||||
*/
|
||||
private void commitBestWord(CharSequence bestWord) {
|
||||
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||
|
@ -1799,8 +1795,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
|
||||
private void revertLastWord(boolean deleteChar) {
|
||||
final int length = mComposingStringBuilder.length();
|
||||
if (!mHasUncommittedTypedChars && length > 0) {
|
||||
if (mHasUncommittedTypedChars || mComposingStringBuilder.length() <= 0) {
|
||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
||||
return;
|
||||
}
|
||||
|
||||
final InputConnection ic = getCurrentInputConnection();
|
||||
final CharSequence punctuation = ic.getTextBeforeCursor(1, 0);
|
||||
if (deleteChar) ic.deleteSurroundingText(1, 0);
|
||||
|
@ -1831,9 +1830,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
mHandler.cancelUpdateBigramPredictions();
|
||||
mHandler.postUpdateSuggestions();
|
||||
} else {
|
||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean revertDoubleSpace() {
|
||||
|
|
Loading…
Reference in New Issue