Fix crash with formatting emails in recipient settings.

Fixes #7868
This commit is contained in:
Greyson Parrelli 2018-06-22 13:24:36 -07:00
parent f72f75ee61
commit 381547d668

View File

@ -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);