Fix issue where contact photos weren't being shown at all.

This commit is contained in:
Greyson Parrelli
2020-04-22 10:13:56 -04:00
parent 9bc70adbbd
commit f466fef20a
3 changed files with 21 additions and 5 deletions

View File

@@ -86,6 +86,7 @@ public class Recipient {
private final Uri contactUri;
private final ProfileName profileName;
private final String profileAvatar;
private final boolean hasProfileImage;
private final boolean profileSharing;
private final String notificationChannel;
private final UnidentifiedAccessMode unidentifiedAccessMode;
@@ -316,6 +317,7 @@ public class Recipient {
this.contactUri = null;
this.profileName = ProfileName.EMPTY;
this.profileAvatar = null;
this.hasProfileImage = false;
this.profileSharing = false;
this.notificationChannel = null;
this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED;
@@ -357,6 +359,7 @@ public class Recipient {
this.contactUri = details.contactUri;
this.profileName = details.profileName;
this.profileAvatar = details.profileAvatar;
this.hasProfileImage = details.hasProfileImage;
this.profileSharing = details.profileSharing;
this.notificationChannel = details.notificationChannel;
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
@@ -631,7 +634,7 @@ public class Recipient {
public @Nullable ContactPhoto getContactPhoto() {
if (localNumber) return null;
else if (isGroupInternal() && groupAvatarId.isPresent()) return new GroupRecordContactPhoto(groupId, groupAvatarId.get());
else if (profileAvatar != null) return new ProfileContactPhoto(this, profileAvatar);
else if (profileAvatar != null && hasProfileImage) return new ProfileContactPhoto(this, profileAvatar);
else if (systemContactPhoto != null) return new SystemContactPhoto(id, systemContactPhoto, 0);
else return null;
}

View File

@@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
import org.thoughtcrime.securesms.profiles.ProfileName;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
@@ -50,6 +51,7 @@ public class RecipientDetails {
final byte[] profileKey;
final byte[] profileKeyCredential;
final String profileAvatar;
final boolean hasProfileImage;
final boolean profileSharing;
final boolean systemContact;
final boolean isLocalNumber;
@@ -95,6 +97,7 @@ public class RecipientDetails {
this.profileKey = settings.getProfileKey();
this.profileKeyCredential = settings.getProfileKeyCredential();
this.profileAvatar = settings.getProfileAvatar();
this.hasProfileImage = settings.hasProfileImage();
this.profileSharing = settings.isProfileSharing();
this.systemContact = systemContact;
this.isLocalNumber = isLocalNumber;
@@ -141,6 +144,7 @@ public class RecipientDetails {
this.profileKey = null;
this.profileKeyCredential = null;
this.profileAvatar = null;
this.hasProfileImage = false;
this.profileSharing = false;
this.systemContact = true;
this.isLocalNumber = false;