diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java
index 141b496b1d..71eacfb946 100644
--- a/app/src/main/java/eu/faircode/email/DaoMessage.java
+++ b/app/src/main/java/eu/faircode/email/DaoMessage.java
@@ -79,6 +79,7 @@ public interface DaoMessage {
" ORDER BY CASE" +
" WHEN 'unread' = :sort THEN SUM(1 - message.ui_seen) = 0" +
" WHEN 'starred' = :sort THEN COUNT(message.id) - SUM(1 - message.ui_flagged) = 0" +
+ " WHEN 'priority' = :sort THEN -MAX(IFNULL(message.priority, 1))" +
" WHEN 'sender' = :sort THEN LOWER(message.sender)" +
" WHEN 'subject' = :sort THEN LOWER(message.subject)" +
" WHEN 'size' = :sort THEN -SUM(message.total)" +
@@ -127,6 +128,7 @@ public interface DaoMessage {
" ORDER BY CASE" +
" WHEN 'unread' = :sort THEN SUM(1 - message.ui_seen) = 0" +
" WHEN 'starred' = :sort THEN COUNT(message.id) - SUM(1 - message.ui_flagged) = 0" +
+ " WHEN 'priority' = :sort THEN -MAX(IFNULL(message.priority, 1))" +
" WHEN 'sender' = :sort THEN LOWER(message.sender)" +
" WHEN 'subject' = :sort THEN LOWER(message.subject)" +
" WHEN 'size' = :sort THEN -SUM(message.total)" +
diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index 0689a8d2e2..3625e0366f 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -3025,6 +3025,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (viewType == AdapterMessage.ViewType.THREAD) {
menu.findItem(R.id.menu_sort_on_time).setVisible(false);
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_sender).setVisible(false);
menu.findItem(R.id.menu_sort_on_subject).setVisible(false);
@@ -3039,6 +3040,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
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 ("priority".equals(sort))
+ menu.findItem(R.id.menu_sort_on_priority).setChecked(true);
else if ("sender".equals(sort))
menu.findItem(R.id.menu_sort_on_sender).setChecked(true);
else if ("subject".equals(sort))
@@ -3109,6 +3112,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
onMenuSort("starred");
return true;
+ case R.id.menu_sort_on_priority:
+ item.setChecked(true);
+ onMenuSort("priority");
+ return true;
+
case R.id.menu_sort_on_sender:
item.setChecked(true);
onMenuSort("sender");
diff --git a/app/src/main/res/menu/menu_messages.xml b/app/src/main/res/menu/menu_messages.xml
index 9f737fffef..0be74676c4 100644
--- a/app/src/main/res/menu/menu_messages.xml
+++ b/app/src/main/res/menu/menu_messages.xml
@@ -31,6 +31,9 @@
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e9660c9014..e069533bd7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -816,6 +816,7 @@
Time
Unread
Starred
+ Priority
Sender
Subject
Size