Respect folder download setting on inline download

This commit is contained in:
M66B 2019-07-15 12:54:53 +02:00
parent 317adf4f02
commit 0b10c17b0b
3 changed files with 15 additions and 11 deletions

View File

@ -416,7 +416,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
message = Core.synchronizeMessage(context, message = Core.synchronizeMessage(context,
account, browsable, account, browsable,
ifolder, (IMAPMessage) isub[j], ifolder, (IMAPMessage) isub[j],
true, true, true,
rules, null); rules, null);
found++; found++;
} }

View File

@ -1197,7 +1197,7 @@ class Core {
context, context,
account, folder, account, folder,
ifolder, (IMAPMessage) isub[j], ifolder, (IMAPMessage) isub[j],
false, false, download,
rules, state); rules, state);
ids[from + j] = message.id; ids[from + j] = message.id;
} catch (MessageRemovedException ex) { } catch (MessageRemovedException ex) {
@ -1304,7 +1304,7 @@ class Core {
Context context, Context context,
EntityAccount account, EntityFolder folder, EntityAccount account, EntityFolder folder,
IMAPFolder ifolder, IMAPMessage imessage, IMAPFolder ifolder, IMAPMessage imessage,
boolean browsed, boolean browsed, boolean download,
List<EntityRule> rules, State state) throws MessagingException, IOException { List<EntityRule> rules, State state) throws MessagingException, IOException {
long uid = ifolder.getUID(imessage); long uid = ifolder.getUID(imessage);
@ -1468,16 +1468,16 @@ class Core {
updateContactInfo(context, folder, message); updateContactInfo(context, folder, message);
// Download small messages inline // Download small messages inline
if (message.size != null) { if (download && message.size != null) {
long maxSize; long maxSize;
if (state == null || state.networkState.isUnmetered()) if (state == null || state.networkState.isUnmetered())
maxSize = MessageHelper.SMALL_MESSAGE_SIZE; maxSize = MessageHelper.SMALL_MESSAGE_SIZE;
else { else {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int download = prefs.getInt("download", 0); int downloadSize = prefs.getInt("download", 0);
maxSize = (download == 0 maxSize = (downloadSize == 0
? MessageHelper.SMALL_MESSAGE_SIZE ? MessageHelper.SMALL_MESSAGE_SIZE
: Math.min(download, MessageHelper.SMALL_MESSAGE_SIZE)); : Math.min(downloadSize, MessageHelper.SMALL_MESSAGE_SIZE));
} }
if (message.size < maxSize) { if (message.size < maxSize) {

View File

@ -825,17 +825,19 @@ public class ServiceSynchronize extends LifecycleService {
fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE); fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE);
ifolder.fetch(e.getMessages(), fp); ifolder.fetch(e.getMessages(), fp);
boolean download = db.folder().getFolderDownload(folder.id);
for (Message imessage : e.getMessages()) for (Message imessage : e.getMessages())
try { try {
EntityMessage message = Core.synchronizeMessage( EntityMessage message = Core.synchronizeMessage(
ServiceSynchronize.this, ServiceSynchronize.this,
account, folder, account, folder,
ifolder, (IMAPMessage) imessage, ifolder, (IMAPMessage) imessage,
false, false, download,
db.rule().getEnabledRules(folder.id), db.rule().getEnabledRules(folder.id),
state); state);
if (db.folder().getFolderDownload(folder.id)) if (download)
Core.downloadMessage(ServiceSynchronize.this, Core.downloadMessage(ServiceSynchronize.this,
folder, ifolder, folder, ifolder,
(IMAPMessage) imessage, message.id, state); (IMAPMessage) imessage, message.id, state);
@ -920,15 +922,17 @@ public class ServiceSynchronize extends LifecycleService {
fp.add(IMAPFolder.FetchProfileItem.FLAGS); fp.add(IMAPFolder.FetchProfileItem.FLAGS);
ifolder.fetch(new Message[]{e.getMessage()}, fp); ifolder.fetch(new Message[]{e.getMessage()}, fp);
boolean download = db.folder().getFolderDownload(folder.id);
EntityMessage message = Core.synchronizeMessage( EntityMessage message = Core.synchronizeMessage(
ServiceSynchronize.this, ServiceSynchronize.this,
account, folder, account, folder,
ifolder, (IMAPMessage) e.getMessage(), ifolder, (IMAPMessage) e.getMessage(),
false, false, download,
db.rule().getEnabledRules(folder.id), db.rule().getEnabledRules(folder.id),
state); state);
if (db.folder().getFolderDownload(folder.id)) if (download)
Core.downloadMessage(ServiceSynchronize.this, Core.downloadMessage(ServiceSynchronize.this,
folder, ifolder, folder, ifolder,
(IMAPMessage) e.getMessage(), message.id, state); (IMAPMessage) e.getMessage(), message.id, state);