Show underline for auto-completion candidate instead of bolding
Bug: 3230726 Change-Id: Iadc11992d45776f7a4002ee9ebf24828646bcc53
This commit is contained in:
parent
89c58745d6
commit
522d5c16d2
1 changed files with 14 additions and 4 deletions
|
@ -21,7 +21,12 @@ import android.content.res.Resources;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.text.SpannableString;
|
||||||
import android.text.TextUtils;
|
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.util.AttributeSet;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -50,6 +55,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
private final int mColorNormal;
|
private final int mColorNormal;
|
||||||
private final int mColorRecommended;
|
private final int mColorRecommended;
|
||||||
private final int mColorOther;
|
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;
|
private boolean mShowingCompletions;
|
||||||
|
|
||||||
|
@ -136,14 +143,17 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
|
|
||||||
View v = mWords.get(i);
|
View v = mWords.get(i);
|
||||||
TextView tv = (TextView)v.findViewById(R.id.candidate_word);
|
TextView tv = (TextView)v.findViewById(R.id.candidate_word);
|
||||||
tv.setTypeface(Typeface.DEFAULT);
|
|
||||||
tv.setTextColor(mColorNormal);
|
tv.setTextColor(mColorNormal);
|
||||||
if (haveMinimalSuggestion
|
if (haveMinimalSuggestion
|
||||||
&& ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
|
&& ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
|
||||||
// TODO: Display underline for the auto-correction word
|
final Spannable word = new SpannableString(suggestion);
|
||||||
tv.setTypeface(Typeface.DEFAULT_BOLD);
|
if (mConfigCandidateHighlightFontColorEnabled) {
|
||||||
if (mConfigCandidateHighlightFontColorEnabled)
|
word.setSpan(BOLD_SPAN, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
tv.setTextColor(mColorRecommended);
|
tv.setTextColor(mColorRecommended);
|
||||||
|
} else {
|
||||||
|
word.setSpan(UNDERLINE_SPAN, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
}
|
||||||
|
suggestion = word;
|
||||||
existsAutoCompletion = true;
|
existsAutoCompletion = true;
|
||||||
} else if (i != 0 || (wordLength == 1 && count > 1)) {
|
} else if (i != 0 || (wordLength == 1 && count > 1)) {
|
||||||
// HACK: even if i == 0, we use mColorOther when this
|
// HACK: even if i == 0, we use mColorOther when this
|
||||||
|
|
Loading…
Reference in a new issue