mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 21:48:17 +00:00
Fix story text previews.
This commit is contained in:
@@ -10,6 +10,7 @@ import com.bumptech.glide.load.data.StreamLocalUriFetcher;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
@@ -60,7 +61,9 @@ class DecryptableStreamLocalUriFetcher extends StreamLocalUriFetcher {
|
||||
}
|
||||
|
||||
try {
|
||||
if (isSafeSize(PartAuthority.getAttachmentThumbnailStream(context, uri))) {
|
||||
if (PartAuthority.isBlobUri(uri) && BlobProvider.isSingleUseMemoryBlob(uri)) {
|
||||
return PartAuthority.getAttachmentThumbnailStream(context, uri);
|
||||
} else if (isSafeSize(PartAuthority.getAttachmentThumbnailStream(context, uri))) {
|
||||
return PartAuthority.getAttachmentThumbnailStream(context, uri);
|
||||
} else {
|
||||
throw new IOException("File dimensions are too large!");
|
||||
|
||||
@@ -224,6 +224,11 @@ public class PartAuthority {
|
||||
return match == PART_ROW || match == THUMBNAIL_ROW;
|
||||
}
|
||||
|
||||
public static boolean isBlobUri(@NonNull Uri uri) {
|
||||
int match = uriMatcher.match(uri);
|
||||
return match == BLOB_ROW;
|
||||
}
|
||||
|
||||
public static @NonNull AttachmentId requireAttachmentId(@NonNull Uri uri) {
|
||||
return new PartUriParser(uri).getPartId();
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ public class BlobProvider {
|
||||
return new BlobBuilder(data, fileSize);
|
||||
}
|
||||
|
||||
public static boolean isSingleUseMemoryBlob(Uri uri) throws IOException {
|
||||
return StorageType.decode(uri.getPathSegments().get(STORAGE_TYPE_PATH_SEGMENT)) == StorageType.SINGLE_USE_MEMORY;
|
||||
}
|
||||
|
||||
public synchronized boolean hasStream(@NonNull Context context, @NonNull Uri uri) {
|
||||
waitUntilInitialized();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user