Plain text: always attach images

pull/178/head
M66B 5 years ago
parent c009f1c4bf
commit 50bea656ea

@ -87,6 +87,11 @@ public interface DaoAttachment {
" WHERE id = :id")
void setError(long id, String error);
@Query("UPDATE attachment" +
" SET disposition = :disposition" +
" WHERE id = :id")
void setDisposition(long id, String disposition);
@Query("UPDATE attachment" +
" SET cid = :cid" +
" WHERE id = :id")

@ -4098,20 +4098,30 @@ public class FragmentCompose extends FragmentBase {
}
} else if (action == R.id.action_send) {
// Remove unused inline images
List<String> cids = new ArrayList<>();
if (draft.plain_only == null || !draft.plain_only)
for (Element element : JsoupEx.parse(body).select("img")) {
if (draft.plain_only == null || !draft.plain_only) {
// Remove unused inline images
List<String> cids = new ArrayList<>();
Document d = JsoupEx.parse(body);
for (Element element : d.select("img")) {
String src = element.attr("src");
if (src.startsWith("cid:"))
cids.add("<" + src.substring(4) + ">");
}
for (EntityAttachment attachment : new ArrayList<>(attachments))
if (attachment.isInline() && !cids.contains(attachment.cid)) {
Log.i("Removing unused inline attachment cid=" + attachment.cid);
db.attachment().deleteAttachment(attachment.id);
}
for (EntityAttachment attachment : new ArrayList<>(attachments))
if (attachment.isInline() && !cids.contains(attachment.cid)) {
Log.i("Removing unused inline attachment cid=" + attachment.cid);
db.attachment().deleteAttachment(attachment.id);
}
} else {
// Convert inline images to attachments
for (EntityAttachment attachment : new ArrayList<>(attachments))
if (attachment.isInline()) {
Log.i("Converting to attachment cid=" + attachment.cid);
attachment.disposition = Part.ATTACHMENT;
db.attachment().setDisposition(attachment.id, attachment.disposition);
}
}
// Delete draft (cannot move to outbox)
EntityOperation.queue(context, draft, EntityOperation.DELETE);

Loading…
Cancel
Save