From e33f9848c7d4542ab96d3a6655f5b2f35c73b42c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 25 Apr 2019 09:21:09 +0200 Subject: [PATCH] Use account order to sort identities --- .../main/java/eu/faircode/email/DaoIdentity.java | 4 +++- .../java/eu/faircode/email/FragmentCompose.java | 16 ---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoIdentity.java b/app/src/main/java/eu/faircode/email/DaoIdentity.java index 0e0ad80aaa..295edb903d 100644 --- a/app/src/main/java/eu/faircode/email/DaoIdentity.java +++ b/app/src/main/java/eu/faircode/email/DaoIdentity.java @@ -39,7 +39,9 @@ public interface DaoIdentity { " JOIN folder ON folder.account = identity.account AND folder.type = '" + EntityFolder.DRAFTS + "'" + " WHERE (:account IS NULL OR identity.account = :account)" + " AND identity.synchronize" + - " AND account.synchronize") + " AND account.synchronize" + + " ORDER BY account.`order`, account.`primary` DESC, account.name COLLATE NOCASE" + + ", identity.`primary` DESC, identity.display COLLATE NOCASE, identity.name COLLATE NOCASE, identity.email COLLATE NOCASE") List getComposableIdentities(Long account); @Query("SELECT identity.*, account.name AS accountName FROM identity" + diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 22d366e596..ddc07a0656 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -119,8 +119,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Locale; @@ -1980,20 +1978,6 @@ public class FragmentCompose extends FragmentBase { if (identities == null) identities = new ArrayList<>(); - // Sort identities - Collections.sort(identities, new Comparator() { - @Override - public int compare(TupleIdentityEx i1, TupleIdentityEx i2) { - int a = i1.accountName.compareTo(i2.accountName); - if (a != 0) - return a; - int d = i1.getDisplayName().compareTo(i2.getDisplayName()); - if (d != 0) - return d; - return i1.email.compareTo(i2.email); - } - }); - return identities; }