Sort folders on display name

pull/147/head
M66B 6 years ago
parent 94eb9af995
commit aa3e4774e0

@ -395,7 +395,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
List<EntityFolder> folders = new ArrayList<>(); List<EntityFolder> folders = new ArrayList<>();
folders.addAll(_folders); folders.addAll(_folders);
EntityFolder.sort(folders); EntityFolder.sort(context, folders);
all.clear(); all.clear();
for (EntityFolder folder : folders) for (EntityFolder folder : folders)

@ -1503,7 +1503,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
!EntityFolder.JUNK.equals(folder.type)) !EntityFolder.JUNK.equals(folder.type))
targets.add(folder); targets.add(folder);
EntityFolder.sort(targets); EntityFolder.sort(context, targets);
return targets; return targets;
} }

@ -259,7 +259,7 @@ public class EntityFolder implements Serializable {
return folder; return folder;
} }
static void sort(List<EntityFolder> folders) { static void sort(final Context context, List<EntityFolder> folders) {
final Collator collator = Collator.getInstance(Locale.getDefault()); final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
@ -274,9 +274,9 @@ public class EntityFolder implements Serializable {
int c = -f1.synchronize.compareTo(f2.synchronize); int c = -f1.synchronize.compareTo(f2.synchronize);
if (c != 0) if (c != 0)
return c; return c;
return collator.compare( String name1 = f1.getDisplayName(context);
f1.name == null ? "" : f1.name, String name2 = f2.getDisplayName(context);
f2.name == null ? "" : f2.name); return collator.compare(name1, name2);
} }
}); });
} }

@ -1154,7 +1154,7 @@ public class FragmentAccount extends FragmentEx {
} }
private void setFolders(List<EntityFolder> folders) { private void setFolders(List<EntityFolder> folders) {
EntityFolder.sort(folders); EntityFolder.sort(getContext(), folders);
EntityFolder none = new EntityFolder(); EntityFolder none = new EntityFolder();
none.name = ""; none.name = "";

@ -836,7 +836,7 @@ public class FragmentIdentity extends FragmentEx {
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(result.folders); EntityFolder.sort(context, result.folders);
return result; return result;
} }

@ -1079,7 +1079,7 @@ public class FragmentMessages extends FragmentEx {
(fid < 0 ? !folder.unified : !folder.id.equals(fid))) (fid < 0 ? !folder.unified : !folder.id.equals(fid)))
targets.add(folder); targets.add(folder);
EntityFolder.sort(targets); EntityFolder.sort(context, targets);
return targets; return targets;
} }

Loading…
Cancel
Save