Fix issue where contact photos weren't being shown at all.
parent
9bc70adbbd
commit
f466fef20a
|
@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
|||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
|
@ -397,7 +398,7 @@ public class RecipientDatabase extends Database {
|
|||
|
||||
try (Cursor cursor = database.query(table, RECIPIENT_FULL_PROJECTION, query, args, null, null, null)) {
|
||||
if (cursor != null && cursor.moveToNext()) {
|
||||
return getRecipientSettings(cursor);
|
||||
return getRecipientSettings(context, cursor);
|
||||
} else {
|
||||
throw new MissingRecipientError(id);
|
||||
}
|
||||
|
@ -686,7 +687,7 @@ public class RecipientDatabase extends Database {
|
|||
|
||||
try (Cursor cursor = db.query(table, RECIPIENT_FULL_PROJECTION, query, args, null, null, null)) {
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
out.add(getRecipientSettings(cursor));
|
||||
out.add(getRecipientSettings(context, cursor));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -727,7 +728,7 @@ public class RecipientDatabase extends Database {
|
|||
return out;
|
||||
}
|
||||
|
||||
private static @NonNull RecipientSettings getRecipientSettings(@NonNull Cursor cursor) {
|
||||
private static @NonNull RecipientSettings getRecipientSettings(@NonNull Context context, @NonNull Cursor cursor) {
|
||||
long id = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
||||
UUID uuid = UuidUtil.parseOrNull(cursor.getString(cursor.getColumnIndexOrThrow(UUID)));
|
||||
String username = cursor.getString(cursor.getColumnIndexOrThrow(USERNAME));
|
||||
|
@ -808,7 +809,8 @@ public class RecipientDatabase extends Database {
|
|||
profileKey, profileKeyCredential,
|
||||
systemDisplayName, systemContactPhoto,
|
||||
systemPhoneLabel, systemContactUri,
|
||||
ProfileName.fromParts(profileGivenName, profileFamilyName), signalProfileAvatar, profileSharing,
|
||||
ProfileName.fromParts(profileGivenName, profileFamilyName), signalProfileAvatar,
|
||||
AvatarHelper.hasAvatar(context, RecipientId.from(id)), profileSharing,
|
||||
notificationChannel, UnidentifiedAccessMode.fromMode(unidentifiedAccessMode),
|
||||
forceSmsSelection,
|
||||
Recipient.Capability.deserialize(uuidCapabilityValue),
|
||||
|
@ -1655,6 +1657,7 @@ public class RecipientDatabase extends Database {
|
|||
private final String systemContactUri;
|
||||
private final ProfileName signalProfileName;
|
||||
private final String signalProfileAvatar;
|
||||
private final boolean hasProfileImage;
|
||||
private final boolean profileSharing;
|
||||
private final String notificationChannel;
|
||||
private final UnidentifiedAccessMode unidentifiedAccessMode;
|
||||
|
@ -1691,6 +1694,7 @@ public class RecipientDatabase extends Database {
|
|||
@Nullable String systemContactUri,
|
||||
@NonNull ProfileName signalProfileName,
|
||||
@Nullable String signalProfileAvatar,
|
||||
boolean hasProfileImage,
|
||||
boolean profileSharing,
|
||||
@Nullable String notificationChannel,
|
||||
@NonNull UnidentifiedAccessMode unidentifiedAccessMode,
|
||||
|
@ -1727,6 +1731,7 @@ public class RecipientDatabase extends Database {
|
|||
this.systemContactUri = systemContactUri;
|
||||
this.signalProfileName = signalProfileName;
|
||||
this.signalProfileAvatar = signalProfileAvatar;
|
||||
this.hasProfileImage = hasProfileImage;
|
||||
this.profileSharing = profileSharing;
|
||||
this.notificationChannel = notificationChannel;
|
||||
this.unidentifiedAccessMode = unidentifiedAccessMode;
|
||||
|
@ -1843,6 +1848,10 @@ public class RecipientDatabase extends Database {
|
|||
return signalProfileAvatar;
|
||||
}
|
||||
|
||||
public boolean hasProfileImage() {
|
||||
return hasProfileImage;
|
||||
}
|
||||
|
||||
public boolean isProfileSharing() {
|
||||
return profileSharing;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue