diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java index 4296c0d..b38950b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java @@ -23,6 +23,7 @@ import android.provider.BaseColumns; import android.provider.ContactsContract; import android.text.TextUtils; +import android.util.Log; import android.util.SparseArray; import org.telegram.PhoneFormat.PhoneFormat; @@ -31,6 +32,7 @@ import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; +import java.text.Collator; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -62,6 +64,8 @@ private ArrayList groupPrivacyRules = null; private ArrayList callPrivacyRules = null; + private Collator collator= Collator.getInstance(java.util.Locale.CHINA); + public static class Contact { public int id; public ArrayList phones = new ArrayList<>(); @@ -1020,6 +1024,8 @@ if (from != 1) { MessagesStorage.getInstance().putUsersAndChats(usersArr, null, true, true); MessagesStorage.getInstance().putContacts(contactsArr, from != 2); + +// Collections.sort(contactsArr, collator); Collections.sort(contactsArr, new Comparator() { @Override public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) { @@ -1042,6 +1048,7 @@ UserConfig.saveConfig(false); } +// Collections.sort(contactsArr, collator); Collections.sort(contactsArr, new Comparator() { @Override public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) { @@ -1108,21 +1115,9 @@ } } - Collections.sort(sortedSectionsArray, new Comparator() { - @Override - public int compare(String s, String s2) { - char cv1 = s.charAt(0); - char cv2 = s2.charAt(0); - if (cv1 == '#') { - return 1; - } else if (cv2 == '#') { - return -1; - } - return s.compareTo(s2); - } - }); + Collections.sort(sortedSectionsArray, collator); - Collections.sort(sortedSectionsArrayMutual, new Comparator() { + /*Collections.sort(sortedSectionsArray, new Comparator() { @Override public int compare(String s, String s2) { char cv1 = s.charAt(0); @@ -1134,7 +1129,22 @@ } return s.compareTo(s2); } - }); + });*/ + + Collections.sort(sortedSectionsArrayMutual, collator); + /*Collections.sort(sortedSectionsArrayMutual, new Comparator() { + @Override + public int compare(String s, String s2) { + char cv1 = s.charAt(0); + char cv2 = s2.charAt(0); + if (cv1 == '#') { + return 1; + } else if (cv2 == '#') { + return -1; + } + return s.compareTo(s2); + } + });*/ AndroidUtilities.runOnUIThread(new Runnable() { @Override @@ -1246,16 +1256,18 @@ sortedPhoneBookContacts.add(value); } + +// Collections.sort(sortedPhoneBookContacts, collator); Collections.sort(sortedPhoneBookContacts, new Comparator() { @Override public int compare(Contact contact, Contact contact2) { - String toComapre1 = contact.first_name; + String toComapre1 = contact.last_name; if (toComapre1.length() == 0) { - toComapre1 = contact.last_name; + toComapre1 = contact.first_name; } - String toComapre2 = contact2.first_name; + String toComapre2 = contact2.last_name; if (toComapre2.length() == 0) { - toComapre2 = contact2.last_name; + toComapre2 = contact2.first_name; } return toComapre1.compareTo(toComapre2); } @@ -1266,6 +1278,7 @@ private void buildContactsSectionsArrays(boolean sort) { if (sort) { +// Collections.sort(contacts, collator); Collections.sort(contacts, new Comparator() { @Override public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) { @@ -1302,6 +1315,7 @@ key = replace; } ArrayList arr = sectionsDict.get(key); + Log.e("bello","aaa2222"); if (arr == null) { arr = new ArrayList<>(); sectionsDict.put(key, arr); @@ -1316,6 +1330,8 @@ UserConfig.contactsHash = Utilities.MD5(ids.toString()); UserConfig.saveConfig(false); + Collections.sort(sortedSectionsArray, collator); + /* Collections.sort(sortedSectionsArray, new Comparator() { @Override public int compare(String s, String s2) { @@ -1328,7 +1344,7 @@ } return s.compareTo(s2); } - }); + });*/ usersSectionsDict = sectionsDict; sortedUsersSectionsArray = sortedSectionsArray;