summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKamaljeet Maini <kmaini@cyngn.com>2016-04-29 01:03:04 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-05-06 21:36:05 (GMT)
commit7b1fe0109483f22f8c5e1852efe7230e0a4ced71 (patch)
treec739f84b768289f5357132c39a0159e0bf948e15
parent3f60397f9e37e0dd59b705a2d119ae01e4b36807 (diff)
downloadandroid_packages_apps_PhoneCommon-7b1fe0109483f22f8c5e1852efe7230e0a4ced71.zip
android_packages_apps_PhoneCommon-7b1fe0109483f22f8c5e1852efe7230e0a4ced71.tar.gz
android_packages_apps_PhoneCommon-7b1fe0109483f22f8c5e1852efe7230e0a4ced71.tar.bz2
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
-rw-r--r--src/com/android/phone/common/util/ViewUtil.java13
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));
}
}
}