From 7ecfd7a788cfe97a935a9da34e29027c08a4ec00 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 28 Jun 2019 09:46:18 +0200 Subject: [PATCH] Fixed folder sort order --- app/src/main/java/eu/faircode/email/EntityFolder.java | 3 +++ app/src/main/java/eu/faircode/email/FragmentAccount.java | 4 ++-- app/src/main/java/eu/faircode/email/FragmentMessages.java | 5 +++-- app/src/main/java/eu/faircode/email/FragmentRule.java | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityFolder.java b/app/src/main/java/eu/faircode/email/EntityFolder.java index f54cafd6c6..ec85c894f1 100644 --- a/app/src/main/java/eu/faircode/email/EntityFolder.java +++ b/app/src/main/java/eu/faircode/email/EntityFolder.java @@ -413,6 +413,9 @@ public class EntityFolder extends EntityOrder implements Serializable { if (c != 0) return c; + if (context == null) + return collator.compare(f1.name, f2.name); + String name1 = f1.getDisplayName(context); String name2 = f2.getDisplayName(context); return collator.compare(name1, name2); diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 271e778a76..628ee28287 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -617,7 +617,7 @@ public class FragmentAccount extends FragmentBase { altJunk.type = EntityFolder.JUNK; if (result.folders.size() > 0) - Collections.sort(result.folders, result.folders.get(0).getComparator(context)); + Collections.sort(result.folders, result.folders.get(0).getComparator(null)); } return result; @@ -1221,7 +1221,7 @@ public class FragmentAccount extends FragmentBase { List folders = db.folder().getFolders(account); if (folders != null && folders.size() > 0) - Collections.sort(folders, folders.get(0).getComparator(context)); + Collections.sort(folders, folders.get(0).getComparator(null)); return folders; } diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 43445a6472..81d47b4e98 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -621,7 +621,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. for (EntityAccount account : accounts) { List folders = db.folder().getFolders(account.id); if (folders.size() > 0) - Collections.sort(folders, folders.get(0).getComparator(context)); + Collections.sort(folders, folders.get(0).getComparator(null)); result.put(account, folders); } @@ -640,7 +640,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. .addSubMenu(Menu.NONE, 0, order++, account.name); int sorder = 1; for (EntityFolder folder : result.get(account)) { - MenuItem item = smenu.add(Menu.NONE, 1, sorder++, folder.getDisplayName(getContext())); + MenuItem item = smenu.add(Menu.NONE, 1, sorder++, + Helper.localizeFolderName(getContext(), folder.name)); item.setIntent(new Intent().putExtra("target", folder.id)); } } diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index cf76072033..d763fd7cb5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -380,7 +380,7 @@ public class FragmentRule extends FragmentBase { data.folders = new ArrayList<>(); if (data.folders.size() > 0) - Collections.sort(data.folders, data.folders.get(0).getComparator(context)); + Collections.sort(data.folders, data.folders.get(0).getComparator(null)); data.identities = db.identity().getIdentities(aid); data.answers = db.answer().getAnswers(false);