From 381547d6687d07f307113c332d27d0727dc7712d Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 22 Jun 2018 13:24:36 -0700 Subject: [PATCH] Fix crash with formatting emails in recipient settings. Fixes #7868 --- .../securesms/RecipientPreferenceActivity.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java index 7723e51aea..a42ee799ca 100644 --- a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java +++ b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java @@ -359,7 +359,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity())); colorPreference.setColor(recipient.getColor().toActionBarColor(getActivity())); - aboutPreference.setTitle(PhoneNumberUtils.formatNumber(recipient.getAddress().toPhoneString())); + aboutPreference.setTitle(formatAddress(recipient.getAddress())); aboutPreference.setSummary(recipient.getCustomLabel()); aboutPreference.setSecure(recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED); @@ -388,6 +388,12 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi } } + private @NonNull String formatAddress(@NonNull Address address) { + if (address.isPhone()) return PhoneNumberUtils.formatNumber(address.toPhoneString()); + else if (address.isEmail()) return address.toEmailString(); + else return ""; + } + private @NonNull String getRingtoneSummary(@NonNull Context context, @Nullable Uri ringtone) { if (ringtone == null) { return context.getString(R.string.preferences__default);