mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-31 11:56:10 +00:00
Migrate avatars and group avatars.
This commit is contained in:
@@ -10,6 +10,7 @@ import androidx.annotation.Nullable;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.util.Conversions;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
@@ -33,11 +34,11 @@ public final class GroupRecordContactPhoto implements ContactPhoto {
|
||||
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
||||
Optional<GroupDatabase.GroupRecord> groupRecord = groupDatabase.getGroup(groupId);
|
||||
|
||||
if (groupRecord.isPresent() && groupRecord.get().getAvatar() != null) {
|
||||
return new ByteArrayInputStream(groupRecord.get().getAvatar());
|
||||
if (!groupRecord.isPresent() || !AvatarHelper.hasAvatar(context, groupRecord.get().getRecipientId())) {
|
||||
throw new IOException("No avatar for group: " + groupId);
|
||||
}
|
||||
|
||||
throw new IOException("Couldn't load avatar for group: " + groupId);
|
||||
return AvatarHelper.getAvatar(context, groupRecord.get().getRecipientId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,13 +31,12 @@ public class ProfileContactPhoto implements ContactPhoto {
|
||||
|
||||
@Override
|
||||
public @NonNull InputStream openInputStream(Context context) throws IOException {
|
||||
return AvatarHelper.getInputStreamFor(context, recipient.getId());
|
||||
return AvatarHelper.getAvatar(context, recipient.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Uri getUri(@NonNull Context context) {
|
||||
File avatarFile = AvatarHelper.getAvatarFile(context, recipient.getId());
|
||||
return avatarFile.exists() ? Uri.fromFile(avatarFile) : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,12 +71,6 @@ public class ProfileContactPhoto implements ContactPhoto {
|
||||
return 0;
|
||||
}
|
||||
|
||||
File avatarFile = AvatarHelper.getAvatarFile(ApplicationDependencies.getApplication(), recipient.getId());
|
||||
|
||||
if (avatarFile.exists()) {
|
||||
return avatarFile.lastModified();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return AvatarHelper.getLastModified(ApplicationDependencies.getApplication(), recipient.getId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user