mirror of https://github.com/M66B/FairEmail.git
Show image description when not showing images
This commit is contained in:
parent
655f0e3d3b
commit
a6963da515
|
@ -127,7 +127,7 @@ public class ActivityEml extends ActivityBase {
|
||||||
|
|
||||||
result.html = parts.getHtml(context);
|
result.html = parts.getHtml(context);
|
||||||
if (result.html != null)
|
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();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
mmessage.writeTo(bos);
|
mmessage.writeTo(bos);
|
||||||
|
|
|
@ -2054,7 +2054,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
body = document.html();
|
body = document.html();
|
||||||
}
|
}
|
||||||
|
|
||||||
String html = HtmlHelper.sanitize(context, body);
|
String html = HtmlHelper.sanitize(context, body, show_images);
|
||||||
if (debug)
|
if (debug)
|
||||||
html += "<pre>" + Html.escapeHtml(html) + "</pre>";
|
html += "<pre>" + Html.escapeHtml(html) + "</pre>";
|
||||||
|
|
||||||
|
|
|
@ -2868,7 +2868,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
Spanned spannedRef = null;
|
Spanned spannedRef = null;
|
||||||
File refFile = draft.getRefFile(context);
|
File refFile = draft.getRefFile(context);
|
||||||
if (refFile.exists()) {
|
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,
|
Spanned spannedQuote = HtmlHelper.fromHtml(quote,
|
||||||
new Html.ImageGetter() {
|
new Html.ImageGetter() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class HtmlHelper {
|
||||||
|
|
||||||
private static final ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
|
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);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean paranoid = prefs.getBoolean("paranoid", true);
|
boolean paranoid = prefs.getBoolean("paranoid", true);
|
||||||
|
|
||||||
|
@ -224,10 +224,10 @@ public class HtmlHelper {
|
||||||
else
|
else
|
||||||
table.tagName("div");
|
table.tagName("div");
|
||||||
|
|
||||||
|
// Images
|
||||||
|
for (Element img : document.select("img")) {
|
||||||
// Remove link tracking pixels
|
// Remove link tracking pixels
|
||||||
if (paranoid)
|
if (paranoid && isTrackingPixel(img)) {
|
||||||
for (Element img : document.select("img"))
|
|
||||||
if (isTrackingPixel(img)) {
|
|
||||||
String src = img.attr("src");
|
String src = img.attr("src");
|
||||||
img.removeAttr("src");
|
img.removeAttr("src");
|
||||||
img.tagName("a");
|
img.tagName("a");
|
||||||
|
@ -236,6 +236,14 @@ public class HtmlHelper {
|
||||||
img.attr("width"), img.attr("height")));
|
img.attr("width"), img.attr("height")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!show_images) {
|
||||||
|
String alt = img.attr("alt");
|
||||||
|
if (!TextUtils.isEmpty(alt)) {
|
||||||
|
img.appendText(alt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Autolink
|
// Autolink
|
||||||
final Pattern pattern = Pattern.compile(
|
final Pattern pattern = Pattern.compile(
|
||||||
PatternsCompat.AUTOLINK_EMAIL_ADDRESS.pattern() + "|" +
|
PatternsCompat.AUTOLINK_EMAIL_ADDRESS.pattern() + "|" +
|
||||||
|
|
Loading…
Reference in New Issue