mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 13:08:33 +00:00
Fix issue where contact photos weren't being shown at all.
This commit is contained in:
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.dependencies.ApplicationDependencies;
|
||||||
import org.thoughtcrime.securesms.groups.GroupId;
|
import org.thoughtcrime.securesms.groups.GroupId;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
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)) {
|
try (Cursor cursor = database.query(table, RECIPIENT_FULL_PROJECTION, query, args, null, null, null)) {
|
||||||
if (cursor != null && cursor.moveToNext()) {
|
if (cursor != null && cursor.moveToNext()) {
|
||||||
return getRecipientSettings(cursor);
|
return getRecipientSettings(context, cursor);
|
||||||
} else {
|
} else {
|
||||||
throw new MissingRecipientError(id);
|
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)) {
|
try (Cursor cursor = db.query(table, RECIPIENT_FULL_PROJECTION, query, args, null, null, null)) {
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
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;
|
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));
|
long id = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
|
||||||
UUID uuid = UuidUtil.parseOrNull(cursor.getString(cursor.getColumnIndexOrThrow(UUID)));
|
UUID uuid = UuidUtil.parseOrNull(cursor.getString(cursor.getColumnIndexOrThrow(UUID)));
|
||||||
String username = cursor.getString(cursor.getColumnIndexOrThrow(USERNAME));
|
String username = cursor.getString(cursor.getColumnIndexOrThrow(USERNAME));
|
||||||
@ -808,7 +809,8 @@ public class RecipientDatabase extends Database {
|
|||||||
profileKey, profileKeyCredential,
|
profileKey, profileKeyCredential,
|
||||||
systemDisplayName, systemContactPhoto,
|
systemDisplayName, systemContactPhoto,
|
||||||
systemPhoneLabel, systemContactUri,
|
systemPhoneLabel, systemContactUri,
|
||||||
ProfileName.fromParts(profileGivenName, profileFamilyName), signalProfileAvatar, profileSharing,
|
ProfileName.fromParts(profileGivenName, profileFamilyName), signalProfileAvatar,
|
||||||
|
AvatarHelper.hasAvatar(context, RecipientId.from(id)), profileSharing,
|
||||||
notificationChannel, UnidentifiedAccessMode.fromMode(unidentifiedAccessMode),
|
notificationChannel, UnidentifiedAccessMode.fromMode(unidentifiedAccessMode),
|
||||||
forceSmsSelection,
|
forceSmsSelection,
|
||||||
Recipient.Capability.deserialize(uuidCapabilityValue),
|
Recipient.Capability.deserialize(uuidCapabilityValue),
|
||||||
@ -1655,6 +1657,7 @@ public class RecipientDatabase extends Database {
|
|||||||
private final String systemContactUri;
|
private final String systemContactUri;
|
||||||
private final ProfileName signalProfileName;
|
private final ProfileName signalProfileName;
|
||||||
private final String signalProfileAvatar;
|
private final String signalProfileAvatar;
|
||||||
|
private final boolean hasProfileImage;
|
||||||
private final boolean profileSharing;
|
private final boolean profileSharing;
|
||||||
private final String notificationChannel;
|
private final String notificationChannel;
|
||||||
private final UnidentifiedAccessMode unidentifiedAccessMode;
|
private final UnidentifiedAccessMode unidentifiedAccessMode;
|
||||||
@ -1691,6 +1694,7 @@ public class RecipientDatabase extends Database {
|
|||||||
@Nullable String systemContactUri,
|
@Nullable String systemContactUri,
|
||||||
@NonNull ProfileName signalProfileName,
|
@NonNull ProfileName signalProfileName,
|
||||||
@Nullable String signalProfileAvatar,
|
@Nullable String signalProfileAvatar,
|
||||||
|
boolean hasProfileImage,
|
||||||
boolean profileSharing,
|
boolean profileSharing,
|
||||||
@Nullable String notificationChannel,
|
@Nullable String notificationChannel,
|
||||||
@NonNull UnidentifiedAccessMode unidentifiedAccessMode,
|
@NonNull UnidentifiedAccessMode unidentifiedAccessMode,
|
||||||
@ -1727,6 +1731,7 @@ public class RecipientDatabase extends Database {
|
|||||||
this.systemContactUri = systemContactUri;
|
this.systemContactUri = systemContactUri;
|
||||||
this.signalProfileName = signalProfileName;
|
this.signalProfileName = signalProfileName;
|
||||||
this.signalProfileAvatar = signalProfileAvatar;
|
this.signalProfileAvatar = signalProfileAvatar;
|
||||||
|
this.hasProfileImage = hasProfileImage;
|
||||||
this.profileSharing = profileSharing;
|
this.profileSharing = profileSharing;
|
||||||
this.notificationChannel = notificationChannel;
|
this.notificationChannel = notificationChannel;
|
||||||
this.unidentifiedAccessMode = unidentifiedAccessMode;
|
this.unidentifiedAccessMode = unidentifiedAccessMode;
|
||||||
@ -1843,6 +1848,10 @@ public class RecipientDatabase extends Database {
|
|||||||
return signalProfileAvatar;
|
return signalProfileAvatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasProfileImage() {
|
||||||
|
return hasProfileImage;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isProfileSharing() {
|
public boolean isProfileSharing() {
|
||||||
return profileSharing;
|
return profileSharing;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@ public class Recipient {
|
|||||||
private final Uri contactUri;
|
private final Uri contactUri;
|
||||||
private final ProfileName profileName;
|
private final ProfileName profileName;
|
||||||
private final String profileAvatar;
|
private final String profileAvatar;
|
||||||
|
private final boolean hasProfileImage;
|
||||||
private final boolean profileSharing;
|
private final boolean profileSharing;
|
||||||
private final String notificationChannel;
|
private final String notificationChannel;
|
||||||
private final UnidentifiedAccessMode unidentifiedAccessMode;
|
private final UnidentifiedAccessMode unidentifiedAccessMode;
|
||||||
@ -316,6 +317,7 @@ public class Recipient {
|
|||||||
this.contactUri = null;
|
this.contactUri = null;
|
||||||
this.profileName = ProfileName.EMPTY;
|
this.profileName = ProfileName.EMPTY;
|
||||||
this.profileAvatar = null;
|
this.profileAvatar = null;
|
||||||
|
this.hasProfileImage = false;
|
||||||
this.profileSharing = false;
|
this.profileSharing = false;
|
||||||
this.notificationChannel = null;
|
this.notificationChannel = null;
|
||||||
this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED;
|
this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED;
|
||||||
@ -357,6 +359,7 @@ public class Recipient {
|
|||||||
this.contactUri = details.contactUri;
|
this.contactUri = details.contactUri;
|
||||||
this.profileName = details.profileName;
|
this.profileName = details.profileName;
|
||||||
this.profileAvatar = details.profileAvatar;
|
this.profileAvatar = details.profileAvatar;
|
||||||
|
this.hasProfileImage = details.hasProfileImage;
|
||||||
this.profileSharing = details.profileSharing;
|
this.profileSharing = details.profileSharing;
|
||||||
this.notificationChannel = details.notificationChannel;
|
this.notificationChannel = details.notificationChannel;
|
||||||
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
|
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
|
||||||
@ -631,7 +634,7 @@ public class Recipient {
|
|||||||
public @Nullable ContactPhoto getContactPhoto() {
|
public @Nullable ContactPhoto getContactPhoto() {
|
||||||
if (localNumber) return null;
|
if (localNumber) return null;
|
||||||
else if (isGroupInternal() && groupAvatarId.isPresent()) return new GroupRecordContactPhoto(groupId, groupAvatarId.get());
|
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 if (systemContactPhoto != null) return new SystemContactPhoto(id, systemContactPhoto, 0);
|
||||||
else return null;
|
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.UnidentifiedAccessMode;
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
||||||
import org.thoughtcrime.securesms.groups.GroupId;
|
import org.thoughtcrime.securesms.groups.GroupId;
|
||||||
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
@ -50,6 +51,7 @@ public class RecipientDetails {
|
|||||||
final byte[] profileKey;
|
final byte[] profileKey;
|
||||||
final byte[] profileKeyCredential;
|
final byte[] profileKeyCredential;
|
||||||
final String profileAvatar;
|
final String profileAvatar;
|
||||||
|
final boolean hasProfileImage;
|
||||||
final boolean profileSharing;
|
final boolean profileSharing;
|
||||||
final boolean systemContact;
|
final boolean systemContact;
|
||||||
final boolean isLocalNumber;
|
final boolean isLocalNumber;
|
||||||
@ -95,6 +97,7 @@ public class RecipientDetails {
|
|||||||
this.profileKey = settings.getProfileKey();
|
this.profileKey = settings.getProfileKey();
|
||||||
this.profileKeyCredential = settings.getProfileKeyCredential();
|
this.profileKeyCredential = settings.getProfileKeyCredential();
|
||||||
this.profileAvatar = settings.getProfileAvatar();
|
this.profileAvatar = settings.getProfileAvatar();
|
||||||
|
this.hasProfileImage = settings.hasProfileImage();
|
||||||
this.profileSharing = settings.isProfileSharing();
|
this.profileSharing = settings.isProfileSharing();
|
||||||
this.systemContact = systemContact;
|
this.systemContact = systemContact;
|
||||||
this.isLocalNumber = isLocalNumber;
|
this.isLocalNumber = isLocalNumber;
|
||||||
@ -141,6 +144,7 @@ public class RecipientDetails {
|
|||||||
this.profileKey = null;
|
this.profileKey = null;
|
||||||
this.profileKeyCredential = null;
|
this.profileKeyCredential = null;
|
||||||
this.profileAvatar = null;
|
this.profileAvatar = null;
|
||||||
|
this.hasProfileImage = false;
|
||||||
this.profileSharing = false;
|
this.profileSharing = false;
|
||||||
this.systemContact = true;
|
this.systemContact = true;
|
||||||
this.isLocalNumber = false;
|
this.isLocalNumber = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user