Merge "Consolidate underlining code under one function."
This commit is contained in:
commit
c525750835
1 changed files with 17 additions and 18 deletions
|
@ -1415,12 +1415,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
final int length = mWordComposer.size();
|
final int length = mWordComposer.size();
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
mWordComposer.deleteLast();
|
mWordComposer.deleteLast();
|
||||||
final CharSequence textWithUnderline =
|
ic.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
|
||||||
mComposingStateManager.isAutoCorrectionIndicatorOn()
|
|
||||||
? SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(
|
|
||||||
this, mWordComposer.getTypedWord())
|
|
||||||
: mWordComposer.getTypedWord();
|
|
||||||
ic.setComposingText(textWithUnderline, 1);
|
|
||||||
if (mWordComposer.size() == 0) {
|
if (mWordComposer.size() == 0) {
|
||||||
mHasUncommittedTypedChars = false;
|
mHasUncommittedTypedChars = false;
|
||||||
// Remaining size equals zero means we just erased the last character of the
|
// Remaining size equals zero means we just erased the last character of the
|
||||||
|
@ -1552,12 +1547,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
mWordComposer.setAutoCapitalized(getCurrentAutoCapsState());
|
mWordComposer.setAutoCapitalized(getCurrentAutoCapsState());
|
||||||
mComposingStateManager.onStartComposingText();
|
mComposingStateManager.onStartComposingText();
|
||||||
}
|
}
|
||||||
final CharSequence textWithUnderline =
|
ic.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
|
||||||
mComposingStateManager.isAutoCorrectionIndicatorOn()
|
|
||||||
? SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(
|
|
||||||
this, mWordComposer.getTypedWord())
|
|
||||||
: mWordComposer.getTypedWord();
|
|
||||||
ic.setComposingText(textWithUnderline, 1);
|
|
||||||
}
|
}
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1671,6 +1661,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CharSequence getTextWithUnderline(final CharSequence text) {
|
||||||
|
return mComposingStateManager.isAutoCorrectionIndicatorOn()
|
||||||
|
? SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(this, text)
|
||||||
|
: mWordComposer.getTypedWord();
|
||||||
|
}
|
||||||
|
|
||||||
private void handleClose() {
|
private void handleClose() {
|
||||||
commitTyped(getCurrentInputConnection());
|
commitTyped(getCurrentInputConnection());
|
||||||
mVoiceProxy.handleClose();
|
mVoiceProxy.handleClose();
|
||||||
|
@ -1744,18 +1740,21 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
mComposingStateManager.isAutoCorrectionIndicatorOn();
|
mComposingStateManager.isAutoCorrectionIndicatorOn();
|
||||||
final boolean newAutoCorrectionIndicator = Utils.willAutoCorrect(words);
|
final boolean newAutoCorrectionIndicator = Utils.willAutoCorrect(words);
|
||||||
if (oldAutoCorrectionIndicator != newAutoCorrectionIndicator) {
|
if (oldAutoCorrectionIndicator != newAutoCorrectionIndicator) {
|
||||||
if (LatinImeLogger.sDBG) {
|
mComposingStateManager.setAutoCorrectionIndicatorOn(newAutoCorrectionIndicator);
|
||||||
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Flip the indicator. " + oldAutoCorrectionIndicator
|
Log.d(TAG, "Flip the indicator. " + oldAutoCorrectionIndicator
|
||||||
+ " -> " + newAutoCorrectionIndicator);
|
+ " -> " + newAutoCorrectionIndicator);
|
||||||
|
if (newAutoCorrectionIndicator
|
||||||
|
!= mComposingStateManager.isAutoCorrectionIndicatorOn()) {
|
||||||
|
throw new RuntimeException("Couldn't flip the indicator! We are not "
|
||||||
|
+ "composing a word right now.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final CharSequence textWithUnderline = newAutoCorrectionIndicator
|
final CharSequence textWithUnderline =
|
||||||
? SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(
|
getTextWithUnderline(mWordComposer.getTypedWord());
|
||||||
this, mWordComposer.getTypedWord())
|
|
||||||
: mWordComposer.getTypedWord();
|
|
||||||
if (!TextUtils.isEmpty(textWithUnderline)) {
|
if (!TextUtils.isEmpty(textWithUnderline)) {
|
||||||
ic.setComposingText(textWithUnderline, 1);
|
ic.setComposingText(textWithUnderline, 1);
|
||||||
}
|
}
|
||||||
mComposingStateManager.setAutoCorrectionIndicatorOn(newAutoCorrectionIndicator);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue