mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Add ui wiring for archive thumbnail support.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user