diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java
index be8083a783..4b9a545f6b 100644
--- a/app/src/main/java/eu/faircode/email/DaoMessage.java
+++ b/app/src/main/java/eu/faircode/email/DaoMessage.java
@@ -116,6 +116,7 @@ public interface DaoMessage {
" END" +
", CASE" +
" WHEN 'unread' = :sort2 THEN SUM(1 - message.ui_seen) = 0" +
+ " WHEN 'starred' = :sort2 THEN COUNT(message.id) - SUM(1 - message.ui_flagged) = 0" +
" ELSE 0" +
" END" +
", CASE WHEN :ascending THEN message.received ELSE -message.received END")
@@ -194,6 +195,7 @@ public interface DaoMessage {
" END" +
", CASE" +
" WHEN 'unread' = :sort2 THEN SUM(1 - message.ui_seen) = 0" +
+ " WHEN 'starred' = :sort2 THEN COUNT(message.id) - SUM(1 - message.ui_flagged) = 0" +
" ELSE 0" +
" END" +
", CASE WHEN :ascending THEN message.received ELSE -message.received END")
diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index 85eae6c09b..c70c138ed3 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -5943,6 +5943,7 @@ public class FragmentMessages extends FragmentBase
menu.findItem(R.id.menu_sort_on_unread).setVisible(false);
menu.findItem(R.id.menu_sort_on_priority).setVisible(false);
menu.findItem(R.id.menu_sort_on_starred).setVisible(false);
+ menu.findItem(R.id.menu_sort_on_unread_starred).setVisible(false);
menu.findItem(R.id.menu_sort_on_starred_unread).setVisible(false);
menu.findItem(R.id.menu_sort_on_sender).setVisible(false);
menu.findItem(R.id.menu_sort_on_subject).setVisible(false);
@@ -5961,6 +5962,8 @@ public class FragmentMessages extends FragmentBase
menu.findItem(R.id.menu_sort_on_unread).setChecked(true);
else if ("starred".equals(sort))
menu.findItem(R.id.menu_sort_on_starred).setChecked(true);
+ else if ("unread+starred".equals(sort))
+ menu.findItem(R.id.menu_sort_on_unread_starred).setChecked(true);
else if ("starred+unread".equals(sort))
menu.findItem(R.id.menu_sort_on_starred_unread).setChecked(true);
else if ("priority".equals(sort))
@@ -6107,6 +6110,10 @@ public class FragmentMessages extends FragmentBase
item.setChecked(true);
onMenuSort("starred");
return true;
+ } else if (itemId == R.id.menu_sort_on_unread_starred) {
+ item.setChecked(true);
+ onMenuSort("unread+starred");
+ return true;
} else if (itemId == R.id.menu_sort_on_starred_unread) {
item.setChecked(true);
onMenuSort("starred+unread");
diff --git a/app/src/main/res/menu/menu_messages.xml b/app/src/main/res/menu/menu_messages.xml
index 7e22bbd306..14ef24d7a5 100644
--- a/app/src/main/res/menu/menu_messages.xml
+++ b/app/src/main/res/menu/menu_messages.xml
@@ -58,6 +58,9 @@
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e65bda1f24..bea0cf69d9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1911,6 +1911,7 @@
Time
Unread
Starred
+ Unread, starred
Starred, unread
Priority
Sender