Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 106c132d authored by cketti's avatar cketti
Browse files

Code cleanup

parent 4729ae04
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
package com.fsck.k9.controller

import android.content.Context
import com.fsck.k9.DefaultMessageCountsProvider
import com.fsck.k9.MessageCountsProvider
import com.fsck.k9.Preferences
import com.fsck.k9.backend.BackendManager
import com.fsck.k9.mailstore.LocalStoreProvider
+6 −4
Original line number Diff line number Diff line
package com.fsck.k9
package com.fsck.k9.controller

import android.content.Context
import com.fsck.k9.Account
import com.fsck.k9.Preferences
import com.fsck.k9.mail.MessagingException
import com.fsck.k9.mailstore.LocalStoreProvider
import com.fsck.k9.search.AccountSearchConditions
@@ -37,7 +39,7 @@ internal class DefaultMessageCountsProvider(
            localStore.getMessageCounts(search)
        } catch (e: MessagingException) {
            Timber.e(e, "Unable to getMessageCounts for account: %s", account)
            return MessageCounts(0, 0)
            MessageCounts(0, 0)
        }
    }

@@ -48,7 +50,7 @@ internal class DefaultMessageCountsProvider(
        var unreadCount = 0
        var starredCount = 0
        for (account in accounts) {
            var accountMessageCount = getMessageCountsWithLocalSearch(account, search)
            val accountMessageCount = getMessageCountsWithLocalSearch(account, search)
            unreadCount += accountMessageCount.unread
            starredCount += accountMessageCount.starred
        }
@@ -62,7 +64,7 @@ internal class DefaultMessageCountsProvider(
            localStore.getMessageCounts(search)
        } catch (e: MessagingException) {
            Timber.e(e, "Unable to getMessageCounts for account: %s", account)
            return MessageCounts(0, 0)
            MessageCounts(0, 0)
        }
    }
}
+0 −10
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ import com.fsck.k9.Account.DeletePolicy;
import com.fsck.k9.Account.Expunge;
import com.fsck.k9.DI;
import com.fsck.k9.K9;
import com.fsck.k9.MessageCounts;
import com.fsck.k9.MessageCountsProvider;
import com.fsck.k9.Preferences;
import com.fsck.k9.backend.BackendManager;
import com.fsck.k9.backend.api.Backend;
@@ -1687,14 +1685,6 @@ public class MessagingController {
        return unreadMessageCountProvider.getUnreadMessageCount(searchAccount);
    }

    public MessageCounts getMessageCounts(Account account) {
        return messageCountsProvider.getMessageCounts(account);
    }

    public MessageCounts getMessageCounts(SearchAccount searchAccount) {
        return messageCountsProvider.getMessageCounts(searchAccount);
    }

    public int getFolderUnreadMessageCount(Account account, Long folderId) throws MessagingException {
        LocalStore localStore = localStoreProvider.getInstance(account);
        LocalFolder localFolder = localStore.getFolder(folderId);
+5 −5
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.MessageCounts;
import com.fsck.k9.controller.MessageCounts;
import com.fsck.k9.controller.MessageReference;
import com.fsck.k9.helper.FileHelper;
import com.fsck.k9.helper.Utility;
@@ -330,20 +330,20 @@ public class LocalFolder {
            return this.localStore.getDatabase().execute(false, new DbCallback<Integer>() {
                @Override
                public Integer doDbWork(final SQLiteDatabase db) throws WrappedException {
                    int unreadMessageCount = 0;
                    int starredMessageCount = 0;
                    Cursor cursor = db.query("messages", new String[] { "COUNT(id)" },
                            "folder_id = ? AND empty = 0 AND deleted = 0 AND flagged = 1",
                            new String[] { Long.toString(databaseId) }, null, null, null);

                    try {
                        if (cursor.moveToFirst()) {
                            unreadMessageCount = cursor.getInt(0);
                            starredMessageCount = cursor.getInt(0);
                        }
                    } finally {
                        cursor.close();
                    }

                    return unreadMessageCount;
                    return starredMessageCount;
                }
            });
        } catch (WrappedException e) {
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import com.fsck.k9.Account;
import com.fsck.k9.Clock;
import com.fsck.k9.DI;
import com.fsck.k9.K9;
import com.fsck.k9.MessageCounts;
import com.fsck.k9.controller.MessageCounts;
import com.fsck.k9.Preferences;
import com.fsck.k9.controller.MessagingControllerCommands.PendingCommand;
import com.fsck.k9.controller.PendingCommandSerializer;
Loading