aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-09-13 12:35:52 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-09-13 12:54:59 +0900
commit697bf585f8dac6ffc4d008c02b63407cfdd83104 (patch)
tree5e36caa08571740548ed1637650139cbe1593f58 /java/src
parentcd15b9300fcf064e0ba5b1292088ede118a6a00c (diff)
downloadlatinime-697bf585f8dac6ffc4d008c02b63407cfdd83104.tar.gz
latinime-697bf585f8dac6ffc4d008c02b63407cfdd83104.tar.xz
latinime-697bf585f8dac6ffc4d008c02b63407cfdd83104.zip
Update suggestions strip text color
Bug: 5287964 Change-Id: Ic40bb656873f41bb6d65427f02399464e831aab2
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestionsView.java30
1 files changed, 23 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java
index 380e73bc0..b00036b49 100644
--- a/java/src/com/android/inputmethod/latin/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java
@@ -163,6 +163,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private final int mColorTypedWord;
private final int mColorAutoCorrect;
private final int mColorSuggested;
+ private final float mAlphaObsoleted;
private final float mCenterSuggestionWeight;
private final int mCenterSuggestionIndex;
private final Drawable mMoreSuggestionsHint;
@@ -205,15 +206,26 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.SuggestionsView, defStyle, R.style.SuggestionsViewStyle);
mSuggestionStripOption = a.getInt(R.styleable.SuggestionsView_suggestionStripOption, 0);
- mColorTypedWord = a.getColor(R.styleable.SuggestionsView_colorTypedWord, 0);
- mColorAutoCorrect = a.getColor(R.styleable.SuggestionsView_colorAutoCorrect, 0);
- mColorSuggested = a.getColor(R.styleable.SuggestionsView_colorSuggested, 0);
+ final float alphaTypedWord = getPercent(a,
+ R.styleable.SuggestionsView_alphaTypedWord, 100);
+ final float alphaAutoCorrect = getPercent(a,
+ R.styleable.SuggestionsView_alphaAutoCorrect, 100);
+ final float alphaSuggested = getPercent(a,
+ R.styleable.SuggestionsView_alphaSuggested, 100);
+ mAlphaObsoleted = getPercent(a, R.styleable.SuggestionsView_alphaSuggested, 100);
+ mColorTypedWord = applyAlpha(
+ a.getColor(R.styleable.SuggestionsView_colorTypedWord, 0), alphaTypedWord);
+ mColorAutoCorrect = applyAlpha(
+ a.getColor(R.styleable.SuggestionsView_colorAutoCorrect, 0), alphaAutoCorrect);
+ mColorSuggested = applyAlpha(
+ a.getColor(R.styleable.SuggestionsView_colorSuggested, 0), alphaSuggested);
mSuggestionsCountInStrip = a.getInt(
R.styleable.SuggestionsView_suggestionsCountInStrip,
DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
- mCenterSuggestionWeight = a.getInt(
+ mCenterSuggestionWeight = getPercent(a,
R.styleable.SuggestionsView_centerSuggestionPercentile,
- DEFAULT_CENTER_SUGGESTION_PERCENTILE) / 100.0f;
+ DEFAULT_CENTER_SUGGESTION_PERCENTILE);
+ mMoreSuggestionsHint = a.getDrawable(R.styleable.SuggestionsView_moreSuggestionsHint);
mMaxMoreSuggestionsRow = a.getInt(
R.styleable.SuggestionsView_maxMoreSuggestionsRow,
DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
@@ -222,7 +234,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
a.recycle();
mCenterSuggestionIndex = mSuggestionsCountInStrip / 2;
- mMoreSuggestionsHint = res.getDrawable(R.drawable.more_suggestions_hint);
mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(
R.dimen.more_suggestions_bottom_gap);
@@ -235,6 +246,11 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
}
+ // Read integer value in TypedArray as percent.
+ private static float getPercent(TypedArray a, int index, int defValue) {
+ return a.getInt(index, defValue) / 100.0f;
+ }
+
// Read fraction value in TypedArray as float.
private static float getRatio(TypedArray a, int index) {
return a.getFraction(index, 1000, 1000, 1) / 1000.0f;
@@ -293,7 +309,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
final SuggestedWordInfo info = (pos < suggestions.size())
? suggestions.getInfo(pos) : null;
if (info != null && info.isObsoleteSuggestedWord()) {
- return applyAlpha(color, 0.5f);
+ return applyAlpha(color, mAlphaObsoleted);
} else {
return color;
}