From a28878ba044397b8172714073fae712e9070d087 Mon Sep 17 00:00:00 2001 From: xynngh Date: Mon, 22 Jun 2020 15:17:06 +0400 Subject: [PATCH] Ellipsize names in call log --- .../CallLogItemRecyclerViewAdapter.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/dummydomain/yetanothercallblocker/CallLogItemRecyclerViewAdapter.java b/app/src/main/java/dummydomain/yetanothercallblocker/CallLogItemRecyclerViewAdapter.java index 72b6d80..2ac94f5 100644 --- a/app/src/main/java/dummydomain/yetanothercallblocker/CallLogItemRecyclerViewAdapter.java +++ b/app/src/main/java/dummydomain/yetanothercallblocker/CallLogItemRecyclerViewAdapter.java @@ -152,7 +152,8 @@ public class CallLogItemRecyclerViewAdapter callTypeIcon.setImageDrawable(null); } - label.setText(item.numberInfo.name != null ? item.numberInfo.name : item.number); + label.setText(ellipsize( + item.numberInfo.name != null ? item.numberInfo.name : item.number, 15)); IconAndColor iconAndColor = IconAndColor.forNumberRating( item.numberInfo.rating, item.numberInfo.contactItem != null); @@ -166,6 +167,12 @@ public class CallLogItemRecyclerViewAdapter time.setText(DateUtils.getRelativeTimeSpanString(item.timestamp)); } + String ellipsize(String s, int maxLength) { + return s == null || s.length() <= maxLength + ? s + : (s.substring(0, maxLength - 1) + '…'); + } + @Override public String toString() { return super.toString() + " '" + label.getText() + "'";