mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 17:47:47 +00:00
Don't format numbers unnecessarily.
Util.getFirstNonEmpty() requires calculating all input strings first, but that's unnecessary and could result in lots of warning logs in the case of calling PhoneNumberFormatter#prettyPrint with nulls or other stuff. Fixes #10246
This commit is contained in:
@@ -416,32 +416,71 @@ public class Recipient {
|
||||
}
|
||||
|
||||
public @NonNull String getDisplayName(@NonNull Context context) {
|
||||
String name = Util.getFirstNonEmpty(getName(context),
|
||||
getProfileName().toString(),
|
||||
PhoneNumberFormatter.prettyPrint(e164),
|
||||
email,
|
||||
context.getString(R.string.Recipient_unknown));
|
||||
String name = getName(context);
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = getProfileName().toString();
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name) && !Util.isEmpty(e164)) {
|
||||
name = PhoneNumberFormatter.prettyPrint(e164);
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = email;
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = context.getString(R.string.Recipient_unknown);
|
||||
}
|
||||
|
||||
return StringUtil.isolateBidi(name);
|
||||
}
|
||||
|
||||
public @NonNull String getDisplayNameOrUsername(@NonNull Context context) {
|
||||
String name = Util.getFirstNonEmpty(getName(context),
|
||||
getProfileName().toString(),
|
||||
PhoneNumberFormatter.prettyPrint(e164),
|
||||
email,
|
||||
username,
|
||||
context.getString(R.string.Recipient_unknown));
|
||||
String name = getName(context);
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = getProfileName().toString();
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name) && !Util.isEmpty(e164)) {
|
||||
name = PhoneNumberFormatter.prettyPrint(e164);
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = email;
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = username;
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = context.getString(R.string.Recipient_unknown);
|
||||
}
|
||||
|
||||
return StringUtil.isolateBidi(name);
|
||||
}
|
||||
|
||||
public @NonNull String getMentionDisplayName(@NonNull Context context) {
|
||||
String name = Util.getFirstNonEmpty(isSelf ? getProfileName().toString() : getName(context),
|
||||
isSelf ? getName(context) : getProfileName().toString(),
|
||||
PhoneNumberFormatter.prettyPrint(e164),
|
||||
email,
|
||||
context.getString(R.string.Recipient_unknown));
|
||||
String name = isSelf ? getProfileName().toString() : getName(context);
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = isSelf ? getName(context) : getProfileName().toString();
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name) && !Util.isEmpty(e164)) {
|
||||
name = PhoneNumberFormatter.prettyPrint(e164);
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = email;
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = context.getString(R.string.Recipient_unknown);
|
||||
}
|
||||
|
||||
return StringUtil.isolateBidi(name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user