diff options
5 files changed, 9 insertions, 1 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java index 1b8100392..be947bc1e 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java @@ -123,6 +123,7 @@ public class PreferencesTest { doTestEnqueueLocation(R.string.enqueue_location_after_current, EnqueueLocation.AFTER_CURRENTLY_PLAYING); doTestEnqueueLocation(R.string.enqueue_location_front, EnqueueLocation.FRONT); doTestEnqueueLocation(R.string.enqueue_location_back, EnqueueLocation.BACK); + doTestEnqueueLocation(R.string.enqueue_location_random, EnqueueLocation.RANDOM); } private void doTestEnqueueLocation(@StringRes int optionResId, EnqueueLocation expected) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java b/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java index 23d308c02..b81f281e8 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculator.java @@ -6,6 +6,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.List; +import java.util.Random; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.model.feed.FeedItem; @@ -46,6 +47,9 @@ class ItemEnqueuePositionCalculator { int currentlyPlayingPosition = getCurrentlyPlayingPosition(curQueue, currentPlaying); return getPositionOfFirstNonDownloadingItem( currentlyPlayingPosition + 1, curQueue); + case RANDOM: + Random random = new Random(); + return random.nextInt(curQueue.size() + 1); default: throw new AssertionError("calcPosition() : unrecognized enqueueLocation option: " + enqueueLocation); } diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index f3c0a0a3c..7749c6f3c 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -161,6 +161,7 @@ <item>@string/enqueue_location_back</item> <item>@string/enqueue_location_front</item> <item>@string/enqueue_location_after_current</item> + <item>@string/enqueue_location_random</item> </string-array> <string-array name="enqueue_location_values"> @@ -168,6 +169,7 @@ <item>BACK</item> <item>FRONT</item> <item>AFTER_CURRENTLY_PLAYING</item> + <item>RANDOM</item> </string-array> <string-array name="episode_cleanup_values"> diff --git a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java index 8a4d248ee..fda95ccd7 100644 --- a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java +++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java @@ -345,7 +345,7 @@ public class UserPreferences { } public enum EnqueueLocation { - BACK, FRONT, AFTER_CURRENTLY_PLAYING + BACK, FRONT, AFTER_CURRENTLY_PLAYING, RANDOM } @NonNull diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index e45cfd481..2a2f7b6d1 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -492,6 +492,7 @@ <string name="enqueue_location_back">Back</string> <string name="enqueue_location_front">Front</string> <string name="enqueue_location_after_current">After current episode</string> + <string name="enqueue_location_random">Random</string> <string name="pref_smart_mark_as_played_disabled">Disabled</string> <string name="documentation_support">Documentation & Support</string> <string name="visit_user_forum">User forum</string> |