Added open tracking link when showing images

Always requires confirmation
pull/215/head
M66B 7 months ago
parent 50f16d93ac
commit 344669cc1c

@ -647,6 +647,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ImageSpan[] image = buffer.getSpans(off, off, ImageSpan.class); ImageSpan[] image = buffer.getSpans(off, off, ImageSpan.class);
if (image.length > 0 && image[0].getSource() != null) { if (image.length > 0 && image[0].getSource() != null) {
Uri uri = Uri.parse(image[0].getSource()); Uri uri = Uri.parse(image[0].getSource());
if (UriHelper.isHyperLink(uri)) { if (UriHelper.isHyperLink(uri)) {
ripple(event); ripple(event);
if (onOpenLink(uri, null, if (onOpenLink(uri, null,
@ -675,10 +676,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
ImageSpan[] image = buffer.getSpans(off, off, ImageSpan.class); ImageSpan[] image = buffer.getSpans(off, off, ImageSpan.class);
if (image.length > 0) { if (image.length > 0 && image[0] instanceof ImageSpanEx) {
if (image[0] instanceof ImageSpanEx && String tracking = ((ImageSpanEx) image[0]).getTracking();
((ImageSpanEx) image[0]).getTracking()) if (!TextUtils.isEmpty(tracking)) {
onOpenLink(Uri.parse(tracking),
context.getString(R.string.title_legend_tracking_pixel), true);
return true; return true;
}
ripple(event); ripple(event);
onOpenImage(message.id, image[0].getSource(), onOpenImage(message.id, image[0].getSource(),

@ -30,7 +30,7 @@ import org.jsoup.nodes.Element;
public class ImageSpanEx extends ImageSpan { public class ImageSpanEx extends ImageSpan {
private final int width; private final int width;
private final int height; private final int height;
private final boolean tracking; private final String tracking;
public ImageSpanEx(@NonNull Drawable drawable, @NonNull Element img) { public ImageSpanEx(@NonNull Drawable drawable, @NonNull Element img) {
super(drawable, img.attr("src")); super(drawable, img.attr("src"));
@ -60,7 +60,7 @@ public class ImageSpanEx extends ImageSpan {
this.width = _width; this.width = _width;
this.height = _height; this.height = _height;
this.tracking = !TextUtils.isEmpty(img.attr("x-tracking")); this.tracking = img.attr("x-tracking");
} }
public int getWidth() { public int getWidth() {
@ -71,7 +71,7 @@ public class ImageSpanEx extends ImageSpan {
return this.height; return this.height;
} }
public boolean getTracking() { public String getTracking() {
return this.tracking; return this.tracking;
} }
} }

Loading…
Cancel
Save