diff options
author | Erik Johnson <palehose@gmail.com> | 2023-02-22 14:34:43 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-22 21:34:43 +0100 |
commit | 9fed944392ee31f00ef91a01a2c34dddc876a86a (patch) | |
tree | 198a5618feacc5fbc847fae378bdaa6bbaec032c /model/src | |
parent | 5c79bc7c4541fbc0788d03adf3c56b483f96dcdb (diff) | |
download | AntennaPod-9fed944392ee31f00ef91a01a2c34dddc876a86a.zip |
Add "New Episodes Action" preference (#6095)
Diffstat (limited to 'model/src')
-rw-r--r-- | model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java | 3 | ||||
-rw-r--r-- | model/src/main/java/de/danoeh/antennapod/model/feed/FeedPreferences.java | 64 |
2 files changed, 58 insertions, 9 deletions
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java b/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java index 006505eb1..94a4776a5 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java @@ -173,7 +173,8 @@ public class Feed extends FeedFile { */ public Feed(String url, String lastUpdate, String title, String username, String password) { this(url, lastUpdate, title); - preferences = new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF, username, password); + preferences = new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF, + FeedPreferences.NewEpisodesAction.GLOBAL, username, password); } /** diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedPreferences.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedPreferences.java index cbbb3c2e7..8e3dd48f6 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedPreferences.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedPreferences.java @@ -17,9 +17,45 @@ public class FeedPreferences implements Serializable { public static final String TAG_SEPARATOR = "\u001e"; public enum AutoDeleteAction { - GLOBAL, - YES, - NO + GLOBAL(0), + ALWAYS(1), + NEVER(2); + + public final int code; + + AutoDeleteAction(int code) { + this.code = code; + } + + public static AutoDeleteAction fromCode(int code) { + for (AutoDeleteAction action : values()) { + if (code == action.code) { + return action; + } + } + return NEVER; + } + } + + public enum NewEpisodesAction { + GLOBAL(0), + ADD_TO_INBOX(1), + NOTHING(2); + + public final int code; + + NewEpisodesAction(int code) { + this.code = code; + } + + public static NewEpisodesAction fromCode(int code) { + for (NewEpisodesAction action : values()) { + if (code == action.code) { + return action; + } + } + return ADD_TO_INBOX; + } } @NonNull @@ -29,6 +65,7 @@ public class FeedPreferences implements Serializable { private boolean keepUpdated; private AutoDeleteAction autoDeleteAction; private VolumeAdaptionSetting volumeAdaptionSetting; + private NewEpisodesAction newEpisodesAction; private String username; private String password; private float feedPlaybackSpeed; @@ -38,15 +75,17 @@ public class FeedPreferences implements Serializable { private final Set<String> tags = new HashSet<>(); public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction autoDeleteAction, - VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) { - this(feedID, autoDownload, true, autoDeleteAction, volumeAdaptionSetting, - username, password, new FeedFilter(), SPEED_USE_GLOBAL, 0, 0, false, new HashSet<>()); + VolumeAdaptionSetting volumeAdaptionSetting, NewEpisodesAction newEpisodesAction, + String username, String password) { + this(feedID, autoDownload, true, autoDeleteAction, volumeAdaptionSetting, username, password, + new FeedFilter(), SPEED_USE_GLOBAL, 0, 0, false, newEpisodesAction, new HashSet<>()); } public FeedPreferences(long feedID, boolean autoDownload, boolean keepUpdated, AutoDeleteAction autoDeleteAction, VolumeAdaptionSetting volumeAdaptionSetting, - String username, String password, @NonNull FeedFilter filter, float feedPlaybackSpeed, - int feedSkipIntro, int feedSkipEnding, boolean showEpisodeNotification, + String username, String password, @NonNull FeedFilter filter, + float feedPlaybackSpeed, int feedSkipIntro, int feedSkipEnding, + boolean showEpisodeNotification, NewEpisodesAction newEpisodesAction, Set<String> tags) { this.feedID = feedID; this.autoDownload = autoDownload; @@ -60,6 +99,7 @@ public class FeedPreferences implements Serializable { this.feedSkipIntro = feedSkipIntro; this.feedSkipEnding = feedSkipEnding; this.showEpisodeNotification = showEpisodeNotification; + this.newEpisodesAction = newEpisodesAction; this.tags.addAll(tags); } @@ -140,6 +180,10 @@ public class FeedPreferences implements Serializable { return volumeAdaptionSetting; } + public NewEpisodesAction getNewEpisodesAction() { + return newEpisodesAction; + } + public void setAutoDeleteAction(AutoDeleteAction autoDeleteAction) { this.autoDeleteAction = autoDeleteAction; } @@ -148,6 +192,10 @@ public class FeedPreferences implements Serializable { this.volumeAdaptionSetting = volumeAdaptionSetting; } + public void setNewEpisodesAction(NewEpisodesAction newEpisodesAction) { + this.newEpisodesAction = newEpisodesAction; + } + public AutoDeleteAction getCurrentAutoDelete() { return autoDeleteAction; } |