Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix: Use unsorted if no key or no sort suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Feb 22, 2024
1 parent a65ee82 commit 46e6d9f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/src/main/java/app/revanced/integrations/shared/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private enum Sort {
}

/**
* Defaults to {@link #BY_TITLE} if key is null or has no sort suffix.
* Defaults to {@link #UNSORTED} if key is null or has no sort suffix.
*/
@NonNull
static Sort fromKey(@Nullable String key) {
Expand All @@ -435,7 +435,7 @@ static Sort fromKey(@Nullable String key) {
}
}
}
return BY_TITLE;
return UNSORTED;
}
}

Expand All @@ -455,9 +455,10 @@ public static String removePunctuationConvertToLowercase(@Nullable CharSequence
* Sort order is determined by the preferences key {@link Sort} suffix.
*
* If a preference has no key or no {@link Sort} suffix,
* then the preferences are sorted by the localized title.
* then the preferences are left unsorted.
*/
public static void sortPreferenceGroups(@NonNull PreferenceGroup group) {
Sort sort = Sort.fromKey(group.getKey());
SortedMap<String, Preference> preferences = new TreeMap<>();

for (int i = 0, prefCount = group.getPreferenceCount(); i < prefCount; i++) {
Expand All @@ -468,7 +469,7 @@ public static void sortPreferenceGroups(@NonNull PreferenceGroup group) {
}

final String sortValue;
switch (Sort.fromKey(group.getKey())) {
switch (sort) {
case BY_TITLE:
sortValue = removePunctuationConvertToLowercase(preference.getTitle());
break;
Expand Down

0 comments on commit 46e6d9f

Please sign in to comment.