From 344669cc1cbf18f339f366001ac0bdfe013ef88c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 23 May 2024 12:37:42 +0200 Subject: [PATCH] Added open tracking link when showing images Always requires confirmation --- .../main/java/eu/faircode/email/AdapterMessage.java | 10 +++++++--- app/src/main/java/eu/faircode/email/ImageSpanEx.java | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 540ff5e15e..d2af843ab0 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -647,6 +647,7 @@ public class AdapterMessage extends RecyclerView.Adapter 0 && image[0].getSource() != null) { Uri uri = Uri.parse(image[0].getSource()); + if (UriHelper.isHyperLink(uri)) { ripple(event); if (onOpenLink(uri, null, @@ -675,10 +676,13 @@ public class AdapterMessage extends RecyclerView.Adapter 0) { - if (image[0] instanceof ImageSpanEx && - ((ImageSpanEx) image[0]).getTracking()) + if (image.length > 0 && image[0] instanceof ImageSpanEx) { + String tracking = ((ImageSpanEx) image[0]).getTracking(); + if (!TextUtils.isEmpty(tracking)) { + onOpenLink(Uri.parse(tracking), + context.getString(R.string.title_legend_tracking_pixel), true); return true; + } ripple(event); onOpenImage(message.id, image[0].getSource(), diff --git a/app/src/main/java/eu/faircode/email/ImageSpanEx.java b/app/src/main/java/eu/faircode/email/ImageSpanEx.java index a2af6db698..11399c5958 100644 --- a/app/src/main/java/eu/faircode/email/ImageSpanEx.java +++ b/app/src/main/java/eu/faircode/email/ImageSpanEx.java @@ -30,7 +30,7 @@ import org.jsoup.nodes.Element; public class ImageSpanEx extends ImageSpan { private final int width; private final int height; - private final boolean tracking; + private final String tracking; public ImageSpanEx(@NonNull Drawable drawable, @NonNull Element img) { super(drawable, img.attr("src")); @@ -60,7 +60,7 @@ public class ImageSpanEx extends ImageSpan { this.width = _width; this.height = _height; - this.tracking = !TextUtils.isEmpty(img.attr("x-tracking")); + this.tracking = img.attr("x-tracking"); } public int getWidth() { @@ -71,7 +71,7 @@ public class ImageSpanEx extends ImageSpan { return this.height; } - public boolean getTracking() { + public String getTracking() { return this.tracking; } }