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.java38
1 files changed, 31 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index d2d1f22dd..9699ad136 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -16,8 +16,11 @@
package com.android.inputmethod.latin;
+import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
+
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Handler;
import android.os.Message;
@@ -43,6 +46,7 @@ import android.widget.PopupWindow;
import android.widget.TextView;
import java.util.ArrayList;
+import java.util.List;
public class CandidateView extends LinearLayout implements OnClickListener, OnLongClickListener {
@@ -50,6 +54,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
private static final int MAX_SUGGESTIONS = 16;
+ private static final boolean DBG = LatinImeLogger.sDBG;
+
private final ArrayList<View> mWords = new ArrayList<View>();
private final boolean mConfigCandidateHighlightFontColorEnabled;
private final CharacterStyle mInvertedForegroundColorSpan;
@@ -175,11 +181,12 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final SuggestedWords suggestions = mSuggestions;
clear();
final int count = suggestions.size();
- final Object[] debugInfo = suggestions.mDebugInfo;
for (int i = 0; i < count; i++) {
CharSequence word = suggestions.getWord(i);
if (word == null) continue;
final int wordLength = word.length();
+ final List<SuggestedWordInfo> suggestedWordInfoList =
+ suggestions.mSuggestedWordInfoList;
final View v = mWords.get(i);
final TextView tv = (TextView)v.findViewById(R.id.candidate_word);
@@ -209,10 +216,25 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
tv.setText(word);
tv.setClickable(true);
- if (debugInfo != null && i < debugInfo.length && debugInfo[i] != null
- && !TextUtils.isEmpty(debugInfo[i].toString())) {
- dv.setText(debugInfo[i].toString());
- dv.setVisibility(VISIBLE);
+
+ if (suggestedWordInfoList != null && suggestedWordInfoList.get(i) != null) {
+ final SuggestedWordInfo info = suggestedWordInfoList.get(i);
+ if (info.isPreviousSuggestedWord()) {
+ int color = tv.getCurrentTextColor();
+ tv.setTextColor(Color.argb((int)(Color.alpha(color) * 0.5f), Color.red(color),
+ Color.green(color), Color.blue(color)));
+ }
+ final String debugString = info.getDebugString();
+ if (DBG) {
+ if (TextUtils.isEmpty(debugString)) {
+ dv.setVisibility(GONE);
+ } else {
+ dv.setText(debugString);
+ dv.setVisibility(VISIBLE);
+ }
+ } else {
+ dv.setVisibility(GONE);
+ }
} else {
dv.setVisibility(GONE);
}
@@ -231,8 +253,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final TextView tv = (TextView)mWords.get(1).findViewById(R.id.candidate_word);
final Spannable word = new SpannableString(autoCorrectedWord);
final int wordLength = word.length();
- word.setSpan(mInvertedBackgroundColorSpan, 0, wordLength, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
- word.setSpan(mInvertedForegroundColorSpan, 0, wordLength, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ word.setSpan(mInvertedBackgroundColorSpan, 0, wordLength,
+ Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ word.setSpan(mInvertedForegroundColorSpan, 0, wordLength,
+ Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
tv.setText(word);
mShowingAutoCorrectionInverted = true;
}