aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/CandidateView.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-02-10 17:31:37 +0900
committersatok <satok@google.com>2011-02-10 17:31:37 +0900
commita7ea6cad8269c2b621dbf585ed90121b495f6ebc (patch)
treeefe9106dacb45cf2cf4f17d80f870a030436ca53 /java/src/com/android/inputmethod/latin/CandidateView.java
parentb7b83125544964bf128e07456edfd0170d889dc4 (diff)
parent03b5579b3b7380f8e12519cca1662317282c6bd9 (diff)
downloadlatinime-a7ea6cad8269c2b621dbf585ed90121b495f6ebc.tar.gz
latinime-a7ea6cad8269c2b621dbf585ed90121b495f6ebc.tar.xz
latinime-a7ea6cad8269c2b621dbf585ed90121b495f6ebc.zip
Merge remote branch 'goog/master' into merge
Conflicts: java/res/xml/method.xml java/src/com/android/inputmethod/latin/LatinIME.java java/src/com/android/inputmethod/latin/SubtypeSwitcher.java java/src/com/android/inputmethod/voice/VoiceIMEConnector.java Change-Id: I9b62da120dcc08327fde92459ee5c7564a5eb6b8
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;
}