Add ui wiring for archive thumbnail support.

This commit is contained in:
Clark
2024-05-22 19:02:20 -04:00
committed by Cody Henthorne
parent 3d382ee15e
commit 2a3cb80217
15 changed files with 451 additions and 100 deletions

View File

@@ -8,6 +8,7 @@ import android.net.Uri;
import com.bumptech.glide.load.data.StreamLocalUriFetcher;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.attachments.AttachmentId;
import org.thoughtcrime.securesms.util.MediaUtil;
import java.io.ByteArrayInputStream;
@@ -39,6 +40,18 @@ class DecryptableStreamLocalUriFetcher extends StreamLocalUriFetcher {
thumbnail.recycle();
return thumbnailStream;
}
if (PartAuthority.isAttachmentUri(uri) && MediaUtil.isVideoType(PartAuthority.getAttachmentContentType(context, uri))) {
try {
AttachmentId attachmentId = PartAuthority.requireAttachmentId(uri);
Uri thumbnailUri = PartAuthority.getAttachmentThumbnailUri(attachmentId);
InputStream thumbStream = PartAuthority.getAttachmentThumbnailStream(context, thumbnailUri);
if (thumbStream != null) {
return thumbStream;
}
} catch (IOException e) {
Log.i(TAG, "Failed to fetch thumbnail", e);
}
}
}
try {

View File

@@ -56,11 +56,12 @@ public abstract class Slide {
@Nullable
public Uri getUri() {
Uri attachmentUri = attachment.getUri();
if (attachmentUri != null) {
return attachmentUri;
}
return attachment.getThumbnailUri();
return attachment.getUri();
}
@Nullable
public Uri getDisplayUri() {
return attachment.getDisplayUri();
}
public @Nullable Uri getPublicUri() {
@@ -141,7 +142,8 @@ public abstract class Slide {
public boolean isPendingDownload() {
return getTransferState() == AttachmentTable.TRANSFER_PROGRESS_FAILED ||
getTransferState() == AttachmentTable.TRANSFER_PROGRESS_PENDING;
getTransferState() == AttachmentTable.TRANSFER_PROGRESS_PENDING ||
getTransferState() == AttachmentTable.TRANSFER_RESTORE_OFFLOADED;
}
public int getTransferState() {
@@ -160,6 +162,10 @@ public abstract class Slide {
return false;
}
public boolean hasThumbnail() {
return attachment.getThumbnailUri() != null;
}
public boolean hasPlayOverlay() {
return false;
}