From 84f63ab4734f071992833768d9dfcee86cbe1805 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 18 Jan 2019 11:15:07 +0000 Subject: [PATCH] Localize folder names --- .../java/eu/faircode/email/EntityFolder.java | 2 +- .../eu/faircode/email/FragmentAccount.java | 18 +++++++++++++++--- .../eu/faircode/email/FragmentIdentity.java | 6 +++++- .../java/eu/faircode/email/FragmentRule.java | 12 +++++++++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityFolder.java b/app/src/main/java/eu/faircode/email/EntityFolder.java index f4c670a6c0..764b2fa20e 100644 --- a/app/src/main/java/eu/faircode/email/EntityFolder.java +++ b/app/src/main/java/eu/faircode/email/EntityFolder.java @@ -215,7 +215,7 @@ public class EntityFolder implements Serializable { @Override public String toString() { - return name; + return (display == null ? name : display); } public JSONObject toJSON() throws JSONException { diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index d51160c3c1..f839d86e12 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -637,6 +637,10 @@ public class FragmentAccount extends FragmentBase { if (!junk && altJunk != null) altJunk.type = EntityFolder.JUNK; + for (EntityFolder folder : result.folders) + folder.display = folder.getDisplayName(getContext()); + EntityFolder.sort(getContext(), result.folders); + } finally { if (istore != null) istore.close(); @@ -1109,7 +1113,17 @@ public class FragmentAccount extends FragmentBase { @Override protected List onExecute(Context context, Bundle args) { long account = args.getLong("account"); - return DB.getInstance(context).folder().getFolders(account); + + DB db = DB.getInstance(context); + List folders = db.folder().getFolders(account); + + if (folders != null) { + for (EntityFolder folder : folders) + folder.display = folder.getDisplayName(getContext()); + EntityFolder.sort(getContext(), folders); + } + + return folders; } @Override @@ -1302,8 +1316,6 @@ public class FragmentAccount extends FragmentBase { } private void setFolders(List folders) { - EntityFolder.sort(getContext(), folders); - EntityFolder none = new EntityFolder(); none.name = "-"; folders.add(0, none); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 800373a562..5a92200816 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -957,7 +957,11 @@ public class FragmentIdentity extends FragmentBase { result.identity = db.identity().getIdentity(iid); result.folders = db.folder().getFolders(aid); - EntityFolder.sort(context, result.folders); + if (result.folders != null) { + for (EntityFolder folder : result.folders) + folder.display = folder.getDisplayName(context); + EntityFolder.sort(context, result.folders); + } return result; } diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index 103f10365e..f79944a096 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -178,7 +178,17 @@ public class FragmentRule extends FragmentBase { @Override protected List onExecute(Context context, Bundle args) { long account = args.getLong("account"); - return DB.getInstance(context).folder().getFolders(account); + + DB db = DB.getInstance(context); + List folders = db.folder().getFolders(account); + + if (folders != null) { + for (EntityFolder folder : folders) + folder.display = folder.getDisplayName(context); + EntityFolder.sort(context, folders); + } + + return folders; } @Override