Fixed showing inline images HTML

pull/175/head
M66B 6 years ago
parent 5d4028fd63
commit 974e9047e1

@ -1739,7 +1739,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
HtmlHelper.setViewport(document); HtmlHelper.setViewport(document);
if (inline || show_images) if (inline || show_images)
HtmlHelper.embedInlineImages(context, message.id, document); HtmlHelper.embedInlineImages(context, message.id, document, show_images || !inline);
boolean disable_tracking = prefs.getBoolean("disable_tracking", true); boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
if (disable_tracking) if (disable_tracking)

@ -5893,7 +5893,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Document document = JsoupEx.parse(file); Document document = JsoupEx.parse(file);
HtmlHelper.truncate(document, false); HtmlHelper.truncate(document, false);
HtmlHelper.embedInlineImages(context, id, document); HtmlHelper.embedInlineImages(context, id, document, true);
Element p = document.createElement("p"); Element p = document.createElement("p");

@ -57,7 +57,9 @@ import org.jsoup.select.NodeVisitor;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -1054,7 +1056,7 @@ public class HtmlHelper {
} }
} }
static void embedInlineImages(Context context, long id, Document document) throws IOException { static void embedInlineImages(Context context, long id, Document document, boolean local) throws IOException {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
for (Element img : document.select("img")) { for (Element img : document.select("img")) {
String src = img.attr("src"); String src = img.attr("src");
@ -1063,10 +1065,11 @@ public class HtmlHelper {
EntityAttachment attachment = db.attachment().getAttachment(id, cid); EntityAttachment attachment = db.attachment().getAttachment(id, cid);
if (attachment != null && attachment.available) { if (attachment != null && attachment.available) {
File file = attachment.getFile(context); File file = attachment.getFile(context);
if (local) {
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file); Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
img.attr("src", uri.toString()); img.attr("src", uri.toString());
Log.i("Inline image uri=" + uri); Log.i("Inline image uri=" + uri);
/* } else {
try (InputStream is = new FileInputStream(file)) { try (InputStream is = new FileInputStream(file)) {
byte[] bytes = new byte[(int) file.length()]; byte[] bytes = new byte[(int) file.length()];
if (is.read(bytes) != bytes.length) if (is.read(bytes) != bytes.length)
@ -1080,7 +1083,7 @@ public class HtmlHelper {
img.attr("src", sb.toString()); img.attr("src", sb.toString());
} }
*/ }
} }
} }
} }

Loading…
Cancel
Save