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