Show image description when not showing images

This commit is contained in:
M66B 2019-06-30 09:59:03 +02:00
parent 655f0e3d3b
commit a6963da515
4 changed files with 22 additions and 14 deletions

View File

@ -127,7 +127,7 @@ public class ActivityEml extends ActivityBase {
result.html = parts.getHtml(context);
if (result.html != null)
result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(context, result.html));
result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(context, result.html, false));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
mmessage.writeTo(bos);

View File

@ -2054,7 +2054,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
body = document.html();
}
String html = HtmlHelper.sanitize(context, body);
String html = HtmlHelper.sanitize(context, body, show_images);
if (debug)
html += "<pre>" + Html.escapeHtml(html) + "</pre>";

View File

@ -2868,7 +2868,7 @@ public class FragmentCompose extends FragmentBase {
Spanned spannedRef = null;
File refFile = draft.getRefFile(context);
if (refFile.exists()) {
String quote = HtmlHelper.sanitize(context, Helper.readText(refFile));
String quote = HtmlHelper.sanitize(context, Helper.readText(refFile), show_images);
Spanned spannedQuote = HtmlHelper.fromHtml(quote,
new Html.ImageGetter() {
@Override

View File

@ -84,7 +84,7 @@ public class HtmlHelper {
private static final ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
static String sanitize(Context context, String html) {
static String sanitize(Context context, String html, boolean show_images) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean paranoid = prefs.getBoolean("paranoid", true);
@ -224,17 +224,25 @@ public class HtmlHelper {
else
table.tagName("div");
// Remove link tracking pixels
if (paranoid)
for (Element img : document.select("img"))
if (isTrackingPixel(img)) {
String src = img.attr("src");
img.removeAttr("src");
img.tagName("a");
img.attr("href", src);
img.appendText(context.getString(R.string.title_hint_tracking_image,
img.attr("width"), img.attr("height")));
// Images
for (Element img : document.select("img")) {
// Remove link tracking pixels
if (paranoid && isTrackingPixel(img)) {
String src = img.attr("src");
img.removeAttr("src");
img.tagName("a");
img.attr("href", src);
img.appendText(context.getString(R.string.title_hint_tracking_image,
img.attr("width"), img.attr("height")));
}
if (!show_images) {
String alt = img.attr("alt");
if (!TextUtils.isEmpty(alt)) {
img.appendText(alt);
}
}
}
// Autolink
final Pattern pattern = Pattern.compile(