From 9706f9a2f468765734a904d296a9e9e813220d15 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 3 Feb 2014 15:08:07 +0900 Subject: [PATCH] Fix important notice strip text layout Bug: 10587358 Change-Id: I9cbdd3b450e05d6d0611a16b6b7fad945918dd5f --- java/res/layout/suggestions_strip.xml | 4 ++-- .../suggestions/SuggestionStripLayoutHelper.java | 14 ++++++++++---- .../latin/suggestions/SuggestionStripView.java | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/java/res/layout/suggestions_strip.xml b/java/res/layout/suggestions_strip.xml index 9ffd231de..5e1019bcd 100644 --- a/java/res/layout/suggestions_strip.xml +++ b/java/res/layout/suggestions_strip.xml @@ -52,9 +52,9 @@ android:layout_height="match_parent"> diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java index da084e1e9..a89f70e1f 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java @@ -502,11 +502,17 @@ final class SuggestionStripLayoutHelper { titleView.setTextColor(mColorAutoCorrect); TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( titleView, infoIcon, null, moreIcon, null); - final CharSequence importantNoticeTitle = res.getText(R.string.important_notice_title); + final CharSequence importantNoticeTitle = titleView.getText(); titleView.setTextScaleX(1.0f); // Reset textScaleX. - final float titleScaleX = getTextScaleX(importantNoticeTitle, width, titleView.getPaint()); - titleView.setText(importantNoticeTitle); - titleView.setTextScaleX(titleScaleX); + // When the suggestions strip is displayed first time, stripWidth may be zero. + // Then importantNoticeTitle will be displayed as is without auto text scaleX. + // TODO: Fix the logic to always have a correct value of stripWidth. + if (width > 0) { + // Auto text scaleX to show entire important notice title should be on the strip. + final float titleScaleX = getTextScaleX( + importantNoticeTitle, width, titleView.getPaint()); + titleView.setTextScaleX(titleScaleX); + } } static void setLayoutWeight(final View v, final float weight, final int height) { diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index fe95d6781..b04a2cb5b 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -220,6 +220,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick return false; } + // TODO: This method should be called after this View has been attached and displayed. public void showImportantNoticeTitle() { mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, getWidth()); mStripVisibilityGroup.showImportantNoticeStrip();