mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 18:30:20 +01:00
Implement new API endpoints for Usernames.
This commit is contained in:
committed by
Greyson Parrelli
parent
ca0e52e141
commit
9b9453734c
@@ -570,6 +570,37 @@ public class Recipient {
|
||||
}
|
||||
|
||||
public @NonNull String getDisplayName(@NonNull Context context) {
|
||||
String name = getNameFromLocalData(context);
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = context.getString(R.string.Recipient_unknown);
|
||||
}
|
||||
|
||||
return StringUtil.isolateBidi(name);
|
||||
}
|
||||
|
||||
public @NonNull String getDisplayNameOrUsername(@NonNull Context context) {
|
||||
String name = getNameFromLocalData(context);
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = StringUtil.isolateBidi(username);
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = StringUtil.isolateBidi(context.getString(R.string.Recipient_unknown));
|
||||
}
|
||||
|
||||
return StringUtil.isolateBidi(name);
|
||||
}
|
||||
|
||||
public boolean hasNonUsernameDisplayName(@NonNull Context context) {
|
||||
return getNameFromLocalData(context) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return local name for user ignoring the username.
|
||||
*/
|
||||
private @Nullable String getNameFromLocalData(@NonNull Context context) {
|
||||
String name = getGroupName(context);
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
@@ -588,40 +619,6 @@ public class Recipient {
|
||||
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 = getGroupName(context);
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = systemContactName;
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = StringUtil.isolateBidi(getProfileName().toString());
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name) && !Util.isEmpty(e164)) {
|
||||
name = PhoneNumberFormatter.prettyPrint(e164);
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = StringUtil.isolateBidi(email);
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = StringUtil.isolateBidi(username);
|
||||
}
|
||||
|
||||
if (Util.isEmpty(name)) {
|
||||
name = StringUtil.isolateBidi(context.getString(R.string.Recipient_unknown));
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user