diff --git a/app/core/src/main/java/com/fsck/k9/AccountStats.java b/app/core/src/main/java/com/fsck/k9/AccountStats.java deleted file mode 100644 index 146a8c94b..000000000 --- a/app/core/src/main/java/com/fsck/k9/AccountStats.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * - */ -package com.fsck.k9; - -import java.io.Serializable; - -public class AccountStats implements Serializable { - private static final long serialVersionUID = -5706839923710842234L; - public long size = -1; - public int unreadMessageCount = 0; - public int flaggedMessageCount = 0; - public boolean available = true; -} diff --git a/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt b/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt index 54d97ecfc..7450ad6a9 100644 --- a/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt +++ b/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt @@ -33,8 +33,7 @@ internal class DefaultUnreadMessageCountProvider( accountSearchConditions.excludeSpecialFolders(account, search) accountSearchConditions.limitToDisplayableFolders(account, search) - val accountStats = localStore.getAccountStats(search) - accountStats.unreadMessageCount + localStore.getUnreadMessageCount(search) } catch (e: MessagingException) { Timber.e(e, "Unable to getUnreadMessageCount for account: %s", account) 0 @@ -56,8 +55,7 @@ internal class DefaultUnreadMessageCountProvider( private fun getUnreadMessageCountWithLocalSearch(account: Account, search: LocalSearch): Int { return try { val localStore = localStoreProvider.getInstance(account) - val accountStats = localStore.getAccountStats(search) - accountStats.unreadMessageCount + localStore.getUnreadMessageCount(search) } catch (e: MessagingException) { Timber.e(e, "Unable to getUnreadMessageCount for account: %s", account) 0 diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/LocalStore.java b/app/core/src/main/java/com/fsck/k9/mailstore/LocalStore.java index dacd307b2..429b93d92 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/LocalStore.java +++ b/app/core/src/main/java/com/fsck/k9/mailstore/LocalStore.java @@ -28,7 +28,6 @@ import androidx.annotation.Nullable; import android.text.TextUtils; import com.fsck.k9.Account; -import com.fsck.k9.AccountStats; import com.fsck.k9.Clock; import com.fsck.k9.DI; import com.fsck.k9.K9; @@ -1293,7 +1292,7 @@ public class LocalStore { return folderMap; } - public AccountStats getAccountStats(LocalSearch search) throws MessagingException { + public int getUnreadMessageCount(LocalSearch search) throws MessagingException { StringBuilder whereBuilder = new StringBuilder(); List queryArgs = new ArrayList<>(); SqlQueryBuilder.buildWhereClause(account, search.getConditions(), whereBuilder, queryArgs); @@ -1301,24 +1300,22 @@ public class LocalStore { String where = whereBuilder.toString(); final String[] selectionArgs = queryArgs.toArray(new String[queryArgs.size()]); - final String sqlQuery = "SELECT SUM(read=0), SUM(flagged) " + + final String sqlQuery = "SELECT SUM(read=0) " + "FROM messages " + "JOIN folders ON (folders.id = messages.folder_id) " + "WHERE (messages.empty = 0 AND messages.deleted = 0)" + (!TextUtils.isEmpty(where) ? " AND (" + where + ")" : ""); - return database.execute(false, new DbCallback() { + return database.execute(false, new DbCallback() { @Override - public AccountStats doDbWork(SQLiteDatabase db) throws WrappedException, MessagingException { + public Integer doDbWork(SQLiteDatabase db) throws WrappedException, MessagingException { Cursor cursor = db.rawQuery(sqlQuery, selectionArgs); try { - AccountStats accountStats = new AccountStats(); if (cursor.moveToFirst()) { - accountStats.unreadMessageCount = cursor.getInt(0); - accountStats.flaggedMessageCount = cursor.getInt(1); + return cursor.getInt(0); + } else { + return 0; } - - return accountStats; } finally { cursor.close(); } diff --git a/app/k9mail/src/main/java/com/fsck/k9/external/MessageProvider.java b/app/k9mail/src/main/java/com/fsck/k9/external/MessageProvider.java index 967def150..58d2e80de 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/external/MessageProvider.java +++ b/app/k9mail/src/main/java/com/fsck/k9/external/MessageProvider.java @@ -36,7 +36,6 @@ import android.os.Bundle; import android.provider.BaseColumns; import com.fsck.k9.Account; -import com.fsck.k9.AccountStats; import com.fsck.k9.BuildConfig; import com.fsck.k9.DI; import com.fsck.k9.Preferences; @@ -45,7 +44,6 @@ import com.fsck.k9.controller.MessagingController; import com.fsck.k9.controller.SimpleMessagingListener; import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Message; -import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mailstore.LocalMessage; import com.fsck.k9.search.SearchAccount; import timber.log.Timber;