aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-12-13 16:11:50 +0900
committerJean Chalard <jchalard@google.com>2011-12-13 17:42:27 +0900
commit77d59b0691b8a9bd6cb336f07c175b88db53bbc0 (patch)
tree2d1b75fe7365f7d77c9d2b731463699027ded18c /java/src
parent0a2494fa5881152a9ed316409ae650353d8969fb (diff)
downloadlatinime-77d59b0691b8a9bd6cb336f07c175b88db53bbc0.tar.gz
latinime-77d59b0691b8a9bd6cb336f07c175b88db53bbc0.tar.xz
latinime-77d59b0691b8a9bd6cb336f07c175b88db53bbc0.zip
Consolidate underlining code under one function.
Change-Id: I4393ff1ec28a6b3118d1344dd6d82d04899dea42
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java35
1 files changed, 17 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index a67e4c938..eae983786 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1415,12 +1415,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final int length = mWordComposer.size();
if (length > 0) {
mWordComposer.deleteLast();
- final CharSequence textWithUnderline =
- mComposingStateManager.isAutoCorrectionIndicatorOn()
- ? SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(
- this, mWordComposer.getTypedWord())
- : mWordComposer.getTypedWord();
- ic.setComposingText(textWithUnderline, 1);
+ ic.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
if (mWordComposer.size() == 0) {
mHasUncommittedTypedChars = false;
// 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());
mComposingStateManager.onStartComposingText();
}
- final CharSequence textWithUnderline =
- mComposingStateManager.isAutoCorrectionIndicatorOn()
- ? SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(
- this, mWordComposer.getTypedWord())
- : mWordComposer.getTypedWord();
- ic.setComposingText(textWithUnderline, 1);
+ ic.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
}
mHandler.postUpdateSuggestions();
} 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() {
commitTyped(getCurrentInputConnection());
mVoiceProxy.handleClose();
@@ -1744,18 +1740,21 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mComposingStateManager.isAutoCorrectionIndicatorOn();
final boolean newAutoCorrectionIndicator = Utils.willAutoCorrect(words);
if (oldAutoCorrectionIndicator != newAutoCorrectionIndicator) {
- if (LatinImeLogger.sDBG) {
+ mComposingStateManager.setAutoCorrectionIndicatorOn(newAutoCorrectionIndicator);
+ if (DEBUG) {
Log.d(TAG, "Flip the indicator. " + oldAutoCorrectionIndicator
+ " -> " + 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
- ? SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(
- this, mWordComposer.getTypedWord())
- : mWordComposer.getTypedWord();
+ final CharSequence textWithUnderline =
+ getTextWithUnderline(mWordComposer.getTypedWord());
if (!TextUtils.isEmpty(textWithUnderline)) {
ic.setComposingText(textWithUnderline, 1);
}
- mComposingStateManager.setAutoCorrectionIndicatorOn(newAutoCorrectionIndicator);
}
}
}