Localize folder names

This commit is contained in:
M66B 2019-01-18 11:15:07 +00:00
parent b1ebc3ffd2
commit 84f63ab473
4 changed files with 32 additions and 6 deletions

View File

@ -215,7 +215,7 @@ public class EntityFolder implements Serializable {
@Override @Override
public String toString() { public String toString() {
return name; return (display == null ? name : display);
} }
public JSONObject toJSON() throws JSONException { public JSONObject toJSON() throws JSONException {

View File

@ -637,6 +637,10 @@ public class FragmentAccount extends FragmentBase {
if (!junk && altJunk != null) if (!junk && altJunk != null)
altJunk.type = EntityFolder.JUNK; altJunk.type = EntityFolder.JUNK;
for (EntityFolder folder : result.folders)
folder.display = folder.getDisplayName(getContext());
EntityFolder.sort(getContext(), result.folders);
} finally { } finally {
if (istore != null) if (istore != null)
istore.close(); istore.close();
@ -1109,7 +1113,17 @@ public class FragmentAccount extends FragmentBase {
@Override @Override
protected List<EntityFolder> onExecute(Context context, Bundle args) { protected List<EntityFolder> onExecute(Context context, Bundle args) {
long account = args.getLong("account"); long account = args.getLong("account");
return DB.getInstance(context).folder().getFolders(account);
DB db = DB.getInstance(context);
List<EntityFolder> folders = db.folder().getFolders(account);
if (folders != null) {
for (EntityFolder folder : folders)
folder.display = folder.getDisplayName(getContext());
EntityFolder.sort(getContext(), folders);
}
return folders;
} }
@Override @Override
@ -1302,8 +1316,6 @@ public class FragmentAccount extends FragmentBase {
} }
private void setFolders(List<EntityFolder> folders) { private void setFolders(List<EntityFolder> folders) {
EntityFolder.sort(getContext(), folders);
EntityFolder none = new EntityFolder(); EntityFolder none = new EntityFolder();
none.name = "-"; none.name = "-";
folders.add(0, none); folders.add(0, none);

View File

@ -957,7 +957,11 @@ public class FragmentIdentity extends FragmentBase {
result.identity = db.identity().getIdentity(iid); result.identity = db.identity().getIdentity(iid);
result.folders = db.folder().getFolders(aid); 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; return result;
} }

View File

@ -178,7 +178,17 @@ public class FragmentRule extends FragmentBase {
@Override @Override
protected List<EntityFolder> onExecute(Context context, Bundle args) { protected List<EntityFolder> onExecute(Context context, Bundle args) {
long account = args.getLong("account"); long account = args.getLong("account");
return DB.getInstance(context).folder().getFolders(account);
DB db = DB.getInstance(context);
List<EntityFolder> folders = db.folder().getFolders(account);
if (folders != null) {
for (EntityFolder folder : folders)
folder.display = folder.getDisplayName(context);
EntityFolder.sort(context, folders);
}
return folders;
} }
@Override @Override