diff --git a/java/res/drawable-hdpi/more_suggestions_hint.png b/java/res/drawable-hdpi/more_suggestions_hint.png deleted file mode 100644 index 93604752b08d4a809d339281853053b3a8312263..0000000000000000000000000000000000000000 Binary files a/java/res/drawable-hdpi/more_suggestions_hint.png and /dev/null differ diff --git a/java/res/drawable-hdpi/more_suggestions_hint_holo.png b/java/res/drawable-hdpi/more_suggestions_hint_holo.png deleted file mode 100644 index 93604752b08d4a809d339281853053b3a8312263..0000000000000000000000000000000000000000 Binary files a/java/res/drawable-hdpi/more_suggestions_hint_holo.png and /dev/null differ diff --git a/java/res/drawable-mdpi/more_suggestions_hint.png b/java/res/drawable-mdpi/more_suggestions_hint.png deleted file mode 100644 index 7352810d3d5ca4cf4d5d6dc554930f09a8c1284e..0000000000000000000000000000000000000000 Binary files a/java/res/drawable-mdpi/more_suggestions_hint.png and /dev/null differ diff --git a/java/res/drawable-mdpi/more_suggestions_hint_holo.png b/java/res/drawable-mdpi/more_suggestions_hint_holo.png deleted file mode 100644 index 7352810d3d5ca4cf4d5d6dc554930f09a8c1284e..0000000000000000000000000000000000000000 Binary files a/java/res/drawable-mdpi/more_suggestions_hint_holo.png and /dev/null differ diff --git a/java/res/drawable-xhdpi/more_suggestions_hint.png b/java/res/drawable-xhdpi/more_suggestions_hint.png deleted file mode 100644 index 35fb4208784d06d58faf92c52d9e3fd99ff897db..0000000000000000000000000000000000000000 Binary files a/java/res/drawable-xhdpi/more_suggestions_hint.png and /dev/null differ diff --git a/java/res/drawable-xhdpi/more_suggestions_hint_holo.png b/java/res/drawable-xhdpi/more_suggestions_hint_holo.png deleted file mode 100644 index 35fb4208784d06d58faf92c52d9e3fd99ff897db..0000000000000000000000000000000000000000 Binary files a/java/res/drawable-xhdpi/more_suggestions_hint_holo.png and /dev/null differ diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml index d02b4eaadbe359ba42f16cd5784f8fc3ebc5c9b4..e1bdecfd96569312f07811e8739bbd13a80c2ae9 100644 --- a/java/res/values-sw600dp/dimens.xml +++ b/java/res/values-sw600dp/dimens.xml @@ -76,4 +76,5 @@ <dimen name="suggestion_min_width">0.3in</dimen> <dimen name="suggestion_padding">12dip</dimen> <dimen name="suggestion_text_size">22dip</dimen> + <dimen name="more_suggestions_hint_text_size">33dip</dimen> </resources> diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml index bfc2593db5046b1c4768d6f96f62f4079bfc0ff0..b825b1457c72e2bd41ed9375178cbe40130df239 100644 --- a/java/res/values-sw768dp/dimens.xml +++ b/java/res/values-sw768dp/dimens.xml @@ -79,4 +79,5 @@ <dimen name="suggestion_min_width">46dip</dimen> <dimen name="suggestion_padding">8dip</dimen> <dimen name="suggestion_text_size">22dip</dimen> + <dimen name="more_suggestions_hint_text_size">33dip</dimen> </resources> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 6e9461a33e7dfe8c924cd6b412c7630e8321583d..e40cc95aba5df24a2f67560cf268e49520ab2f46 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -132,7 +132,6 @@ <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/dimens.xml b/java/res/values/dimens.xml index 8488c777b8df76340bac9fb58fa3f4d5be1c366d..16cccc62af83267bd7b14af33142263ac399d210 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -92,6 +92,7 @@ <dimen name="suggestion_min_width">44dip</dimen> <dimen name="suggestion_padding">6dip</dimen> <dimen name="suggestion_text_size">18dip</dimen> + <dimen name="more_suggestions_hint_text_size">27dip</dimen> <integer name="suggestions_count_in_strip">3</integer> <integer name="center_suggestion_percentile">36</integer> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 6aa967410ffaf13aa379d73ad7ae622b7258022f..7b8bfa841b7fb24974d3b30812f587efb44f98c3 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -102,7 +102,6 @@ <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> @@ -284,7 +283,6 @@ <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 13beb447981474bfdcb2201a8330886e2ea728b0..6fc7900302e7181fac0259272b7cd10c1b53fef6 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -19,8 +19,14 @@ package com.android.inputmethod.latin; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Paint.Align; +import android.graphics.Rect; import android.graphics.Typeface; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Message; import android.os.SystemClock; @@ -167,6 +173,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, private final float mCenterSuggestionWeight; private final int mCenterSuggestionIndex; private final Drawable mMoreSuggestionsHint; + private static final String MORE_SUGGESTIONS_HINT = "\u2026"; private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD); private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan(); @@ -225,7 +232,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, mCenterSuggestionWeight = getPercent(a, R.styleable.SuggestionsView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE); - mMoreSuggestionsHint = a.getDrawable(R.styleable.SuggestionsView_moreSuggestionsHint); mMaxMoreSuggestionsRow = a.getInt( R.styleable.SuggestionsView_maxMoreSuggestionsRow, DEFAULT_MAX_MORE_SUGGESTIONS_ROW); @@ -233,6 +239,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, R.styleable.SuggestionsView_minMoreSuggestionsWidth); a.recycle(); + mMoreSuggestionsHint = getMoreSuggestionsHint(res, + res.getDimension(R.dimen.more_suggestions_hint_text_size), mColorAutoCorrect); mCenterSuggestionIndex = mSuggestionsCountInStrip / 2; mMoreSuggestionsBottomGap = res.getDimensionPixelOffset( R.dimen.more_suggestions_bottom_gap); @@ -246,6 +254,23 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, mHintToSaveText = context.getText(R.string.hint_add_to_dictionary); } + private static Drawable getMoreSuggestionsHint(Resources res, float textSize, int color) { + final Paint paint = new Paint(); + paint.setAntiAlias(true); + paint.setTextAlign(Align.CENTER); + paint.setTextSize(textSize); + paint.setColor(color); + final Rect bounds = new Rect(); + paint.getTextBounds(MORE_SUGGESTIONS_HINT, 0, 1, bounds); + final int width = Math.round(bounds.width() + 0.5f); + final int height = Math.round(bounds.height() + 0.5f); + final Bitmap buffer = Bitmap.createBitmap( + width, (height * 3 / 2), Bitmap.Config.ARGB_8888); + final Canvas canvas = new Canvas(buffer); + canvas.drawText(MORE_SUGGESTIONS_HINT, width / 2, height, paint); + return new BitmapDrawable(res, buffer); + } + // Read integer value in TypedArray as percent. private static float getPercent(TypedArray a, int index, int defValue) { return a.getInt(index, defValue) / 100.0f;