Display profile name in when appropriate

Display in conversation list, conversation actionbar, group
messages, and group members list when address is not in system
contacts

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2017-08-15 19:23:42 -07:00
parent 77a216b705
commit e7c20499ec
14 changed files with 270 additions and 59 deletions

View File

@@ -64,6 +64,7 @@ public class Recipient implements RecipientModifiedListener {
private boolean blocked = false;
private VibrateState vibrate = VibrateState.DEFAULT;
private int expireMessages = 0;
private String profileName = null;
@Nullable private MaterialColor color;
@@ -88,6 +89,9 @@ public class Recipient implements RecipientModifiedListener {
this.blocked = stale.blocked;
this.vibrate = stale.vibrate;
this.expireMessages = stale.expireMessages;
this.profileName = stale.profileName;
this.participants.clear();
this.participants.addAll(stale.participants);
}
if (details.isPresent()) {
@@ -99,6 +103,7 @@ public class Recipient implements RecipientModifiedListener {
this.blocked = details.get().blocked;
this.vibrate = details.get().vibrateState;
this.expireMessages = details.get().expireMessages;
this.profileName = details.get().profileName;
this.participants.clear();
this.participants.addAll(details.get().participants);
}
@@ -118,6 +123,7 @@ public class Recipient implements RecipientModifiedListener {
Recipient.this.blocked = result.blocked;
Recipient.this.vibrate = result.vibrateState;
Recipient.this.expireMessages = result.expireMessages;
Recipient.this.profileName = result.profileName;
Recipient.this.participants.clear();
Recipient.this.participants.addAll(result.participants);
@@ -151,6 +157,7 @@ public class Recipient implements RecipientModifiedListener {
this.blocked = details.blocked;
this.vibrate = details.vibrateState;
this.expireMessages = details.expireMessages;
this.profileName = details.profileName;
this.participants.addAll(details.participants);
this.resolving = false;
}
@@ -196,6 +203,10 @@ public class Recipient implements RecipientModifiedListener {
return customLabel;
}
public @Nullable String getProfileName() {
return profileName;
}
public boolean isGroupRecipient() {
return address.isGroup();
}
@@ -208,7 +219,7 @@ public class Recipient implements RecipientModifiedListener {
return address.isGroup() && !address.isMmsGroup();
}
public List<Recipient> getParticipants() {
public @NonNull List<Recipient> getParticipants() {
return participants;
}

View File

@@ -154,7 +154,7 @@ class RecipientProvider {
}
if (STATIC_DETAILS.containsKey(address.serialize())) return STATIC_DETAILS.get(address.serialize());
else return new RecipientDetails(null, null, null, ContactPhotoFactory.getDefaultContactPhoto(null), preferences.orNull(), null);
else return new RecipientDetails(null, null, null, ContactPhotoFactory.getSignalAvatarContactPhoto(context, address, null, context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size)), preferences.orNull(), null);
}
private @NonNull RecipientDetails getGroupRecipientDetails(Context context, Address groupId, Optional<GroupRecord> groupRecord, Optional<RecipientsPreferences> preferences, boolean asynchronous) {
@@ -198,6 +198,7 @@ class RecipientProvider {
public final boolean blocked;
public final int expireMessages;
@NonNull public final List<Recipient> participants;
@Nullable public final String profileName;
public RecipientDetails(@Nullable String name, @Nullable String customLabel,
@Nullable Uri contactUri, @NonNull ContactPhoto avatar,
@@ -214,6 +215,7 @@ class RecipientProvider {
this.blocked = preferences != null && preferences.isBlocked();
this.expireMessages = preferences != null ? preferences.getExpireMessages() : 0;
this.participants = participants == null ? new LinkedList<Recipient>() : participants;
this.profileName = preferences != null ? preferences.getProfileName() : null;
if (name == null && preferences != null) this.name = preferences.getSystemDisplayName();
else this.name = name;