From a3caabcafd8f3b6ff7f3132c91e03e4fc7a44d2e Mon Sep 17 00:00:00 2001 From: alex-signal Date: Thu, 19 Sep 2019 13:44:43 -0300 Subject: [PATCH] Fix video forwarding thumbnail display. --- .../mms/DecryptableStreamLocalUriFetcher.java | 2 +- .../thoughtcrime/securesms/mms/PartAuthority.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/mms/DecryptableStreamLocalUriFetcher.java b/src/org/thoughtcrime/securesms/mms/DecryptableStreamLocalUriFetcher.java index 0543e737cd..ee833915ff 100644 --- a/src/org/thoughtcrime/securesms/mms/DecryptableStreamLocalUriFetcher.java +++ b/src/org/thoughtcrime/securesms/mms/DecryptableStreamLocalUriFetcher.java @@ -40,7 +40,7 @@ class DecryptableStreamLocalUriFetcher extends StreamLocalUriFetcher { } try { - return PartAuthority.getAttachmentStream(context, uri); + return PartAuthority.getAttachmentThumbnailStream(context, uri); } catch (IOException ioe) { Log.w(TAG, ioe); throw new FileNotFoundException("PartAuthority couldn't load Uri resource."); diff --git a/src/org/thoughtcrime/securesms/mms/PartAuthority.java b/src/org/thoughtcrime/securesms/mms/PartAuthority.java index c86fb32d99..508ea06bd0 100644 --- a/src/org/thoughtcrime/securesms/mms/PartAuthority.java +++ b/src/org/thoughtcrime/securesms/mms/PartAuthority.java @@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.providers.BlobProvider; import org.thoughtcrime.securesms.providers.DeprecatedPersistentBlobProvider; import org.thoughtcrime.securesms.providers.PartProvider; +import org.thoughtcrime.securesms.util.MediaUtil; import java.io.IOException; import java.io.InputStream; @@ -44,6 +45,19 @@ public class PartAuthority { uriMatcher.addURI(BlobProvider.AUTHORITY, BlobProvider.PATH, BLOB_ROW); } + public static InputStream getAttachmentThumbnailStream(@NonNull Context context, @NonNull Uri uri) + throws IOException + { + String contentType = getAttachmentContentType(context, uri); + int match = uriMatcher.match(uri); + + if (match == PART_ROW && MediaUtil.isVideoType(contentType)) { + return DatabaseFactory.getAttachmentDatabase(context).getThumbnailStream(new PartUriParser(uri).getPartId()); + } + + return getAttachmentStream(context, uri); + } + public static InputStream getAttachmentStream(@NonNull Context context, @NonNull Uri uri) throws IOException {