Ellipsize names in call log

This commit is contained in:
xynngh 2020-06-22 15:17:06 +04:00
parent c18e735483
commit a28878ba04
1 changed files with 8 additions and 1 deletions

View File

@ -152,7 +152,8 @@ public class CallLogItemRecyclerViewAdapter
callTypeIcon.setImageDrawable(null); 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( IconAndColor iconAndColor = IconAndColor.forNumberRating(
item.numberInfo.rating, item.numberInfo.contactItem != null); item.numberInfo.rating, item.numberInfo.contactItem != null);
@ -166,6 +167,12 @@ public class CallLogItemRecyclerViewAdapter
time.setText(DateUtils.getRelativeTimeSpanString(item.timestamp)); 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 @Override
public String toString() { public String toString() {
return super.toString() + " '" + label.getText() + "'"; return super.toString() + " '" + label.getText() + "'";