Loading app/core/src/main/java/com/fsck/k9/controller/KoinModule.kt +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ val controllerModule = module { get<NotificationController>(), get<NotificationStrategy>(), get<LocalStoreProvider>(), get<MessageCountsProvider>(), get<BackendManager>(), get<Preferences>(), get<MessageStoreManager>(), Loading app/core/src/main/java/com/fsck/k9/controller/MessageCountsProvider.kt +13 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ import timber.log.Timber interface MessageCountsProvider { fun getMessageCounts(account: Account): MessageCounts fun getMessageCounts(searchAccount: SearchAccount): MessageCounts fun getUnreadMessageCount(account: Account, folderId: Long): Int } data class MessageCounts(val unread: Int, val starred: Int) Loading Loading @@ -52,6 +53,18 @@ internal class DefaultMessageCountsProvider( return MessageCounts(unreadCount, starredCount) } override fun getUnreadMessageCount(account: Account, folderId: Long): Int { return try { val localStore = localStoreProvider.getInstance(account) val localFolder = localStore.getFolder(folderId) localFolder.unreadMessageCount } catch (e: MessagingException) { Timber.e(e, "Unable to getUnreadMessageCount for account: %s, folder: %d", account, folderId) 0 } } private fun getMessageCountsWithLocalSearch(account: Account, search: LocalSearch): MessageCounts { return try { val localStore = localStoreProvider.getInstance(account) Loading app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +1 −25 Original line number Diff line number Diff line Loading @@ -82,7 +82,6 @@ import com.fsck.k9.mailstore.SpecialLocalFoldersCreator; import com.fsck.k9.notification.NotificationController; import com.fsck.k9.notification.NotificationStrategy; import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.SearchAccount; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import timber.log.Timber; Loading Loading @@ -126,7 +125,6 @@ public class MessagingController { private final Set<MessagingListener> listeners = new CopyOnWriteArraySet<>(); private final ExecutorService threadPool = Executors.newCachedThreadPool(); private final MemorizingMessagingListener memorizingMessagingListener = new MemorizingMessagingListener(); private final MessageCountsProvider messageCountsProvider; private final DraftOperations draftOperations; private final NotificationOperations notificationOperations; Loading @@ -142,15 +140,13 @@ public class MessagingController { MessagingController(Context context, NotificationController notificationController, NotificationStrategy notificationStrategy, LocalStoreProvider localStoreProvider, MessageCountsProvider messageCountsProvider, BackendManager backendManager, Preferences preferences, MessageStoreManager messageStoreManager, BackendManager backendManager, Preferences preferences, MessageStoreManager messageStoreManager, SaveMessageDataCreator saveMessageDataCreator, SpecialLocalFoldersCreator specialLocalFoldersCreator, List<ControllerExtension> controllerExtensions) { this.context = context; this.notificationController = notificationController; this.notificationStrategy = notificationStrategy; this.localStoreProvider = localStoreProvider; this.messageCountsProvider = messageCountsProvider; this.backendManager = backendManager; this.preferences = preferences; this.messageStoreManager = messageStoreManager; Loading Loading @@ -1652,22 +1648,6 @@ public class MessagingController { } } public int getUnreadMessageCount(Account account) { MessageCounts messageCounts = messageCountsProvider.getMessageCounts(account); return messageCounts.getUnread(); } public int getUnreadMessageCount(SearchAccount searchAccount) { MessageCounts messageCounts = messageCountsProvider.getMessageCounts(searchAccount); return messageCounts.getUnread(); } public int getFolderUnreadMessageCount(Account account, Long folderId) throws MessagingException { LocalStore localStore = localStoreProvider.getInstance(account); LocalFolder localFolder = localStore.getFolder(folderId); return localFolder.getUnreadMessageCount(); } public boolean isMoveCapable(MessageReference messageReference) { return !messageReference.getUid().startsWith(K9.LOCAL_UID_PREFIX); } Loading Loading @@ -2370,10 +2350,6 @@ public class MessagingController { Timber.v("Clearing notification flag for %s", account); clearFetchingMailNotification(account); if (getUnreadMessageCount(account) == 0) { notificationController.clearNewMailNotifications(account, false); } } } ); Loading app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java +1 −15 Original line number Diff line number Diff line Loading @@ -34,8 +34,6 @@ import com.fsck.k9.mailstore.SpecialLocalFoldersCreator; import com.fsck.k9.notification.NotificationController; import com.fsck.k9.notification.NotificationStrategy; import com.fsck.k9.preferences.Protocols; import com.fsck.k9.search.SearchAccount; import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.Before; import org.junit.Test; Loading Loading @@ -108,18 +106,6 @@ public class MessagingControllerTest extends K9RobolectricTest { private LocalMessage localMessageToSend1; private volatile boolean hasFetchedMessage = false; private MessageCountsProvider messageCountsProvider = new MessageCountsProvider() { @Override public MessageCounts getMessageCounts(@NotNull SearchAccount searchAccount) { return new MessageCounts(0, 0); } @Override public MessageCounts getMessageCounts(@NotNull Account account) { return new MessageCounts(0, 0); } }; private Preferences preferences; private String accountUuid; Loading @@ -133,7 +119,7 @@ public class MessagingControllerTest extends K9RobolectricTest { preferences = Preferences.getPreferences(); controller = new MessagingController(appContext, notificationController, notificationStrategy, localStoreProvider, messageCountsProvider, backendManager, preferences, messageStoreManager, localStoreProvider, backendManager, preferences, messageStoreManager, saveMessageDataCreator, specialLocalFoldersCreator, Collections.<ControllerExtension>emptyList()); configureAccount(); Loading app/k9mail/src/main/java/com/fsck/k9/widget/unread/KoinModule.kt +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ val unreadWidgetModule = module { UnreadWidgetDataProvider( context = get(), preferences = get(), messagingController = get(), messageCountsProvider = get(), defaultFolderProvider = get(), folderRepository = get(), folderNameFormatterFactory = get() Loading Loading
app/core/src/main/java/com/fsck/k9/controller/KoinModule.kt +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ val controllerModule = module { get<NotificationController>(), get<NotificationStrategy>(), get<LocalStoreProvider>(), get<MessageCountsProvider>(), get<BackendManager>(), get<Preferences>(), get<MessageStoreManager>(), Loading
app/core/src/main/java/com/fsck/k9/controller/MessageCountsProvider.kt +13 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ import timber.log.Timber interface MessageCountsProvider { fun getMessageCounts(account: Account): MessageCounts fun getMessageCounts(searchAccount: SearchAccount): MessageCounts fun getUnreadMessageCount(account: Account, folderId: Long): Int } data class MessageCounts(val unread: Int, val starred: Int) Loading Loading @@ -52,6 +53,18 @@ internal class DefaultMessageCountsProvider( return MessageCounts(unreadCount, starredCount) } override fun getUnreadMessageCount(account: Account, folderId: Long): Int { return try { val localStore = localStoreProvider.getInstance(account) val localFolder = localStore.getFolder(folderId) localFolder.unreadMessageCount } catch (e: MessagingException) { Timber.e(e, "Unable to getUnreadMessageCount for account: %s, folder: %d", account, folderId) 0 } } private fun getMessageCountsWithLocalSearch(account: Account, search: LocalSearch): MessageCounts { return try { val localStore = localStoreProvider.getInstance(account) Loading
app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +1 −25 Original line number Diff line number Diff line Loading @@ -82,7 +82,6 @@ import com.fsck.k9.mailstore.SpecialLocalFoldersCreator; import com.fsck.k9.notification.NotificationController; import com.fsck.k9.notification.NotificationStrategy; import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.SearchAccount; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import timber.log.Timber; Loading Loading @@ -126,7 +125,6 @@ public class MessagingController { private final Set<MessagingListener> listeners = new CopyOnWriteArraySet<>(); private final ExecutorService threadPool = Executors.newCachedThreadPool(); private final MemorizingMessagingListener memorizingMessagingListener = new MemorizingMessagingListener(); private final MessageCountsProvider messageCountsProvider; private final DraftOperations draftOperations; private final NotificationOperations notificationOperations; Loading @@ -142,15 +140,13 @@ public class MessagingController { MessagingController(Context context, NotificationController notificationController, NotificationStrategy notificationStrategy, LocalStoreProvider localStoreProvider, MessageCountsProvider messageCountsProvider, BackendManager backendManager, Preferences preferences, MessageStoreManager messageStoreManager, BackendManager backendManager, Preferences preferences, MessageStoreManager messageStoreManager, SaveMessageDataCreator saveMessageDataCreator, SpecialLocalFoldersCreator specialLocalFoldersCreator, List<ControllerExtension> controllerExtensions) { this.context = context; this.notificationController = notificationController; this.notificationStrategy = notificationStrategy; this.localStoreProvider = localStoreProvider; this.messageCountsProvider = messageCountsProvider; this.backendManager = backendManager; this.preferences = preferences; this.messageStoreManager = messageStoreManager; Loading Loading @@ -1652,22 +1648,6 @@ public class MessagingController { } } public int getUnreadMessageCount(Account account) { MessageCounts messageCounts = messageCountsProvider.getMessageCounts(account); return messageCounts.getUnread(); } public int getUnreadMessageCount(SearchAccount searchAccount) { MessageCounts messageCounts = messageCountsProvider.getMessageCounts(searchAccount); return messageCounts.getUnread(); } public int getFolderUnreadMessageCount(Account account, Long folderId) throws MessagingException { LocalStore localStore = localStoreProvider.getInstance(account); LocalFolder localFolder = localStore.getFolder(folderId); return localFolder.getUnreadMessageCount(); } public boolean isMoveCapable(MessageReference messageReference) { return !messageReference.getUid().startsWith(K9.LOCAL_UID_PREFIX); } Loading Loading @@ -2370,10 +2350,6 @@ public class MessagingController { Timber.v("Clearing notification flag for %s", account); clearFetchingMailNotification(account); if (getUnreadMessageCount(account) == 0) { notificationController.clearNewMailNotifications(account, false); } } } ); Loading
app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java +1 −15 Original line number Diff line number Diff line Loading @@ -34,8 +34,6 @@ import com.fsck.k9.mailstore.SpecialLocalFoldersCreator; import com.fsck.k9.notification.NotificationController; import com.fsck.k9.notification.NotificationStrategy; import com.fsck.k9.preferences.Protocols; import com.fsck.k9.search.SearchAccount; import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.Before; import org.junit.Test; Loading Loading @@ -108,18 +106,6 @@ public class MessagingControllerTest extends K9RobolectricTest { private LocalMessage localMessageToSend1; private volatile boolean hasFetchedMessage = false; private MessageCountsProvider messageCountsProvider = new MessageCountsProvider() { @Override public MessageCounts getMessageCounts(@NotNull SearchAccount searchAccount) { return new MessageCounts(0, 0); } @Override public MessageCounts getMessageCounts(@NotNull Account account) { return new MessageCounts(0, 0); } }; private Preferences preferences; private String accountUuid; Loading @@ -133,7 +119,7 @@ public class MessagingControllerTest extends K9RobolectricTest { preferences = Preferences.getPreferences(); controller = new MessagingController(appContext, notificationController, notificationStrategy, localStoreProvider, messageCountsProvider, backendManager, preferences, messageStoreManager, localStoreProvider, backendManager, preferences, messageStoreManager, saveMessageDataCreator, specialLocalFoldersCreator, Collections.<ControllerExtension>emptyList()); configureAccount(); Loading
app/k9mail/src/main/java/com/fsck/k9/widget/unread/KoinModule.kt +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ val unreadWidgetModule = module { UnreadWidgetDataProvider( context = get(), preferences = get(), messagingController = get(), messageCountsProvider = get(), defaultFolderProvider = get(), folderRepository = get(), folderNameFormatterFactory = get() Loading