|
1 | 1 | package app.revanced.extension.shared;
|
2 | 2 |
|
3 | 3 | import android.annotation.SuppressLint;
|
4 |
| -import android.app.*; |
| 4 | +import android.app.Activity; |
| 5 | +import android.app.AlertDialog; |
| 6 | +import android.app.Dialog; |
| 7 | +import android.app.DialogFragment; |
| 8 | +import android.app.Fragment; |
5 | 9 | import android.content.Context;
|
6 | 10 | import android.content.Intent;
|
7 | 11 | import android.content.pm.ApplicationInfo;
|
|
18 | 22 | import android.preference.Preference;
|
19 | 23 | import android.preference.PreferenceGroup;
|
20 | 24 | import android.preference.PreferenceScreen;
|
| 25 | +import android.util.Pair; |
21 | 26 | import android.view.View;
|
22 | 27 | import android.view.ViewGroup;
|
23 | 28 | import android.view.ViewParent;
|
@@ -738,9 +743,9 @@ public static String removePunctuationToLowercase(@Nullable CharSequence origina
|
738 | 743 | * then the preferences are left unsorted.
|
739 | 744 | */
|
740 | 745 | @SuppressWarnings("deprecation")
|
741 |
| - public static void sortPreferenceGroups(@NonNull PreferenceGroup group) { |
| 746 | + public static void sortPreferenceGroups(PreferenceGroup group) { |
742 | 747 | Sort groupSort = Sort.fromKey(group.getKey(), Sort.UNSORTED);
|
743 |
| - SortedMap<String, Preference> preferences = new TreeMap<>(); |
| 748 | + List<Pair<String, Preference>> preferences = new ArrayList<>(); |
744 | 749 |
|
745 | 750 | for (int i = 0, prefCount = group.getPreferenceCount(); i < prefCount; i++) {
|
746 | 751 | Preference preference = group.getPreference(i);
|
@@ -769,17 +774,21 @@ public static void sortPreferenceGroups(@NonNull PreferenceGroup group) {
|
769 | 774 | throw new IllegalStateException();
|
770 | 775 | }
|
771 | 776 |
|
772 |
| - preferences.put(sortValue, preference); |
| 777 | + preferences.add(new Pair<>(sortValue, preference)); |
773 | 778 | }
|
774 | 779 |
|
| 780 | + Collections.sort(preferences, (pair1, pair2) |
| 781 | + -> pair1.first.compareToIgnoreCase(pair2.first)); |
| 782 | + |
775 | 783 | int index = 0;
|
776 |
| - for (Preference pref : preferences.values()) { |
| 784 | + for (Pair<String, Preference> pair : preferences) { |
777 | 785 | int order = index++;
|
| 786 | + Preference pref = pair.second; |
778 | 787 |
|
779 | 788 | // Move any screens, intents, and the one off About preference to the top.
|
780 | 789 | if (pref instanceof PreferenceScreen || pref instanceof ReVancedAboutPreference
|
781 | 790 | || pref.getIntent() != null) {
|
782 |
| - // Arbitrary high number. |
| 791 | + // Any arbitrary large number. |
783 | 792 | order -= 1000;
|
784 | 793 | }
|
785 | 794 |
|
|
0 commit comments