Open image link on click when not showing images

This commit is contained in:
M66B 2019-05-03 16:58:18 +02:00
parent 2e56ed8d1f
commit c0ed1c6e38
1 changed files with 14 additions and 13 deletions

View File

@ -1855,6 +1855,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
boolean show_images = properties.getValue("images", message.id);
if (!show_images) {
ImageSpan[] image = buffer.getSpans(off, off, ImageSpan.class);
if (image.length > 0 && image[0].getSource() != null) {
Uri uri = Uri.parse(image[0].getSource());
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
onOpenLink(uri);
return true;
}
}
}
URLSpan[] link = buffer.getSpans(off, off, URLSpan.class);
if (link.length > 0) {
String url = link[0].getURL();
@ -1867,25 +1879,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ImageSpan[] image = buffer.getSpans(off, off, ImageSpan.class);
if (image.length > 0 && image[0].getSource() != null) {
boolean show_images = properties.getValue("images", message.id);
if (show_images) {
onOpenImage(image[0].getDrawable());
return true;
} else {
Uri uri = Uri.parse(image[0].getSource());
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
onOpenLink(uri);
return true;
}
}
onOpenImage(image[0].getDrawable());
return true;
}
DynamicDrawableSpan[] ddss = buffer.getSpans(off, off, DynamicDrawableSpan.class);
if (ddss.length > 0) {
properties.setValue("quotes", message.id, true);
boolean show_images = properties.getValue("images", message.id);
Bundle args = new Bundle();
args.putSerializable("message", message);
args.putBoolean("show_images", show_images);