mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 11:51:10 +01:00
Update username UX and UI.
This commit is contained in:
@@ -398,15 +398,13 @@ public class Recipient {
|
||||
* False iff it {@link #getDisplayName} would fall back to e164, email or unknown.
|
||||
*/
|
||||
public boolean hasAUserSetDisplayName(@NonNull Context context) {
|
||||
return !TextUtils.isEmpty(getName(context)) ||
|
||||
!TextUtils.isEmpty(getProfileName().toString()) ||
|
||||
!TextUtils.isEmpty(getDisplayUsername());
|
||||
return !TextUtils.isEmpty(getName(context)) ||
|
||||
!TextUtils.isEmpty(getProfileName().toString());
|
||||
}
|
||||
|
||||
public @NonNull String getDisplayName(@NonNull Context context) {
|
||||
String name = Util.getFirstNonEmpty(getName(context),
|
||||
getProfileName().toString(),
|
||||
getDisplayUsername(),
|
||||
e164,
|
||||
email,
|
||||
context.getString(R.string.Recipient_unknown));
|
||||
@@ -414,10 +412,20 @@ public class Recipient {
|
||||
return StringUtil.isolateBidi(name);
|
||||
}
|
||||
|
||||
public @NonNull String getDisplayNameOrUsername(@NonNull Context context) {
|
||||
String name = Util.getFirstNonEmpty(getName(context),
|
||||
getProfileName().toString(),
|
||||
e164,
|
||||
email,
|
||||
username,
|
||||
context.getString(R.string.Recipient_unknown));
|
||||
|
||||
return StringUtil.isolateBidi(name);
|
||||
}
|
||||
|
||||
public @NonNull String getMentionDisplayName(@NonNull Context context) {
|
||||
String name = Util.getFirstNonEmpty(localNumber ? getProfileName().toString() : getName(context),
|
||||
localNumber ? getName(context) : getProfileName().toString(),
|
||||
getDisplayUsername(),
|
||||
e164,
|
||||
email,
|
||||
context.getString(R.string.Recipient_unknown));
|
||||
@@ -817,14 +825,6 @@ public class Recipient {
|
||||
return ApplicationDependencies.getRecipientCache().getLive(id);
|
||||
}
|
||||
|
||||
public @Nullable String getDisplayUsername() {
|
||||
if (!TextUtils.isEmpty(username)) {
|
||||
return "@" + username;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public @NonNull MentionSetting getMentionSetting() {
|
||||
return mentionSetting;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
||||
}
|
||||
|
||||
String usernameNumberString = recipient.hasAUserSetDisplayName(requireContext()) && !recipient.isLocalNumber()
|
||||
? String.format("%s %s", recipient.getUsername().or(""), recipient.getSmsAddress().or("")).trim()
|
||||
? recipient.getSmsAddress().or("").trim()
|
||||
: "";
|
||||
usernameNumber.setText(usernameNumberString);
|
||||
usernameNumber.setVisibility(TextUtils.isEmpty(usernameNumberString) ? View.GONE : View.VISIBLE);
|
||||
|
||||
@@ -124,8 +124,7 @@ public final class ManageRecipientViewModel extends ViewModel {
|
||||
|
||||
private static @NonNull String getDisplaySubtitle(@NonNull Recipient recipient, @NonNull Context context) {
|
||||
if (!recipient.isLocalNumber() && recipient.hasAUserSetDisplayName(context)) {
|
||||
return String.format("%s %s", recipient.getUsername().or(""), recipient.getSmsAddress().or(""))
|
||||
.trim();
|
||||
return recipient.getSmsAddress().or("").trim();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user