From 7b1fe0109483f22f8c5e1852efe7230e0a4ced71 Mon Sep 17 00:00:00 2001 From: Kamaljeet Maini Date: Thu, 28 Apr 2016 18:03:04 -0700 Subject: 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 --- src/com/android/phone/common/util/ViewUtil.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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)); } } } -- cgit v1.2.3