aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-08-22 03:32:05 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-22 03:32:05 -0700
commit9f315750452ff187d06a11148005f42419483f0c (patch)
treeef82d82598524c1b0fbe486c778689f4471bfeed /java/src
parent70a92a33f87cba5ca84d603eb765d95bafab7789 (diff)
parentd47a955610987c8abdab4d275c044aefc8a7f1db (diff)
downloadlatinime-9f315750452ff187d06a11148005f42419483f0c.tar.gz
latinime-9f315750452ff187d06a11148005f42419483f0c.tar.xz
latinime-9f315750452ff187d06a11148005f42419483f0c.zip
Merge "Fix suggestions strip text colors"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index f499bc0bb..d46b4b5b5 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -272,9 +272,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private static final int AUTO_CORRECT_BOLD = 0x01;
private static final int AUTO_CORRECT_UNDERLINE = 0x02;
private static final int AUTO_CORRECT_INVERT = 0x04;
+ private static final int VALID_TYPED_WORD_BOLD = 0x08;
private final TextPaint mPaint;
- private final int mAutoCorrectHighlight;
+ private final int mSuggestionStripOption;
private final ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>();
@@ -285,7 +286,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
super(words, dividers, infos);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.CandidateView, defStyle, R.style.CandidateViewStyle);
- mAutoCorrectHighlight = a.getInt(R.styleable.CandidateView_autoCorrectHighlight, 0);
+ mSuggestionStripOption = a.getInt(R.styleable.CandidateView_suggestionStripOption, 0);
mColorTypedWord = a.getColor(R.styleable.CandidateView_colorTypedWord, 0);
mColorAutoCorrect = a.getColor(R.styleable.CandidateView_colorAutoCorrect, 0);
mColorSuggestedCandidate = a.getColor(R.styleable.CandidateView_colorSuggested, 0);
@@ -313,15 +314,23 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
return mColorTypedWord;
}
- private CharSequence getStyledCandidateWord(CharSequence word, boolean isAutoCorrect) {
- if (!isAutoCorrect)
+ private CharSequence getStyledCandidateWord(SuggestedWords suggestions, int pos) {
+ final CharSequence word = suggestions.getWord(pos);
+ final boolean isAutoCorrect = pos == 1 && willAutoCorrect(suggestions);
+ final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid;
+ if (!isAutoCorrect && !isTypedWordValid)
return word;
+
final int len = word.length();
final Spannable spannedWord = new SpannableString(word);
- if ((mAutoCorrectHighlight & AUTO_CORRECT_BOLD) != 0)
+ final int option = mSuggestionStripOption;
+ if ((isAutoCorrect && (option & AUTO_CORRECT_BOLD) != 0)
+ || (isTypedWordValid && (option & VALID_TYPED_WORD_BOLD) != 0)) {
spannedWord.setSpan(BOLD_SPAN, 0, len, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
- if ((mAutoCorrectHighlight & AUTO_CORRECT_UNDERLINE) != 0)
+ }
+ if (isAutoCorrect && (option & AUTO_CORRECT_UNDERLINE) != 0) {
spannedWord.setSpan(UNDERLINE_SPAN, 0, len, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ }
return spannedWord;
}
@@ -370,7 +379,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
public CharSequence getInvertedText(CharSequence text) {
- if ((mAutoCorrectHighlight & AUTO_CORRECT_INVERT) == 0)
+ if ((mSuggestionStripOption & AUTO_CORRECT_INVERT) == 0)
return null;
final int len = text.length();
final Spannable word = new SpannableString(text);
@@ -457,9 +466,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mTexts.clear();
final int count = Math.min(suggestions.size(), countInStrip);
for (int pos = 0; pos < count; pos++) {
- final CharSequence word = suggestions.getWord(pos);
- final boolean isAutoCorrect = pos == 1 && willAutoCorrect(suggestions);
- final CharSequence styled = getStyledCandidateWord(word, isAutoCorrect);
+ final CharSequence styled = getStyledCandidateWord(suggestions, pos);
mTexts.add(styled);
}
for (int pos = count; pos < countInStrip; pos++) {