Commit 3ec9eb0a authored by Francisco Cunha's avatar Francisco Cunha

Merge branch 'bug/P4A-800' into develop

parents f992a229 8c84cc4d
......@@ -788,6 +788,9 @@ class ImapFolder extends Folder<ImapMessage> {
throw ioExceptionHandler(connection, ioe);
}
}
if (listener != null) {
listener.messagesFinished(messages.size());
}
}
@Override
......
......@@ -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
......@@ -1736,8 +1737,7 @@ 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);
}
}
} catch (MessagingException | RuntimeException me) {
......@@ -1751,6 +1751,8 @@ public class MessagingController implements Sync.MessageToSendCallback {
@Override
public void messagesFinished(int total) {
// Notify with the localMessages so that we don't have to recalculate the content preview.
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)) {
......@@ -1821,10 +1824,11 @@ 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);
}
}
// Notify with the localMessages so that we don't have to recalculate the content preview.
notificationController.addNewMailsNotification(account, messagesToNotify, unreadBeforeStart);
Timber.d("SYNC: Done fetching large messages for folder %s", folder);
}
......
......@@ -11,6 +11,8 @@ import com.fsck.k9.K9.NotificationHideSubject;
import com.fsck.k9.activity.MessageReference;
import com.fsck.k9.mailstore.LocalMessage;
import java.util.List;
/**
* Handle notifications for new messages.
......@@ -23,6 +25,7 @@ import com.fsck.k9.mailstore.LocalMessage;
* </p>
*/
class NewMailNotifications {
private static final int FIRST_POSITION = 0;
private final NotificationController controller;
private final NotificationContentCreator contentCreator;
private final DeviceNotifications deviceNotifications;
......@@ -48,7 +51,18 @@ class NewMailNotifications {
return new NewMailNotifications(controller, contentCreator, deviceNotifications, wearNotifications);
}
public void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount) {
void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount) {
addNewMailNotification(account, message, unreadMessageCount, false);
}
void addNewMailsNotification(Account account, List<LocalMessage> messages, int unreadMessageCount) {
for (int position = 0; position < messages.size(); position++) {
LocalMessage message = messages.get(position);
addNewMailNotification(account, message, unreadMessageCount, position != FIRST_POSITION);
}
}
private void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount, boolean silent) {
NotificationContent content = contentCreator.createFromMessage(account, message);
synchronized (lock) {
......@@ -61,7 +75,7 @@ class NewMailNotifications {
}
createStackedNotification(account, result.getNotificationHolder());
createSummaryNotification(account, notificationData, false);
createSummaryNotification(account, notificationData, silent);
}
}
......
......@@ -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,8 @@ 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) {
newMailNotifications.addNewMailsNotification(account, messages, 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