Fix several issues with contact name syncing.

This commit is contained in:
Alex Hart
2021-03-16 10:52:59 -03:00
committed by GitHub
parent d83c3d35eb
commit 9e56441d4a
7 changed files with 37 additions and 16 deletions

View File

@@ -212,10 +212,10 @@ public final class LiveRecipient {
avatarId = Optional.of(groupRecord.get().getAvatarId());
}
return new RecipientDetails(title, avatarId, false, false, settings, members);
return new RecipientDetails(title, null, avatarId, false, false, settings, members);
}
return new RecipientDetails(null, Optional.absent(), false, false, settings, null);
return new RecipientDetails(null, null, Optional.absent(), false, false, settings, null);
}
synchronized void set(@NonNull Recipient recipient) {

View File

@@ -110,6 +110,7 @@ public class Recipient {
private final String about;
private final String aboutEmoji;
private final ProfileName systemProfileName;
private final String systemContactName;
/**
@@ -347,6 +348,7 @@ public class Recipient {
this.about = null;
this.aboutEmoji = null;
this.systemProfileName = ProfileName.EMPTY;
this.systemContactName = null;
}
public Recipient(@NonNull RecipientId id, @NonNull RecipientDetails details, boolean resolved) {
@@ -393,6 +395,7 @@ public class Recipient {
this.about = details.about;
this.aboutEmoji = details.aboutEmoji;
this.systemProfileName = details.systemProfileName;
this.systemContactName = details.systemContactName;
}
public @NonNull RecipientId getId() {
@@ -432,7 +435,7 @@ public class Recipient {
*/
public boolean hasAUserSetDisplayName(@NonNull Context context) {
return !TextUtils.isEmpty(getGroupName(context)) ||
!TextUtils.isEmpty(getSystemProfileName().toString()) ||
!TextUtils.isEmpty(systemContactName) ||
!TextUtils.isEmpty(getProfileName().toString());
}
@@ -440,7 +443,7 @@ public class Recipient {
String name = getGroupName(context);
if (Util.isEmpty(name)) {
name = getSystemProfileName().toString();
name = systemContactName;
}
if (Util.isEmpty(name)) {
@@ -466,7 +469,7 @@ public class Recipient {
String name = getGroupName(context);
if (Util.isEmpty(name)) {
name = getSystemProfileName().toString();
name = systemContactName;
}
if (Util.isEmpty(name)) {
@@ -497,7 +500,7 @@ public class Recipient {
name = StringUtil.isolateBidi(name);
if (Util.isEmpty(name)) {
name = isSelf ? getGroupName(context) : getSystemProfileName().toString();
name = isSelf ? getGroupName(context) : systemContactName;
name = StringUtil.isolateBidi(name);
}

View File

@@ -32,7 +32,8 @@ public class RecipientDetails {
final String e164;
final String email;
final GroupId groupId;
final String groupName;
final String groupName;
final String systemContactName;
final String customLabel;
final Uri systemContactPhoto;
final Uri contactUri;
@@ -71,6 +72,7 @@ public class RecipientDetails {
final ProfileName systemProfileName;
public RecipientDetails(@Nullable String groupName,
@Nullable String systemContactName,
@NonNull Optional<Long> groupAvatarId,
boolean systemContact,
boolean isSelf,
@@ -119,6 +121,7 @@ public class RecipientDetails {
this.aboutEmoji = settings.getAboutEmoji();
this.systemProfileName = settings.getSystemProfileName();
this.groupName = groupName;
this.systemContactName = systemContactName;
}
/**
@@ -167,6 +170,7 @@ public class RecipientDetails {
this.about = null;
this.aboutEmoji = null;
this.systemProfileName = ProfileName.EMPTY;
this.systemContactName = null;
}
public static @NonNull RecipientDetails forIndividual(@NonNull Context context, @NonNull RecipientSettings settings) {
@@ -174,6 +178,6 @@ public class RecipientDetails {
boolean isSelf = (settings.getE164() != null && settings.getE164().equals(TextSecurePreferences.getLocalNumber(context))) ||
(settings.getUuid() != null && settings.getUuid().equals(TextSecurePreferences.getLocalUuid(context)));
return new RecipientDetails(null, Optional.absent(), systemContact, isSelf, settings, null);
return new RecipientDetails(null, settings.getSystemDisplayName(), Optional.absent(), systemContact, isSelf, settings, null);
}
}