Update suggestions strip text color

Bug: 5287964
Change-Id: Ic40bb656873f41bb6d65427f02399464e831aab2
main
Tadashi G. Takaoka 2011-09-13 12:35:52 +09:00
parent cd15b9300f
commit 697bf585f8
6 changed files with 40 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

View File

@ -126,8 +126,13 @@
<attr name="colorTypedWord" format="color" /> <attr name="colorTypedWord" format="color" />
<attr name="colorAutoCorrect" format="color" /> <attr name="colorAutoCorrect" format="color" />
<attr name="colorSuggested" format="color" /> <attr name="colorSuggested" format="color" />
<attr name="alphaTypedWord" format="integer" />
<attr name="alphaAutoCorrect" format="integer" />
<attr name="alphaSuggested" format="integer" />
<attr name="alphaObsoleted" format="integer" />
<attr name="suggestionsCountInStrip" format="integer" /> <attr name="suggestionsCountInStrip" format="integer" />
<attr name="centerSuggestionPercentile" format="integer" /> <attr name="centerSuggestionPercentile" format="integer" />
<attr name="moreSuggestionsHint" format="reference" />
<attr name="maxMoreSuggestionsRow" format="integer" /> <attr name="maxMoreSuggestionsRow" format="integer" />
<attr name="minMoreSuggestionsWidth" format="float" /> <attr name="minMoreSuggestionsWidth" format="float" />
</declare-styleable> </declare-styleable>

View File

@ -96,11 +96,13 @@
parent="SuggestionsStripBackgroundStyle" parent="SuggestionsStripBackgroundStyle"
> >
<item name="suggestionStripOption">autoCorrectBold</item> <item name="suggestionStripOption">autoCorrectBold</item>
<item name="colorTypedWord">#FFFFFFFF</item> <item name="colorTypedWord">@android:color/white</item>
<item name="colorAutoCorrect">#FFFCAE00</item> <item name="colorAutoCorrect">#FFFCAE00</item>
<item name="colorSuggested">#FFFCAE00</item> <item name="colorSuggested">#FFFCAE00</item>
<item name="alphaObsoleted">50</item>
<item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item> <item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item>
<item name="centerSuggestionPercentile">@integer/center_suggestion_percentile</item> <item name="centerSuggestionPercentile">@integer/center_suggestion_percentile</item>
<item name="moreSuggestionsHint">@drawable/more_suggestions_hint</item>
<item name="maxMoreSuggestionsRow">@integer/max_more_suggestions_row</item> <item name="maxMoreSuggestionsRow">@integer/max_more_suggestions_row</item>
<item name="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item> <item name="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item>
</style> </style>
@ -272,11 +274,17 @@
parent="SuggestionsStripBackgroundStyle.IceCreamSandwich" parent="SuggestionsStripBackgroundStyle.IceCreamSandwich"
> >
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
<item name="colorTypedWord">#FFBCBEC0</item> <!-- android:color/holo_blue_light=#FF33B5E5 -->
<item name="colorAutoCorrect">#FF0099CC</item> <item name="colorTypedWord">@android:color/holo_blue_light</item>
<item name="colorSuggested">#FFA7A9AC</item> <item name="colorAutoCorrect">@android:color/holo_blue_light</item>
<item name="colorSuggested">@android:color/holo_blue_light</item>
<item name="alphaTypedWord">85</item>
<item name="alphaAutoCorrect">100</item>
<item name="alphaSuggested">70</item>
<item name="alphaObsoleted">70</item>
<item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item> <item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item>
<item name="centerSuggestionPercentile">@integer/center_suggestion_percentile</item> <item name="centerSuggestionPercentile">@integer/center_suggestion_percentile</item>
<item name="moreSuggestionsHint">@drawable/more_suggestions_hint_holo</item>
<item name="maxMoreSuggestionsRow">@integer/max_more_suggestions_row</item> <item name="maxMoreSuggestionsRow">@integer/max_more_suggestions_row</item>
<item name="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item> <item name="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item>
</style> </style>

View File

@ -163,6 +163,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private final int mColorTypedWord; private final int mColorTypedWord;
private final int mColorAutoCorrect; private final int mColorAutoCorrect;
private final int mColorSuggested; private final int mColorSuggested;
private final float mAlphaObsoleted;
private final float mCenterSuggestionWeight; private final float mCenterSuggestionWeight;
private final int mCenterSuggestionIndex; private final int mCenterSuggestionIndex;
private final Drawable mMoreSuggestionsHint; private final Drawable mMoreSuggestionsHint;
@ -205,15 +206,26 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
final TypedArray a = context.obtainStyledAttributes( final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.SuggestionsView, defStyle, R.style.SuggestionsViewStyle); attrs, R.styleable.SuggestionsView, defStyle, R.style.SuggestionsViewStyle);
mSuggestionStripOption = a.getInt(R.styleable.SuggestionsView_suggestionStripOption, 0); mSuggestionStripOption = a.getInt(R.styleable.SuggestionsView_suggestionStripOption, 0);
mColorTypedWord = a.getColor(R.styleable.SuggestionsView_colorTypedWord, 0); final float alphaTypedWord = getPercent(a,
mColorAutoCorrect = a.getColor(R.styleable.SuggestionsView_colorAutoCorrect, 0); R.styleable.SuggestionsView_alphaTypedWord, 100);
mColorSuggested = a.getColor(R.styleable.SuggestionsView_colorSuggested, 0); 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( mSuggestionsCountInStrip = a.getInt(
R.styleable.SuggestionsView_suggestionsCountInStrip, R.styleable.SuggestionsView_suggestionsCountInStrip,
DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
mCenterSuggestionWeight = a.getInt( mCenterSuggestionWeight = getPercent(a,
R.styleable.SuggestionsView_centerSuggestionPercentile, R.styleable.SuggestionsView_centerSuggestionPercentile,
DEFAULT_CENTER_SUGGESTION_PERCENTILE) / 100.0f; DEFAULT_CENTER_SUGGESTION_PERCENTILE);
mMoreSuggestionsHint = a.getDrawable(R.styleable.SuggestionsView_moreSuggestionsHint);
mMaxMoreSuggestionsRow = a.getInt( mMaxMoreSuggestionsRow = a.getInt(
R.styleable.SuggestionsView_maxMoreSuggestionsRow, R.styleable.SuggestionsView_maxMoreSuggestionsRow,
DEFAULT_MAX_MORE_SUGGESTIONS_ROW); DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
@ -222,7 +234,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
a.recycle(); a.recycle();
mCenterSuggestionIndex = mSuggestionsCountInStrip / 2; mCenterSuggestionIndex = mSuggestionsCountInStrip / 2;
mMoreSuggestionsHint = res.getDrawable(R.drawable.more_suggestions_hint);
mMoreSuggestionsBottomGap = res.getDimensionPixelOffset( mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(
R.dimen.more_suggestions_bottom_gap); 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); 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. // Read fraction value in TypedArray as float.
private static float getRatio(TypedArray a, int index) { private static float getRatio(TypedArray a, int index) {
return a.getFraction(index, 1000, 1000, 1) / 1000.0f; 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()) final SuggestedWordInfo info = (pos < suggestions.size())
? suggestions.getInfo(pos) : null; ? suggestions.getInfo(pos) : null;
if (info != null && info.isObsoleteSuggestedWord()) { if (info != null && info.isObsoleteSuggestedWord()) {
return applyAlpha(color, 0.5f); return applyAlpha(color, mAlphaObsoleted);
} else { } else {
return color; return color;
} }