Do not assume phone number in conversation.

Fixes #8813
This commit is contained in:
Alan Evans 2019-05-22 13:29:45 -03:00
parent 0a7970ad0c
commit 7db1588578
2 changed files with 8 additions and 4 deletions

View File

@ -200,7 +200,7 @@ public class ConversationListItem extends RelativeLayout
String name = recipient.isLocalNumber() ? getContext().getString(R.string.note_to_self) : recipient.getName(); String name = recipient.isLocalNumber() ? getContext().getString(R.string.note_to_self) : recipient.getName();
fromView.setText(SearchUtil.getHighlightedSpan(locale, () -> new StyleSpan(Typeface.BOLD), name, highlightSubstring)); 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(""); dateView.setText("");
archivedView.setVisibility(GONE); archivedView.setVisibility(GONE);
unreadIndicator.setVisibility(GONE); unreadIndicator.setVisibility(GONE);

View File

@ -126,17 +126,21 @@ public class Address implements Parcelable, Comparable<Address> {
} }
public @NonNull String toGroupString() { public @NonNull String toGroupString() {
if (!isGroup()) throw new AssertionError("Not group: " + address); if (!isGroup()) throw new AssertionError("Not group");
return address; return address;
} }
public @NonNull String toPhoneString() { 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; return address;
} }
public @NonNull String toEmailString() { public @NonNull String toEmailString() {
if (!isEmail()) throw new AssertionError("Not email: " + address); if (!isEmail()) throw new AssertionError("Not email");
return address; return address;
} }