diff options
author | Kamaljeet Maini <kmaini@cyngn.com> | 2016-04-28 18:03:04 -0700 |
---|---|---|
committer | Kamaljeet Maini <kmaini@cyngn.com> | 2016-05-06 14:39:37 -0700 |
commit | 539a2dd4782779a4cb2efd1e5a8272fcb3504ee5 (patch) | |
tree | 4f947e908c7a91fe9ef0de6b3ce60e9b0960a0b9 /src/com/android | |
parent | a9a3b4669037df2540a388d5b5ccf8f07419dded (diff) | |
download | packages_apps_PhoneCommon-539a2dd4782779a4cb2efd1e5a8272fcb3504ee5.tar.gz packages_apps_PhoneCommon-539a2dd4782779a4cb2efd1e5a8272fcb3504ee5.tar.bz2 packages_apps_PhoneCommon-539a2dd4782779a4cb2efd1e5a8272fcb3504ee5.zip |
Reduce InCallUI name text field size to prevent text truncation
The resizeText() function calculates maximum possible text size for
the available width. In some cases, this leads to slightly bigger
text than width of text view, causing InCallUI name truncation.
To prevent this issue, the text size is now reduced by a fixed value
of 1. This solves the issue by providing enough margin on a failing
product. This margin may not be enough for all scenarios. So it may
need to be changed for other products. The goal is to keep this margin
small enough to minimize impact on non-failing products.
Change-Id: I390ca38b1cad29db42d6a1ed52346c6a72dec4a8
Issue-Id: CYNGNOS-2674
(cherry picked from commit 7b1fe0109483f22f8c5e1852efe7230e0a4ced71)
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/phone/common/util/ViewUtil.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/com/android/phone/common/util/ViewUtil.java b/src/com/android/phone/common/util/ViewUtil.java index 6611c3b..3d4bc57 100644 --- a/src/com/android/phone/common/util/ViewUtil.java +++ b/src/com/android/phone/common/util/ViewUtil.java @@ -32,6 +32,17 @@ import com.android.phone.common.R; * Provides static functions to work with views */ public class ViewUtil { + /** + * The resizeText() function calculates maximum possible text size for the available width. + * In some cases, this leads to slightly bigger text than width of text view, causing string + * truncation. + * To prevent this issue, the text size is now reduced by a fixed value of 1. This solves the + * issue by providing enough margin on a failing product. This margin may not be enough + * for all scenarios. So it may need to be changed for other products.The goal is to keep this + * margin small enough to minimize impact on non-failing products. + */ + private static final float textSizeMargin = 1.0f; + private ViewUtil() {} /** @@ -100,7 +111,7 @@ public class ViewUtil { float ratio = width / paint.measureText(textView.getText().toString()); if (ratio <= 1.0f) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, - Math.max(minTextSize, originalTextSize * ratio)); + Math.max(minTextSize, originalTextSize * ratio - textSizeMargin)); } } } |