diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 7c52e4cc9d..309f99336f 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -68,12 +68,13 @@ public interface DaoMessage { " GROUP BY account.id, CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " HAVING :found OR SUM(unified) > 0" + " ORDER BY" + - " CASE WHEN 'sender' = :sort THEN message.sender ELSE '' END," + " CASE" + - " WHEN 'unread' = :sort THEN " + unseen_unified + " > 0" + - " WHEN 'starred' = :sort THEN COUNT(message.id) - " + unflagged_unified + " > 0" + + " WHEN 'unread' = :sort THEN " + unseen_unified + " = 0" + + " WHEN 'starred' = :sort THEN COUNT(message.id) - " + unflagged_unified + " = 0" + + " WHEN 'sender' = :sort THEN LOWER(message.sender)" + + " WHEN 'subject' = :sort THEN LOWER(message.subject)" + " ELSE 0" + - " END DESC, message.received DESC") + " END, message.received DESC") @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) DataSource.Factory pagedUnifiedInbox(boolean threading, String sort, boolean snoozed, boolean found, boolean debug); @@ -109,12 +110,13 @@ public interface DaoMessage { " 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" + " ORDER BY" + - " CASE WHEN 'sender' = :sort THEN message.sender ELSE '' END," + " CASE" + - " WHEN 'unread' = :sort THEN " + unseen_folder + " > 0" + - " WHEN 'starred' = :sort THEN COUNT(message.id) - " + unflagged_folder + " > 0" + + " WHEN 'unread' = :sort THEN " + unseen_folder + " = 0" + + " WHEN 'starred' = :sort THEN COUNT(message.id) - " + unflagged_folder + " = 0" + + " WHEN 'sender' = :sort THEN LOWER(message.sender)" + + " WHEN 'subject' = :sort THEN LOWER(message.subject)" + " ELSE 0" + - " END DESC, message.received DESC") + " END, message.received DESC") @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) DataSource.Factory pagedFolder(long folder, boolean threading, String sort, boolean snoozed, boolean found, boolean debug); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 6d779e5faf..4822748e1a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -1746,6 +1746,8 @@ public class FragmentMessages extends FragmentBase { menu.findItem(R.id.menu_sort_on_starred).setChecked(true); else if ("sender".equals(sort)) menu.findItem(R.id.menu_sort_on_sender).setChecked(true); + else if ("subject".equals(sort)) + menu.findItem(R.id.menu_sort_on_subject).setChecked(true); menu.findItem(R.id.menu_zoom).setVisible(!selection); @@ -1787,6 +1789,11 @@ public class FragmentMessages extends FragmentBase { onMenuSort("sender"); return true; + case R.id.menu_sort_on_subject: + item.setChecked(true); + onMenuSort("subject"); + return true; + case R.id.menu_zoom: onMenuZoom(); return true; diff --git a/app/src/main/res/menu/menu_messages.xml b/app/src/main/res/menu/menu_messages.xml index 37c2560c16..7dd928a616 100644 --- a/app/src/main/res/menu/menu_messages.xml +++ b/app/src/main/res/menu/menu_messages.xml @@ -34,6 +34,9 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a9a23d807b..1e00af485a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -417,6 +417,7 @@ Unread Starred Sender + Subject Compact view Text size