diff options
author | Shom Bandopadhaya <shom@bandopadhaya.com> | 2022-01-04 10:26:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 11:26:59 +0100 |
commit | 8568226468e7377e273410847a97ebf8a1d7e5e7 (patch) | |
tree | 487879cce40c1dba0180d4041430bdde9f0cf26f /core/src | |
parent | 4f031c4e45cc2e83059da8bed55f23bca345320d (diff) | |
download | AntennaPod-8568226468e7377e273410847a97ebf8a1d7e5e7.zip |
Local feeds: add sort option for file name (#5629)
Co-authored-by: widlok <widlok@users.noreply.github.com>
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/FeedItemPermutors.java | 12 | ||||
-rw-r--r-- | core/src/main/res/values/arrays.xml | 23 | ||||
-rw-r--r-- | core/src/main/res/values/strings.xml | 2 |
3 files changed, 37 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemPermutors.java b/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemPermutors.java index 09161ca7b..7f2742ab0 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemPermutors.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemPermutors.java @@ -50,6 +50,12 @@ public class FeedItemPermutors { case DURATION_LONG_SHORT: comparator = (f1, f2) -> Integer.compare(duration(f2), duration(f1)); break; + case EPISODE_FILENAME_A_Z: + comparator = (f1, f2) -> itemLink(f1).compareTo(itemLink(f2)); + break; + case EPISODE_FILENAME_Z_A: + comparator = (f1, f2) -> itemLink(f2).compareTo(itemLink(f1)); + break; case FEED_TITLE_A_Z: comparator = (f1, f2) -> feedTitle(f1).compareTo(feedTitle(f2)); break; @@ -91,6 +97,12 @@ public class FeedItemPermutors { } @NonNull + private static String itemLink(@Nullable FeedItem item) { + return (item != null && item.getLink() != null) + ? item.getLink().toLowerCase(Locale.getDefault()) : ""; + } + + @NonNull private static String feedTitle(@Nullable FeedItem item) { return (item != null && item.getFeed() != null && item.getFeed().getTitle() != null) ? item.getFeed().getTitle().toLowerCase(Locale.getDefault()) : ""; diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index ba4d48219..de83bbf59 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -209,6 +209,18 @@ <item>@string/sort_duration_long_short</item> </string-array> + <!-- sort for local feed screen --> + <string-array name="local_feed_episodes_sort_options"> + <item>@string/sort_date_new_old</item> + <item>@string/sort_date_old_new</item> + <item>@string/sort_title_a_z</item> + <item>@string/sort_title_z_a</item> + <item>@string/sort_duration_short_long</item> + <item>@string/sort_duration_long_short</item> + <item>@string/sort_filename_a_z</item> + <item>@string/sort_filename_z_a</item> + </string-array> + <string-array name="feed_episodes_sort_values"> <item>DATE_NEW_OLD</item> <item>DATE_OLD_NEW</item> @@ -218,6 +230,17 @@ <item>DURATION_LONG_SHORT</item> </string-array> + <string-array name="local_feed_episodes_sort_values"> + <item>DATE_NEW_OLD</item> + <item>DATE_OLD_NEW</item> + <item>EPISODE_TITLE_A_Z</item> + <item>EPISODE_TITLE_Z_A</item> + <item>DURATION_SHORT_LONG</item> + <item>DURATION_LONG_SHORT</item> + <item>EPISODE_FILENAME_A_Z</item> + <item>EPISODE_FILENAME_Z_A</item> + </string-array> + <string-array name="compact_notification_buttons_options"> <item>@string/rewind_label</item> <item>@string/fast_forward_label</item> diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index d011b9cf1..5ed065793 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -761,6 +761,8 @@ <string name="sort_date_old_new">Date (Old \u2192 New)</string> <string name="sort_duration_short_long">Duration (Short \u2192 Long)</string> <string name="sort_duration_long_short">Duration (Long \u2192 Short)</string> + <string name="sort_filename_a_z">File Name (A \u2192 Z)</string> + <string name="sort_filename_z_a">File Name (Z \u2192 A)</string> <string name="sort_a_z">A \u2192 Z</string> <string name="sort_z_a">Z \u2192 A</string> |