From d671b997049ca1a7b7fef1bebcd0c6ba7895203f Mon Sep 17 00:00:00 2001 From: Carlos Melero Date: Thu, 30 Nov 2017 07:10:08 +0100 Subject: [PATCH] Label sort should be alphabetical and locale-sensitive (#74) Doing ascii sort on natural language text will result in unexpected sorting. ie: Lowercase words being sorted after uppercase block or accents messing ordering. --- .../flocke/andotp/View/EntriesCardAdapter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java index 52b27a96..30f17e8d 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java @@ -51,6 +51,7 @@ import org.shadowice.flocke.andotp.R; import static org.shadowice.flocke.andotp.Utilities.Settings.SortMode; +import java.text.Collator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -438,9 +439,16 @@ public class EntriesCardAdapter extends RecyclerView.Adapter } public class LabelComparator implements Comparator { + Collator collator; + + LabelComparator(){ + collator = Collator.getInstance(); + collator.setStrength(Collator.PRIMARY); + } + @Override public int compare(Entry o1, Entry o2) { - return o1.getLabel().compareTo(o2.getLabel()); + return collator.compare(o1.getLabel(), o2.getLabel()); } }