From 8568226468e7377e273410847a97ebf8a1d7e5e7 Mon Sep 17 00:00:00 2001 From: Shom Bandopadhaya Date: Tue, 4 Jan 2022 10:26:59 +0000 Subject: Local feeds: add sort option for file name (#5629) Co-authored-by: widlok --- .../antennapod/core/util/FeedItemPermutors.java | 12 +++++++++++ core/src/main/res/values/arrays.xml | 23 ++++++++++++++++++++++ core/src/main/res/values/strings.xml | 2 ++ 3 files changed, 37 insertions(+) (limited to 'core/src') 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; @@ -90,6 +96,12 @@ public class FeedItemPermutors { return (item != null && item.getMedia() != null) ? item.getMedia().getDuration() : 0; } + @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) 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 @@ @string/sort_duration_long_short + + + @string/sort_date_new_old + @string/sort_date_old_new + @string/sort_title_a_z + @string/sort_title_z_a + @string/sort_duration_short_long + @string/sort_duration_long_short + @string/sort_filename_a_z + @string/sort_filename_z_a + + DATE_NEW_OLD DATE_OLD_NEW @@ -218,6 +230,17 @@ DURATION_LONG_SHORT + + DATE_NEW_OLD + DATE_OLD_NEW + EPISODE_TITLE_A_Z + EPISODE_TITLE_Z_A + DURATION_SHORT_LONG + DURATION_LONG_SHORT + EPISODE_FILENAME_A_Z + EPISODE_FILENAME_Z_A + + @string/rewind_label @string/fast_forward_label 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 @@ Date (Old \u2192 New) Duration (Short \u2192 Long) Duration (Long \u2192 Short) + File Name (A \u2192 Z) + File Name (Z \u2192 A) A \u2192 Z Z \u2192 A -- cgit v1.2.3