Random enqueue location (#6403)
This commit is contained in:
parent
214bf974cf
commit
548f9e021e
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -345,7 +345,7 @@ public class UserPreferences {
|
|||
}
|
||||
|
||||
public enum EnqueueLocation {
|
||||
BACK, FRONT, AFTER_CURRENTLY_PLAYING
|
||||
BACK, FRONT, AFTER_CURRENTLY_PLAYING, RANDOM
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue