Download small messages inline

pull/158/head
M66B 5 years ago
parent 52c16a52ed
commit d2f25ad652

@ -1466,6 +1466,30 @@ class Core {
if (message.received > account.created) if (message.received > account.created)
updateContactInfo(context, folder, message); updateContactInfo(context, folder, message);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
long maxSize = prefs.getInt("download", 0);
if (maxSize == 0)
maxSize = MessageHelper.SMALL_MESSAGE_SIZE;
else
maxSize = Math.min(maxSize, MessageHelper.SMALL_MESSAGE_SIZE);
// Download small messages inline
if (message.size != null && message.size < maxSize) {
String body = parts.getHtml(context);
Helper.writeText(message.getFile(context), body);
db.message().setMessageContent(message.id,
true,
parts.isPlainOnly(),
HtmlHelper.getPreview(body),
parts.getWarnings(message.warning));
Log.i(folder.name + " inline downloaded message id=" + message.id +
" size=" + message.size + "/" + (body == null ? null : body.length()));
if (!TextUtils.isEmpty(body))
fixAttachments(context, message.id, body);
}
} else { } else {
if (process) { if (process) {
EntityIdentity identity = matchIdentity(context, folder, message); EntityIdentity identity = matchIdentity(context, folder, message);
@ -1716,7 +1740,6 @@ class Core {
maxSize = Long.MAX_VALUE; maxSize = Long.MAX_VALUE;
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id); List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
MessageHelper helper = new MessageHelper(imessage);
boolean fetch = false; boolean fetch = false;
if (!message.content) if (!message.content)
@ -1747,10 +1770,12 @@ class Core {
//fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE); //fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE);
//ifolder.fetch(new Message[]{imessage}, fp); //ifolder.fetch(new Message[]{imessage}, fp);
MessageHelper helper = new MessageHelper(imessage);
MessageHelper.MessageParts parts = helper.getMessageParts(); MessageHelper.MessageParts parts = helper.getMessageParts();
if (!message.content) { if (!message.content) {
if (state.getNetworkState().isUnmetered() || (message.size != null && message.size < maxSize)) { if (state.getNetworkState().isUnmetered() ||
(message.size != null && message.size < maxSize)) {
String body = parts.getHtml(context); String body = parts.getHtml(context);
Helper.writeText(message.getFile(context), body); Helper.writeText(message.getFile(context), body);
db.message().setMessageContent(message.id, db.message().setMessageContent(message.id,

@ -84,8 +84,10 @@ public class MessageHelper {
private static final int APPEND_BUFFER_SIZE = 4 * 1024 * 1024; // bytes private static final int APPEND_BUFFER_SIZE = 4 * 1024 * 1024; // bytes
static final int SMALL_MESSAGE_SIZE = 32 * 1024; // bytes
static final int ATTACHMENT_BUFFER_SIZE = 8192; // bytes static final int ATTACHMENT_BUFFER_SIZE = 8192; // bytes
static final int DEFAULT_ATTACHMENT_DOWNLOAD_SIZE = 262144; // bytes static final int DEFAULT_ATTACHMENT_DOWNLOAD_SIZE = 256 * 1024; // bytes
static void setSystemProperties() { static void setSystemProperties() {
System.setProperty("mail.mime.decodetext.strict", "false"); System.setProperty("mail.mime.decodetext.strict", "false");

Loading…
Cancel
Save