aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/CandidateView.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/CandidateView.java')
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java35
1 files changed, 23 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index 460ef8650..bb3c09d60 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -21,7 +21,12 @@ import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Handler;
import android.os.Message;
+import android.text.Spannable;
+import android.text.SpannableString;
import android.text.TextUtils;
+import android.text.style.CharacterStyle;
+import android.text.style.StyleSpan;
+import android.text.style.UnderlineSpan;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -50,6 +55,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private final int mColorNormal;
private final int mColorRecommended;
private final int mColorOther;
+ private static final StyleSpan BOLD_SPAN = new StyleSpan(Typeface.BOLD);
+ private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
private boolean mShowingCompletions;
@@ -136,21 +143,25 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
View v = mWords.get(i);
TextView tv = (TextView)v.findViewById(R.id.candidate_word);
- tv.setTypeface(Typeface.DEFAULT);
tv.setTextColor(mColorNormal);
- if (mConfigCandidateHighlightFontColorEnabled) {
- if (haveMinimalSuggestion
- && ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
- tv.setTypeface(Typeface.DEFAULT_BOLD);
+ if (haveMinimalSuggestion
+ && ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
+ final Spannable word = new SpannableString(suggestion);
+ if (mConfigCandidateHighlightFontColorEnabled) {
+ word.setSpan(BOLD_SPAN, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
tv.setTextColor(mColorRecommended);
- existsAutoCompletion = true;
- } else if (i != 0 || (wordLength == 1 && count > 1)) {
- // HACK: even if i == 0, we use mColorOther when this suggestion's length is 1
- // and there are multiple suggestions, such as the default punctuation list.
- tv.setTextColor(mColorOther);
+ } else {
+ word.setSpan(UNDERLINE_SPAN, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
- } else {
- // TODO: Display underline for the auto-correction word
+ suggestion = word;
+ existsAutoCompletion = true;
+ } else if (i != 0 || (wordLength == 1 && count > 1)) {
+ // HACK: even if i == 0, we use mColorOther when this
+ // suggestion's length is 1
+ // and there are multiple suggestions, such as the default
+ // punctuation list.
+ if (mConfigCandidateHighlightFontColorEnabled)
+ tv.setTextColor(mColorOther);
}
tv.setText(suggestion);
tv.setClickable(true);