Take inline images into account for having images

This commit is contained in:
M66B 2019-07-17 13:06:47 +02:00
parent 3a96e3d13e
commit 87b9dbd834
1 changed files with 18 additions and 1 deletions

View File

@ -1988,7 +1988,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
builder.getSpanFlags(squote));
}
args.putBoolean("has_images", builder.getSpans(0, body.length(), ImageSpan.class).length > 0);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean inline = prefs.getBoolean("inline_images", false);
boolean has_images;
ImageSpan[] spans = builder.getSpans(0, body.length(), ImageSpan.class);
if (inline) {
has_images = false;
for (ImageSpan span : spans) {
String source = span.getSource();
if (source == null || !source.startsWith("cid:")) {
has_images = true;
break;
}
}
} else
has_images = spans.length > 0;
args.putBoolean("has_images", has_images);
return builder;
}