From 692c1ed647fa47361436762b3a3ad5d663c373e8 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 26 Jun 2021 13:15:41 +0200 Subject: [PATCH] Favicon type --- app/src/main/java/eu/faircode/email/ContactInfo.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ContactInfo.java b/app/src/main/java/eu/faircode/email/ContactInfo.java index 5590b87a71..64b04e2205 100644 --- a/app/src/main/java/eu/faircode/email/ContactInfo.java +++ b/app/src/main/java/eu/faircode/email/ContactInfo.java @@ -385,14 +385,14 @@ public class ContactInfo { futures.add(executorFavicon.submit(new Callable() { @Override public Bitmap call() throws Exception { - return getFavicon(new URL(base, "favicon.ico"), scaleToPixels, context); + return getFavicon(new URL(base, "favicon.ico"), null, scaleToPixels, context); } })); futures.add(executorFavicon.submit(new Callable() { @Override public Bitmap call() throws Exception { - return getFavicon(new URL(www, "favicon.ico"), scaleToPixels, context); + return getFavicon(new URL(www, "favicon.ico"), null, scaleToPixels, context); } })); @@ -577,7 +577,7 @@ public class ContactInfo { futures.add(executorFavicon.submit(new Callable() { @Override public Bitmap call() throws Exception { - return getFavicon(url, scaleToPixels, context); + return getFavicon(url, img.attr("type"), scaleToPixels, context); } })); } @@ -597,7 +597,7 @@ public class ContactInfo { } @NonNull - private static Bitmap getFavicon(URL url, int scaleToPixels, Context context) throws IOException { + private static Bitmap getFavicon(URL url, String type, int scaleToPixels, Context context) throws IOException { Log.i("GET favicon " + url); if (!"https".equals(url.getProtocol())) @@ -622,6 +622,9 @@ public class ContactInfo { if (status != HttpURLConnection.HTTP_OK) throw new FileNotFoundException("Error " + status + ":" + connection.getResponseMessage()); + if ("image/svg+xml".equals(type) || url.getPath().endsWith(".svg")) + ; // Android does not support SVG + Bitmap bitmap = ImageHelper.getScaledBitmap(connection.getInputStream(), url.toString(), scaleToPixels); if (bitmap == null) throw new FileNotFoundException("decodeStream");