Print attachment names/sizes

pull/175/head
M66B 5 years ago
parent fd6cdeae39
commit 4cdacb4698

@ -5978,11 +5978,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (!file.exists())
return null;
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
if (attachments == null)
return null;
Document document = JsoupEx.parse(file);
HtmlHelper.truncate(document, false);
HtmlHelper.embedInlineImages(context, id, document, true);
Element p = document.createElement("p");
Element header = document.createElement("p");
if (message.from != null && message.from.length > 0) {
Element span = document.createElement("span");
@ -5991,7 +5995,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
span.appendChild(strong);
span.appendText(" " + MessageHelper.formatAddresses(message.from));
span.appendElement("br");
p.appendChild(span);
header.appendChild(span);
}
if (message.to != null && message.to.length > 0) {
@ -6001,7 +6005,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
span.appendChild(strong);
span.appendText(" " + MessageHelper.formatAddresses(message.to));
span.appendElement("br");
p.appendChild(span);
header.appendChild(span);
}
if (message.cc != null && message.cc.length > 0) {
@ -6011,7 +6015,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
span.appendChild(strong);
span.appendText(" " + MessageHelper.formatAddresses(message.cc));
span.appendElement("br");
p.appendChild(span);
header.appendChild(span);
}
{
@ -6023,26 +6027,45 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
span.appendChild(strong);
span.appendText(" " + DTF.format(message.received));
span.appendElement("br");
p.appendChild(span);
header.appendChild(span);
}
if (!TextUtils.isEmpty(message.subject)) {
Element span = document.createElement("span");
span.appendText(message.subject);
span.appendElement("br");
p.appendChild(span);
header.appendChild(span);
}
if (headers && message.headers != null) {
p.appendElement("hr");
header.appendElement("hr");
Element pre = document.createElement("pre");
pre.text(message.headers);
p.appendChild(pre);
header.appendChild(pre);
}
p.appendElement("hr").appendElement("br");
header.appendElement("hr").appendElement("br");
document.prependChild(header);
boolean hasAttachments = false;
Element footer = document.createElement("p");
footer.appendElement("br").appendElement("hr");
for (EntityAttachment attachment : attachments)
if (!attachment.isInline()) {
hasAttachments = true;
Element strong = document.createElement("strong");
strong.text(getString(R.string.title_attachment));
footer.appendChild(strong);
if (!TextUtils.isEmpty(attachment.name))
footer.appendText(" " + attachment.name);
if (attachment.size != null)
footer.appendText(" " + Helper.humanReadableByteCount(attachment.size, true));
footer.appendElement("br");
}
document.prependChild(p);
if (hasAttachments)
document.appendChild(footer);
return new String[]{message.subject, document.html()};
}

@ -771,6 +771,7 @@
<string name="title_received">Received:</string>
<string name="title_size">Size:</string>
<string name="title_subject">Subject:</string>
<string name="title_attachment">Attachment:</string>
<string name="title_body_hint">Your message</string>
<string name="title_discard">Discard</string>
<string name="title_save">Save</string>

Loading…
Cancel
Save