Commit 7d0eff25 authored by Francisco Cunha's avatar Francisco Cunha

P4A-800 - MessagingController notifies NotificationController at the end of all messages download

parent 657ec50b
......@@ -1643,6 +1643,7 @@ public class MessagingController implements Sync.MessageToSendCallback {
Timber.d("SYNC: Fetching %d small messages for folder %s", smallMessages.size(), folder);
List<LocalMessage> messagesToNotify = new ArrayList<>();
remoteFolder.fetch(smallMessages,
fp, new MessageRetrievalListener<T>() {
@Override
......@@ -1737,7 +1738,7 @@ public class MessagingController implements Sync.MessageToSendCallback {
if (shouldNotifyForMessage(account, localFolder, message)) {
// Notify with the localMessage so that we don't have to recalculate the content preview.
notificationController.addNewMailNotification(account, localMessage, unreadBeforeStart);
messagesToNotify.add(localMessage);
}
}
} catch (MessagingException | RuntimeException me) {
......@@ -1751,6 +1752,7 @@ public class MessagingController implements Sync.MessageToSendCallback {
@Override
public void messagesFinished(int total) {
notificationController.addNewMailsNotification(account, messagesToNotify, unreadBeforeStart);
}
});
......@@ -1788,6 +1790,7 @@ public class MessagingController implements Sync.MessageToSendCallback {
Timber.d("SYNC: Fetching large messages for folder %s", folder);
remoteFolder.fetch(largeMessages, fp, null);
List<LocalMessage> messagesToNotify = new ArrayList<>();
for (T message : largeMessages) {
if (!shouldImportMessage(account, message, earliestDate)) {
......@@ -1822,9 +1825,10 @@ public class MessagingController implements Sync.MessageToSendCallback {
// Send a notification of this message
if (shouldNotifyForMessage(account, localFolder, message)) {
// Notify with the localMessage so that we don't have to recalculate the content preview.
notificationController.addNewMailNotification(account, localMessage, unreadBeforeStart);
messagesToNotify.add(localMessage);
}
}
notificationController.addNewMailsNotification(account,messagesToNotify,unreadBeforeStart);
Timber.d("SYNC: Done fetching large messages for folder %s", folder);
}
......
......@@ -15,6 +15,7 @@ import com.fsck.k9.activity.MessageReference;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mailstore.LocalMessage;
import java.util.List;
public class NotificationController {
private static final int NOTIFICATION_LED_ON_TIME = 500;
......@@ -104,8 +105,10 @@ public class NotificationController {
syncNotifications.clearFetchingMailNotification(account);
}
public void addNewMailNotification(Account account, LocalMessage message, int previousUnreadMessageCount) {
newMailNotifications.addNewMailNotification(account, message, previousUnreadMessageCount);
public void addNewMailsNotification(Account account, List<LocalMessage> messages, int previousUnreadMessageCount) {
for (LocalMessage message : messages) {
newMailNotifications.addNewMailNotification(account, message, previousUnreadMessageCount);
}
}
public void removeNewMailNotification(Account account, MessageReference messageReference) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment