Convert HEIC/HEIF to JPEG.
parent
e6a0e5b858
commit
eb02dacfdc
|
@ -638,7 +638,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
|
|||
} else if (MediaUtil.isGif(mediaItem.getMimeType())) {
|
||||
slideDeck.addSlide(new GifSlide(this, mediaItem.getUri(), 0, mediaItem.getWidth(), mediaItem.getHeight(), mediaItem.isBorderless(), mediaItem.getCaption().orNull()));
|
||||
} else if (MediaUtil.isImageType(mediaItem.getMimeType())) {
|
||||
slideDeck.addSlide(new ImageSlide(this, mediaItem.getUri(), 0, mediaItem.getWidth(), mediaItem.getHeight(), mediaItem.isBorderless(), mediaItem.getCaption().orNull(), null));
|
||||
slideDeck.addSlide(new ImageSlide(this, mediaItem.getUri(), mediaItem.getMimeType(), 0, mediaItem.getWidth(), mediaItem.getHeight(), mediaItem.isBorderless(), mediaItem.getCaption().orNull(), null));
|
||||
} else {
|
||||
Log.w(TAG, "Asked to send an unexpected mimeType: '" + mediaItem.getMimeType() + "'. Skipping.");
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public final class AttachmentCompressionJob extends BaseJob {
|
|||
if (!constraints.isSatisfied(context, attachment)) {
|
||||
throw new UndeliverableMessageException("Size constraints could not be met on video!");
|
||||
}
|
||||
} else if (MediaUtil.isHeic(attachment)) {
|
||||
} else if (MediaUtil.isHeic(attachment) || MediaUtil.isHeif(attachment)) {
|
||||
MediaStream converted = getResizedMedia(context, attachment, constraints);
|
||||
attachmentDatabase.updateAttachmentData(attachment, converted, false);
|
||||
attachmentDatabase.markAttachmentAsTransformed(attachmentId);
|
||||
|
|
|
@ -195,7 +195,7 @@ class MediaUploadRepository {
|
|||
} else if (MediaUtil.isGif(media.getMimeType())) {
|
||||
return new GifSlide(context, media.getUri(), 0, media.getWidth(), media.getHeight(), media.isBorderless(), media.getCaption().orNull()).asAttachment();
|
||||
} else if (MediaUtil.isImageType(media.getMimeType())) {
|
||||
return new ImageSlide(context, media.getUri(), 0, media.getWidth(), media.getHeight(), media.isBorderless(), media.getCaption().orNull(), null).asAttachment();
|
||||
return new ImageSlide(context, media.getUri(), media.getMimeType(), 0, media.getWidth(), media.getHeight(), media.isBorderless(), media.getCaption().orNull(), null).asAttachment();
|
||||
} else if (MediaUtil.isTextType(media.getMimeType())) {
|
||||
return new TextSlide(context, media.getUri(), null, media.getSize()).asAttachment();
|
||||
} else {
|
||||
|
|
|
@ -41,12 +41,11 @@ public class ImageSlide extends Slide {
|
|||
}
|
||||
|
||||
public ImageSlide(Context context, Uri uri, long size, int width, int height, @Nullable BlurHash blurHash) {
|
||||
this(context, uri, size, width, height, false, null, blurHash);
|
||||
this(context, uri, MediaUtil.IMAGE_JPEG, size, width, height, false, null, blurHash);
|
||||
}
|
||||
|
||||
public ImageSlide(Context context, Uri uri, long size, int width, int height, boolean borderless, @Nullable String caption, @Nullable BlurHash blurHash) {
|
||||
// TODO [greyson] [borderless] Handle borderless
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_JPEG, size, width, height, true, null, caption, null, blurHash, null, false, borderless, false));
|
||||
public ImageSlide(Context context, Uri uri, String contentType, long size, int width, int height, boolean borderless, @Nullable String caption, @Nullable BlurHash blurHash) {
|
||||
super(context, constructAttachmentFromUri(context, uri, contentType, size, width, height, true, null, caption, null, blurHash, null, false, borderless, false));
|
||||
this.borderless = borderless;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ public class MediaUtil {
|
|||
public static final String IMAGE_PNG = "image/png";
|
||||
public static final String IMAGE_JPEG = "image/jpeg";
|
||||
public static final String IMAGE_HEIC = "image/heic";
|
||||
public static final String IMAGE_HEIF = "image/heif";
|
||||
public static final String IMAGE_WEBP = "image/webp";
|
||||
public static final String IMAGE_GIF = "image/gif";
|
||||
public static final String AUDIO_AAC = "audio/aac";
|
||||
|
@ -224,6 +225,10 @@ public class MediaUtil {
|
|||
return isHeicType(attachment.getContentType());
|
||||
}
|
||||
|
||||
public static boolean isHeif(Attachment attachment) {
|
||||
return isHeifType(attachment.getContentType());
|
||||
}
|
||||
|
||||
public static boolean isImage(Attachment attachment) {
|
||||
return isImageType(attachment.getContentType());
|
||||
}
|
||||
|
@ -256,6 +261,10 @@ public class MediaUtil {
|
|||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(IMAGE_HEIC);
|
||||
}
|
||||
|
||||
public static boolean isHeifType(String contentType) {
|
||||
return !TextUtils.isEmpty(contentType) && contentType.trim().equals(IMAGE_HEIF);
|
||||
}
|
||||
|
||||
public static boolean isFile(Attachment attachment) {
|
||||
return !isGif(attachment) && !isImage(attachment) && !isAudio(attachment) && !isVideo(attachment);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue