From 697bf585f8dac6ffc4d008c02b63407cfdd83104 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" <takaoka@google.com> Date: Tue, 13 Sep 2011 12:35:52 +0900 Subject: [PATCH] Update suggestions strip text color Bug: 5287964 Change-Id: Ic40bb656873f41bb6d65427f02399464e831aab2 --- .../more_suggestions_hint_holo.png | Bin 0 -> 242 bytes .../more_suggestions_hint_holo.png | Bin 0 -> 222 bytes .../more_suggestions_hint_holo.png | Bin 0 -> 310 bytes java/res/values/attrs.xml | 5 +++ java/res/values/styles.xml | 16 +++++++--- .../inputmethod/latin/SuggestionsView.java | 30 ++++++++++++++---- 6 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 java/res/drawable-hdpi/more_suggestions_hint_holo.png create mode 100644 java/res/drawable-mdpi/more_suggestions_hint_holo.png create mode 100644 java/res/drawable-xhdpi/more_suggestions_hint_holo.png diff --git a/java/res/drawable-hdpi/more_suggestions_hint_holo.png b/java/res/drawable-hdpi/more_suggestions_hint_holo.png new file mode 100644 index 0000000000000000000000000000000000000000..93604752b08d4a809d339281853053b3a8312263 GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^B0$W}!3HEbPUl(xDaPU;cPEB*=VV?2If^B&5hcO- zX(i=}MX3z#MTrF&naR%id1a|ZC8<RU8lHJ2sX3bE?Y|^}it9aH978JRB>njR-=5jj zFqGHXY=Ue@Inzg5g)+zBDGW#Y8!PN)?T`?d&+;hSVNG}5g0J-~5q--(@=Tf|F{#32 zQib-e#!C)=n6)DN(;f(|_~EUP<|-7<_NYE!XGBio3brG84rf}@6xao-opoLLja3!4 k9TsZ~ISjO#;s1YThC-&D-G4aO-v;qLUHx3vIVCg!0E`t=Bme*a literal 0 HcmV?d00001 diff --git a/java/res/drawable-mdpi/more_suggestions_hint_holo.png b/java/res/drawable-mdpi/more_suggestions_hint_holo.png new file mode 100644 index 0000000000000000000000000000000000000000..7352810d3d5ca4cf4d5d6dc554930f09a8c1284e GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~h!3HEx)yO>uQjEnx?oJHr&dIz4auiEkBT9nv z(@M${i&7cfixLYmGLxP2^U6|-N>YmyG(7W4QgbxR+kZ&{6=!?8IEGZrN&4~szdf_6 z#LUB7N1`&gDjFgreSJhamTr_Z_-W6wM4?l*p)1nir;o!QsgC{38x3|bUS8N`JmE;6 z!_hShYups-c#haF)N?d!VD9i;*p-mf<glju8EaxnexOK$0uRuh|Nog8Ua{#g&8U>s Q0&*EVUHx3vIVCg!0I$DFV*mgE literal 0 HcmV?d00001 diff --git a/java/res/drawable-xhdpi/more_suggestions_hint_holo.png b/java/res/drawable-xhdpi/more_suggestions_hint_holo.png new file mode 100644 index 0000000000000000000000000000000000000000..35fb4208784d06d58faf92c52d9e3fd99ff897db GIT binary patch literal 310 zcmeAS@N?(olHy`uVBq!ia0vp^vOvtm!3HEf971(~6k~CayA#8@b22Z19K{mXh?3y^ zw370~qErU=qQruX%w*^Myt34ylGGvv4bQxi)Ev$7_Fs}f#fLpz978JRB>njR-=2A| z;a%M$X)6T;+L<?U3m8ATxPtr0MTa$g?!3kV)r^H20-qml3K8g-|IfWa(t?MZ=}~=v zX??>D$@X2Q9%*;klJs(>wf%8tjW7IBCOd1_&WI}oik3WV5Bi+LBpR2!uof^*G%Qe_ zwTm_4$_B=d)h4CyZs>?Q2k(&SPE?TTPn#jnS6V#rip}qSk@YXQL>qUobO<k4cXX=9 zorWDu9dAFZU{qD%SI}cg%1qhmI5G7_6C=?5|Nk>HI2KO3J@=^yJCMuZ>FVdQ&MBb@ E0LTk*6#xJL literal 0 HcmV?d00001 diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index a876e28890..9358c9085a 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -126,8 +126,13 @@ <attr name="colorTypedWord" format="color" /> <attr name="colorAutoCorrect" 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="centerSuggestionPercentile" format="integer" /> + <attr name="moreSuggestionsHint" format="reference" /> <attr name="maxMoreSuggestionsRow" format="integer" /> <attr name="minMoreSuggestionsWidth" format="float" /> </declare-styleable> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 9fa4d842ed..6aa967410f 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -96,11 +96,13 @@ parent="SuggestionsStripBackgroundStyle" > <item name="suggestionStripOption">autoCorrectBold</item> - <item name="colorTypedWord">#FFFFFFFF</item> + <item name="colorTypedWord">@android:color/white</item> <item name="colorAutoCorrect">#FFFCAE00</item> <item name="colorSuggested">#FFFCAE00</item> + <item name="alphaObsoleted">50</item> <item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</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="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item> </style> @@ -272,11 +274,17 @@ parent="SuggestionsStripBackgroundStyle.IceCreamSandwich" > <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> - <item name="colorTypedWord">#FFBCBEC0</item> - <item name="colorAutoCorrect">#FF0099CC</item> - <item name="colorSuggested">#FFA7A9AC</item> + <!-- android:color/holo_blue_light=#FF33B5E5 --> + <item name="colorTypedWord">@android:color/holo_blue_light</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="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="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item> </style> diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index 380e73bc03..b00036b49f 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; } -- GitLab