From 03e2013ab12d78c48dc8c7c2eab85c00d76ab6cb Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 18 Aug 2021 19:37:35 +0200 Subject: [PATCH] Added support for AVIF --- app/src/main/java/eu/faircode/email/DB.java | 3 +++ app/src/main/java/eu/faircode/email/ImageHelper.java | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/DB.java b/app/src/main/java/eu/faircode/email/DB.java index ceaef9ac27..bbad2dbe8c 100644 --- a/app/src/main/java/eu/faircode/email/DB.java +++ b/app/src/main/java/eu/faircode/email/DB.java @@ -427,6 +427,9 @@ public abstract class DB extends RoomDatabase { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) for (String img : ImageHelper.IMAGE_TYPES8) image.add("'" + img + "'"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + for (String img : ImageHelper.IMAGE_TYPES12) + image.add("'" + img + "'"); String images = TextUtils.join(",", image); db.execSQL("CREATE TRIGGER IF NOT EXISTS attachment_insert" + diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index f8c1f6ca99..25dcba9348 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -109,11 +109,20 @@ class ImageHelper { "image/heif" )); + // https://developer.android.com/about/versions/12/features#avif + static final List IMAGE_TYPES12 = Collections.unmodifiableList(Arrays.asList( + "image/avif" + )); + static boolean isImage(String mimeType) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) if (IMAGE_TYPES8.contains(mimeType)) return true; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + if (IMAGE_TYPES12.contains(mimeType)) + return true; + return IMAGE_TYPES.contains(mimeType); }