Fixed counts in single message mode

This commit is contained in:
M66B 2019-12-17 08:43:44 +01:00
parent 35253e9733
commit 1fd5d8f6b8
2 changed files with 7 additions and 6 deletions

View File

@ -65,9 +65,10 @@ public interface DaoMessage {
" LEFT JOIN identity ON identity.id = message.identity" + " LEFT JOIN identity ON identity.id = message.identity" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" WHERE account.`synchronize`" + " WHERE account.`synchronize`" +
" AND (:threading OR folder.unified)" +
" AND (NOT message.ui_hide OR :debug)" + " AND (NOT message.ui_hide OR :debug)" +
" AND (NOT :found OR ui_found = :found)" + " AND (NOT :found OR ui_found = :found)" +
" GROUP BY account.id, CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " GROUP BY account.id, CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" +
" HAVING (:found OR" + " HAVING (:found OR" +
" CASE WHEN :type IS NULL THEN SUM(folder.unified) > 0" + " CASE WHEN :type IS NULL THEN SUM(folder.unified) > 0" +
" ELSE SUM(CASE WHEN folder.type = :type THEN 1 ELSE 0 END) > 0 END)" + " ELSE SUM(CASE WHEN folder.type = :type THEN 1 ELSE 0 END) > 0 END)" +
@ -113,9 +114,10 @@ public interface DaoMessage {
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" JOIN folder AS f ON f.id = :folder" + " JOIN folder AS f ON f.id = :folder" +
" WHERE (message.account = f.account OR " + is_outbox + ")" + " WHERE (message.account = f.account OR " + is_outbox + ")" +
" AND (:threading OR folder.id = :folder)" +
" AND (NOT message.ui_hide OR :debug)" + " AND (NOT message.ui_hide OR :debug)" +
" AND (NOT :found OR ui_found = :found)" + " AND (NOT :found OR ui_found = :found)" +
" GROUP BY CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " GROUP BY CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" +
" HAVING SUM(CASE WHEN folder.id = :folder THEN 1 ELSE 0 END) > 0" + " 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_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 + ")" + " AND (NOT :filter_unflagged OR COUNT(message.id) - SUM(1 - message.ui_flagged) > 0 OR " + is_outbox + ")" +
@ -362,10 +364,10 @@ public interface DaoMessage {
" AND (NOT :unseen OR NOT message.ui_seen)" + " AND (NOT :unseen OR NOT message.ui_seen)" +
" AND (NOT :flagged OR message.ui_flagged)" + " AND (NOT :flagged OR message.ui_flagged)" +
" GROUP BY account.id" + " GROUP BY account.id" +
", CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + ", CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" +
" ORDER BY message.received DESC") " ORDER BY message.received DESC")
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
List<TupleMessageWidget> getWidgetUnified(Long folder, boolean threading, boolean unseen, boolean flagged); List<TupleMessageWidget> getWidgetUnified(Long folder, boolean unseen, boolean flagged);
@Query("SELECT uid FROM message" + @Query("SELECT uid FROM message" +
" WHERE folder = :folder" + " WHERE folder = :folder" +

View File

@ -70,7 +70,6 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
Log.i("Widget factory changed id=" + appWidgetId); Log.i("Widget factory changed id=" + appWidgetId);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
threading = prefs.getBoolean("threading", true);
subject_top = prefs.getBoolean("subject_top", false); subject_top = prefs.getBoolean("subject_top", false);
subject_italic = prefs.getBoolean("subject_italic", true); subject_italic = prefs.getBoolean("subject_italic", true);
account = prefs.getLong("widget." + appWidgetId + ".account", -1L); account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
@ -84,7 +83,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
try { try {
db.beginTransaction(); db.beginTransaction();
messages = db.message().getWidgetUnified(folder < 0 ? null : folder, threading, unseen, flagged); messages = db.message().getWidgetUnified(folder < 0 ? null : folder, unseen, flagged);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {