From 38e6f7ed6ea2aa9e7d9310f4da209be405baacd2 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 18 Dec 2019 08:28:45 +0100 Subject: [PATCH] Revert "Fixed counts in single message mode" This reverts commit 1fd5d8f6b882c6c4b47c033c7bfabd123a22f1d2. --- app/src/main/java/eu/faircode/email/DaoMessage.java | 10 ++++------ .../email/WidgetUnifiedRemoteViewsFactory.java | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 55042f9b58..831fc9341d 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -65,10 +65,9 @@ public interface DaoMessage { " LEFT JOIN identity ON identity.id = message.identity" + " JOIN folder ON folder.id = message.folder" + " WHERE account.`synchronize`" + - " AND (:threading OR folder.unified)" + " AND (NOT message.ui_hide OR :debug)" + " AND (NOT :found OR ui_found = :found)" + - " GROUP BY account.id, CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" + + " GROUP BY account.id, CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " HAVING (:found OR" + " CASE WHEN :type IS NULL THEN SUM(folder.unified) > 0" + " ELSE SUM(CASE WHEN folder.type = :type THEN 1 ELSE 0 END) > 0 END)" + @@ -114,10 +113,9 @@ public interface DaoMessage { " JOIN folder ON folder.id = message.folder" + " JOIN folder AS f ON f.id = :folder" + " WHERE (message.account = f.account OR " + is_outbox + ")" + - " AND (:threading OR folder.id = :folder)" + " AND (NOT message.ui_hide OR :debug)" + " AND (NOT :found OR ui_found = :found)" + - " GROUP BY CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" + + " GROUP BY CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " HAVING SUM(CASE WHEN folder.id = :folder THEN 1 ELSE 0 END) > 0" + " AND (NOT :filter_seen OR SUM(1 - message.ui_seen) > 0 OR " + is_outbox + ")" + " AND (NOT :filter_unflagged OR COUNT(message.id) - SUM(1 - message.ui_flagged) > 0 OR " + is_outbox + ")" + @@ -364,10 +362,10 @@ public interface DaoMessage { " AND (NOT :unseen OR NOT message.ui_seen)" + " AND (NOT :flagged OR message.ui_flagged)" + " GROUP BY account.id" + - ", CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" + + ", CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " ORDER BY message.received DESC") @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) - List getWidgetUnified(Long folder, boolean unseen, boolean flagged); + List getWidgetUnified(Long folder, boolean threading, boolean unseen, boolean flagged); @Query("SELECT uid FROM message" + " WHERE folder = :folder" + diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index d1993692ec..708fe585b7 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -70,6 +70,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot Log.i("Widget factory changed id=" + appWidgetId); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + threading = prefs.getBoolean("threading", true); subject_top = prefs.getBoolean("subject_top", false); subject_italic = prefs.getBoolean("subject_italic", true); account = prefs.getLong("widget." + appWidgetId + ".account", -1L); @@ -83,7 +84,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot try { db.beginTransaction(); - messages = db.message().getWidgetUnified(folder < 0 ? null : folder, unseen, flagged); + messages = db.message().getWidgetUnified(folder < 0 ? null : folder, threading, unseen, flagged); db.setTransactionSuccessful(); } finally {