From 7db15885781e20d9adeaaecf22e9e700ff399020 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Wed, 22 May 2019 13:29:45 -0300 Subject: [PATCH] Do not assume phone number in conversation. Fixes #8813 --- .../thoughtcrime/securesms/ConversationListItem.java | 2 +- src/org/thoughtcrime/securesms/database/Address.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationListItem.java b/src/org/thoughtcrime/securesms/ConversationListItem.java index fb62951dc3..067b3efbfb 100644 --- a/src/org/thoughtcrime/securesms/ConversationListItem.java +++ b/src/org/thoughtcrime/securesms/ConversationListItem.java @@ -200,7 +200,7 @@ public class ConversationListItem extends RelativeLayout String name = recipient.isLocalNumber() ? getContext().getString(R.string.note_to_self) : recipient.getName(); fromView.setText(SearchUtil.getHighlightedSpan(locale, () -> new StyleSpan(Typeface.BOLD), name, highlightSubstring)); - subjectView.setText(SearchUtil.getHighlightedSpan(locale, () -> new StyleSpan(Typeface.BOLD), contact.getAddress().toPhoneString(), highlightSubstring)); + subjectView.setText(SearchUtil.getHighlightedSpan(locale, () -> new StyleSpan(Typeface.BOLD), contact.getAddress().toString(), highlightSubstring)); dateView.setText(""); archivedView.setVisibility(GONE); unreadIndicator.setVisibility(GONE); diff --git a/src/org/thoughtcrime/securesms/database/Address.java b/src/org/thoughtcrime/securesms/database/Address.java index a60028c7a6..ac7eaea579 100644 --- a/src/org/thoughtcrime/securesms/database/Address.java +++ b/src/org/thoughtcrime/securesms/database/Address.java @@ -126,17 +126,21 @@ public class Address implements Parcelable, Comparable
{ } public @NonNull String toGroupString() { - if (!isGroup()) throw new AssertionError("Not group: " + address); + if (!isGroup()) throw new AssertionError("Not group"); return address; } public @NonNull String toPhoneString() { - if (!isPhone()) throw new AssertionError("Not e164: " + address); + if (!isPhone()) { + if (isEmail()) throw new AssertionError("Not e164, is email"); + if (isGroup()) throw new AssertionError("Not e164, is group"); + throw new AssertionError("Not e164, unknown"); + } return address; } public @NonNull String toEmailString() { - if (!isEmail()) throw new AssertionError("Not email: " + address); + if (!isEmail()) throw new AssertionError("Not email"); return address; }