summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Johnson <palehose@gmail.com>2023-02-22 14:34:43 -0600
committerGitHub <noreply@github.com>2023-02-22 21:34:43 +0100
commit9fed944392ee31f00ef91a01a2c34dddc876a86a (patch)
tree198a5618feacc5fbc847fae378bdaa6bbaec032c
parent5c79bc7c4541fbc0788d03adf3c56b483f96dcdb (diff)
downloadAntennaPod-9fed944392ee31f00ef91a01a2c34dddc876a86a.zip
Add "New Episodes Action" preference (#6095)
-rw-r--r--app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java3
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java43
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java22
-rw-r--r--app/src/main/res/layout/playback_speed_feed_setting_dialog.xml2
-rw-r--r--app/src/main/res/xml/feed_settings.xml10
-rw-r--r--app/src/main/res/xml/preferences_network.xml7
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java3
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java25
-rw-r--r--core/src/main/res/values/arrays.xml24
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/Feed.java3
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/FeedPreferences.java64
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java4
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java12
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java7
-rw-r--r--storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java8
-rw-r--r--ui/i18n/src/main/res/values/strings.xml6
18 files changed, 185 insertions, 62 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java
index aa2f1cf98..e8436a3a2 100644
--- a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java
@@ -129,7 +129,8 @@ public class PlaybackServiceMediaPlayerTest {
private Playable writeTestPlayable(String downloadUrl, String fileUrl) {
Feed f = new Feed(0, null, "f", "l", "d", null, null, null, null, "i", null, null, "l", false);
- FeedPreferences prefs = new FeedPreferences(f.getId(), false, FeedPreferences.AutoDeleteAction.NO, VolumeAdaptionSetting.OFF, null, null);
+ FeedPreferences prefs = new FeedPreferences(f.getId(), false, FeedPreferences.AutoDeleteAction.NEVER,
+ VolumeAdaptionSetting.OFF, FeedPreferences.NewEpisodesAction.NOTHING, null, null);
f.setPreferences(prefs);
f.setItems(new ArrayList<>());
FeedItem i = new FeedItem(0, "t", "i", "l", new Date(), FeedItem.UNPLAYED, f);
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
index 47c2e4dcd..b4195ba01 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java
@@ -105,6 +105,7 @@ public class FeedSettingsFragment extends Fragment {
private static final CharSequence PREF_AUTHENTICATION = "authentication";
private static final CharSequence PREF_AUTO_DELETE = "autoDelete";
private static final CharSequence PREF_CATEGORY_AUTO_DOWNLOAD = "autoDownloadCategory";
+ private static final CharSequence PREF_NEW_EPISODES_ACTION = "feedNewEpisodesAction";
private static final String PREF_FEED_PLAYBACK_SPEED = "feedPlaybackSpeed";
private static final String PREF_AUTO_SKIP = "feedAutoSkip";
private static final String PREF_TAGS = "tags";
@@ -156,6 +157,7 @@ public class FeedSettingsFragment extends Fragment {
setupKeepUpdatedPreference();
setupAutoDeletePreference();
setupVolumeReductionPreferences();
+ setupNewEpisodesAction();
setupAuthentificationPreference();
setupEpisodeFilterPreference();
setupPlaybackSpeedPreference();
@@ -166,6 +168,7 @@ public class FeedSettingsFragment extends Fragment {
updateAutoDeleteSummary();
updateVolumeReductionValue();
updateAutoDownloadEnabled();
+ updateNewEpisodesAction();
if (feed.isLocalFeed()) {
findPreference(PREF_AUTHENTICATION).setVisible(false);
@@ -283,11 +286,12 @@ public class FeedSettingsFragment extends Fragment {
feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.GLOBAL);
break;
case "always":
- feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.YES);
+ feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.ALWAYS);
break;
case "never":
- feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NO);
+ feedPreferences.setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NEVER);
break;
+ default:
}
DBWriter.setFeedPreferences(feedPreferences);
updateAutoDeleteSummary();
@@ -300,14 +304,14 @@ public class FeedSettingsFragment extends Fragment {
switch (feedPreferences.getAutoDeleteAction()) {
case GLOBAL:
- autoDeletePreference.setSummary(R.string.feed_auto_download_global);
+ autoDeletePreference.setSummary(R.string.global_default);
autoDeletePreference.setValue("global");
break;
- case YES:
+ case ALWAYS:
autoDeletePreference.setSummary(R.string.feed_auto_download_always);
autoDeletePreference.setValue("always");
break;
- case NO:
+ case NEVER:
autoDeletePreference.setSummary(R.string.feed_auto_download_never);
autoDeletePreference.setValue("never");
break;
@@ -327,6 +331,7 @@ public class FeedSettingsFragment extends Fragment {
case "heavy":
feedPreferences.setVolumeAdaptionSetting(VolumeAdaptionSetting.HEAVY_REDUCTION);
break;
+ default:
}
DBWriter.setFeedPreferences(feedPreferences);
updateVolumeReductionValue();
@@ -352,6 +357,34 @@ public class FeedSettingsFragment extends Fragment {
}
}
+ private void setupNewEpisodesAction() {
+ findPreference(PREF_NEW_EPISODES_ACTION).setOnPreferenceChangeListener((preference, newValue) -> {
+ int code = Integer.parseInt((String) newValue);
+ feedPreferences.setNewEpisodesAction(FeedPreferences.NewEpisodesAction.fromCode(code));
+ DBWriter.setFeedPreferences(feedPreferences);
+ updateNewEpisodesAction();
+ return false;
+ });
+ }
+
+ private void updateNewEpisodesAction() {
+ ListPreference newEpisodesAction = findPreference(PREF_NEW_EPISODES_ACTION);
+ newEpisodesAction.setValue("" + feedPreferences.getNewEpisodesAction().code);
+
+ switch (feedPreferences.getNewEpisodesAction()) {
+ case GLOBAL:
+ newEpisodesAction.setSummary(R.string.global_default);
+ break;
+ case ADD_TO_INBOX:
+ newEpisodesAction.setSummary(R.string.feed_new_episodes_action_add_to_inbox);
+ break;
+ case NOTHING:
+ newEpisodesAction.setSummary(R.string.feed_new_episodes_action_nothing);
+ break;
+ default:
+ }
+ }
+
private void setupKeepUpdatedPreference() {
SwitchPreferenceCompat pref = findPreference("keepUpdated");
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java b/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java
index 203a64c32..bbe78f4a2 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java
@@ -89,28 +89,12 @@ public class FeedMultiSelectActionHandler {
private void autoDeleteEpisodesPrefHandler() {
PreferenceListDialog preferenceListDialog = new PreferenceListDialog(activity,
- "Auto delete episodes");
+ activity.getString(R.string.auto_delete_label));
String[] items = activity.getResources().getStringArray(R.array.spnAutoDeleteItems);
- String[] values = activity.getResources().getStringArray(R.array.spnAutoDeleteValues);
preferenceListDialog.openDialog(items);
preferenceListDialog.setOnPreferenceChangedListener(which -> {
- FeedPreferences.AutoDeleteAction autoDeleteAction = null;
- switch (values[which]) {
- case "global":
- autoDeleteAction = FeedPreferences.AutoDeleteAction.GLOBAL;
- break;
- case "always":
- autoDeleteAction = FeedPreferences.AutoDeleteAction.YES;
- break;
- case "never":
- autoDeleteAction = FeedPreferences.AutoDeleteAction.NO;
- break;
- default:
- }
- FeedPreferences.AutoDeleteAction finalAutoDeleteAction = autoDeleteAction;
- saveFeedPreferences(feedPreferences -> {
- feedPreferences.setAutoDeleteAction(finalAutoDeleteAction);
- });
+ FeedPreferences.AutoDeleteAction autoDeleteAction = FeedPreferences.AutoDeleteAction.fromCode(which);
+ saveFeedPreferences(feedPreferences -> feedPreferences.setAutoDeleteAction(autoDeleteAction));
});
}
diff --git a/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml b/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml
index 572096911..48d69e4a9 100644
--- a/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml
+++ b/app/src/main/res/layout/playback_speed_feed_setting_dialog.xml
@@ -10,7 +10,7 @@
android:id="@+id/useGlobalCheckbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/feed_auto_download_global"
+ android:text="@string/global_default"
android:layout_marginBottom="8dp" />
<LinearLayout
diff --git a/app/src/main/res/xml/feed_settings.xml b/app/src/main/res/xml/feed_settings.xml
index a2ea42f01..619ab6296 100644
--- a/app/src/main/res/xml/feed_settings.xml
+++ b/app/src/main/res/xml/feed_settings.xml
@@ -45,7 +45,7 @@
android:entryValues="@array/spnAutoDeleteValues"
android:icon="@drawable/ic_delete"
android:key="autoDelete"
- android:summary="@string/feed_auto_download_global"
+ android:summary="@string/global_default"
android:title="@string/auto_delete_label" />
<de.danoeh.antennapod.preferences.MaterialListPreference
@@ -57,6 +57,14 @@
android:summary="@string/feed_volume_reduction_summary"
android:title="@string/feed_volume_reduction" />
+ <de.danoeh.antennapod.preferences.MaterialListPreference
+ android:entries="@array/feedNewEpisodesActionItems"
+ android:entryValues="@array/feedNewEpisodesActionValues"
+ android:icon="@drawable/ic_feed"
+ android:key="feedNewEpisodesAction"
+ android:summary="@string/global_default"
+ android:title="@string/pref_new_episodes_action_title" />
+
<PreferenceCategory
android:key="autoDownloadCategory"
android:title="@string/auto_download_settings_label">
diff --git a/app/src/main/res/xml/preferences_network.xml b/app/src/main/res/xml/preferences_network.xml
index 428c891ad..83929bb70 100644
--- a/app/src/main/res/xml/preferences_network.xml
+++ b/app/src/main/res/xml/preferences_network.xml
@@ -13,6 +13,13 @@
android:key="prefAutoDownloadSettings"
android:title="@string/pref_automatic_download_title"
search:ignore="true" />
+ <de.danoeh.antennapod.preferences.MaterialListPreference
+ android:entryValues="@array/globalNewEpisodesActionValues"
+ android:entries="@array/globalNewEpisodesActionItems"
+ android:key="prefNewEpisodesAction"
+ android:title="@string/pref_new_episodes_action_title"
+ android:summary="@string/pref_new_episodes_action_sum"
+ android:defaultValue="1"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/download_pref_details">
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java
index 8ee924243..058602fdd 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java
@@ -124,7 +124,7 @@ public class LocalFeedUpdater {
feed.setImageUrl(getImageUrl(allFiles, folderUri));
feed.getPreferences().setAutoDownload(false);
- feed.getPreferences().setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NO);
+ feed.getPreferences().setAutoDeleteAction(FeedPreferences.AutoDeleteAction.NEVER);
feed.setDescription(context.getString(R.string.local_feed_description));
feed.setAuthor(context.getString(R.string.local_folder));
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java
index a5ed5c3dd..1118b93cd 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java
@@ -43,7 +43,8 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
feed.setId(request.getFeedfileId());
feed.setDownloaded(true);
feed.setPreferences(new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL,
- VolumeAdaptionSetting.OFF, request.getUsername(), request.getPassword()));
+ VolumeAdaptionSetting.OFF, FeedPreferences.NewEpisodesAction.GLOBAL, request.getUsername(),
+ request.getPassword()));
feed.setPageNr(request.getArguments().getInt(DownloadRequest.REQUEST_ARG_PAGE_NR, 0));
DownloadError reason = null;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
index 36a056c5d..7e0377c88 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
@@ -1073,7 +1073,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
// Delete episode if enabled
FeedPreferences.AutoDeleteAction action =
item.getFeed().getPreferences().getCurrentAutoDelete();
- boolean shouldAutoDelete = action == FeedPreferences.AutoDeleteAction.YES
+ boolean shouldAutoDelete = action == FeedPreferences.AutoDeleteAction.ALWAYS
|| (action == FeedPreferences.AutoDeleteAction.GLOBAL && UserPreferences.isAutoDelete());
if (shouldAutoDelete && (!item.isTagged(FeedItem.TAG_FAVORITE)
|| !UserPreferences.shouldFavoriteKeepEpisode())) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
index 423c83c79..bf03ebff1 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
@@ -42,6 +42,7 @@ import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
import de.danoeh.antennapod.model.feed.Feed;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
+import de.danoeh.antennapod.model.feed.FeedPreferences;
import de.danoeh.antennapod.net.sync.model.EpisodeAction;
/**
@@ -298,13 +299,6 @@ public final class DBTasks {
Log.d(TAG, "Found no existing Feed with title "
+ newFeed.getTitle() + ". Adding as new one.");
- // Add a new Feed
- // all new feeds will have the most recent item marked as unplayed
- FeedItem mostRecent = newFeed.getMostRecentItem();
- if (mostRecent != null) {
- mostRecent.setNew();
- }
-
resultFeed = newFeed;
} else {
Log.d(TAG, "Feed with title " + newFeed.getTitle()
@@ -388,14 +382,15 @@ public final class DBTasks {
savedFeed.getItems().add(idx, item);
}
- // only mark the item new if it was published after or at the same time
- // as the most recent item
- // (if the most recent date is null then we can assume there are no items
- // and this is the first, hence 'new')
- // New items that do not have a pubDate set are always marked as new
- if (item.getPubDate() == null || priorMostRecentDate == null
- || priorMostRecentDate.before(item.getPubDate())
- || priorMostRecentDate.equals(item.getPubDate())) {
+ FeedPreferences.NewEpisodesAction action = savedFeed.getPreferences().getNewEpisodesAction();
+ if (action == FeedPreferences.NewEpisodesAction.GLOBAL) {
+ action = UserPreferences.getNewEpisodesAction();
+ }
+ if (action == FeedPreferences.NewEpisodesAction.ADD_TO_INBOX
+ && (item.getPubDate() == null
+ || priorMostRecentDate == null
+ || priorMostRecentDate.before(item.getPubDate())
+ || priorMostRecentDate.equals(item.getPubDate()))) {
Log.d(TAG, "Marking item published on " + item.getPubDate()
+ " new, prior most recent date = " + priorMostRecentDate);
item.setNew();
diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml
index 090d5e2e4..b8b9d3d6d 100644
--- a/core/src/main/res/values/arrays.xml
+++ b/core/src/main/res/values/arrays.xml
@@ -2,7 +2,7 @@
<resources>
<string-array name="spnAutoDeleteItems">
- <item>@string/feed_auto_download_global</item>
+ <item>@string/global_default</item>
<item>@string/feed_auto_download_always</item>
<item>@string/feed_auto_download_never</item>
</string-array>
@@ -25,6 +25,28 @@
<item>heavy</item>
</string-array>
+ <string-array name="globalNewEpisodesActionItems">
+ <item>@string/feed_new_episodes_action_add_to_inbox</item>
+ <item>@string/feed_new_episodes_action_nothing</item>
+ </string-array>
+
+ <string-array name="globalNewEpisodesActionValues">
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
+ <string-array name="feedNewEpisodesActionItems">
+ <item>@string/global_default</item>
+ <item>@string/feed_new_episodes_action_add_to_inbox</item>
+ <item>@string/feed_new_episodes_action_nothing</item>
+ </string-array>
+
+ <string-array name="feedNewEpisodesActionValues">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
<string-array name="smart_mark_as_played_values">
<item>0</item>
<item>15</item>
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;
}
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java
index 78eaf6964..e4a1f5a3d 100644
--- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java
+++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java
@@ -330,6 +330,10 @@ class DBUpgrader {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " ADD COLUMN " + PodDBAdapter.KEY_PODCASTINDEX_CHAPTER_URL + " TEXT");
}
+ if (oldVersion < 3010000) {
+ db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ + " ADD COLUMN " + PodDBAdapter.KEY_NEW_EPISODES_ACTION + " INTEGER DEFAULT 0");
+ }
}
}
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java
index bb0218a0b..0909ea4b7 100644
--- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java
+++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java
@@ -54,7 +54,7 @@ public class PodDBAdapter {
private static final String TAG = "PodDBAdapter";
public static final String DATABASE_NAME = "Antennapod.db";
- public static final int VERSION = 2060000;
+ public static final int VERSION = 3010000;
/**
* Maximum number of arguments for IN-operator.
@@ -120,6 +120,7 @@ public class PodDBAdapter {
public static final String KEY_FEED_SKIP_ENDING = "feed_skip_ending";
public static final String KEY_FEED_TAGS = "tags";
public static final String KEY_EPISODE_NOTIFICATION = "episode_notification";
+ public static final String KEY_NEW_EPISODES_ACTION = "new_episodes_action";
public static final String KEY_PODCASTINDEX_CHAPTER_URL = "podcastindex_chapter_url";
// Table names
@@ -161,7 +162,8 @@ public class PodDBAdapter {
+ KEY_FEED_TAGS + " TEXT,"
+ KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0,"
+ KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0,"
- + KEY_EPISODE_NOTIFICATION + " INTEGER DEFAULT 0)";
+ + KEY_EPISODE_NOTIFICATION + " INTEGER DEFAULT 0,"
+ + KEY_NEW_EPISODES_ACTION + " INTEGER DEFAULT 0)";
private static final String CREATE_TABLE_FEED_ITEMS = "CREATE TABLE "
+ TABLE_NAME_FEED_ITEMS + " (" + TABLE_PRIMARY_KEY
@@ -311,7 +313,8 @@ public class PodDBAdapter {
+ TABLE_NAME_FEEDS + "." + KEY_FEED_TAGS + ", "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_INTRO + ", "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_ENDING + ", "
- + TABLE_NAME_FEEDS + "." + KEY_EPISODE_NOTIFICATION;
+ + TABLE_NAME_FEEDS + "." + KEY_EPISODE_NOTIFICATION + ", "
+ + TABLE_NAME_FEEDS + "." + KEY_NEW_EPISODES_ACTION;
private static final String JOIN_FEED_ITEM_AND_MEDIA = " LEFT JOIN " + TABLE_NAME_FEED_MEDIA
+ " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "=" + TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM + " ";
@@ -448,7 +451,7 @@ public class PodDBAdapter {
ContentValues values = new ContentValues();
values.put(KEY_AUTO_DOWNLOAD_ENABLED, prefs.getAutoDownload());
values.put(KEY_KEEP_UPDATED, prefs.getKeepUpdated());
- values.put(KEY_AUTO_DELETE_ACTION, prefs.getAutoDeleteAction().ordinal());
+ values.put(KEY_AUTO_DELETE_ACTION, prefs.getAutoDeleteAction().code);
values.put(KEY_FEED_VOLUME_ADAPTION, prefs.getVolumeAdaptionSetting().toInteger());
values.put(KEY_USERNAME, prefs.getUsername());
values.put(KEY_PASSWORD, prefs.getPassword());
@@ -460,6 +463,7 @@ public class PodDBAdapter {
values.put(KEY_FEED_SKIP_INTRO, prefs.getFeedSkipIntro());
values.put(KEY_FEED_SKIP_ENDING, prefs.getFeedSkipEnding());
values.put(KEY_EPISODE_NOTIFICATION, prefs.getShowEpisodeNotification());
+ values.put(KEY_NEW_EPISODES_ACTION, prefs.getNewEpisodesAction().code);
db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[]{String.valueOf(prefs.getFeedID())});
}
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java
index 289bcbab8..2de100dff 100644
--- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java
+++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java
@@ -34,14 +34,14 @@ public abstract class FeedPreferencesCursorMapper {
int indexAutoSkipIntro = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_SKIP_INTRO);
int indexAutoSkipEnding = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_SKIP_ENDING);
int indexEpisodeNotification = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_EPISODE_NOTIFICATION);
+ int indexNewEpisodesAction = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_NEW_EPISODES_ACTION);
int indexTags = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_TAGS);
long feedId = cursor.getLong(indexId);
boolean autoDownload = cursor.getInt(indexAutoDownload) > 0;
boolean autoRefresh = cursor.getInt(indexAutoRefresh) > 0;
- int autoDeleteActionIndex = cursor.getInt(indexAutoDeleteAction);
FeedPreferences.AutoDeleteAction autoDeleteAction =
- FeedPreferences.AutoDeleteAction.values()[autoDeleteActionIndex];
+ FeedPreferences.AutoDeleteAction.fromCode(cursor.getInt(indexAutoDeleteAction));
int volumeAdaptionValue = cursor.getInt(indexVolumeAdaption);
VolumeAdaptionSetting volumeAdaptionSetting = VolumeAdaptionSetting.fromInteger(volumeAdaptionValue);
String username = cursor.getString(indexUsername);
@@ -52,6 +52,8 @@ public abstract class FeedPreferencesCursorMapper {
float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed);
int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro);
int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding);
+ FeedPreferences.NewEpisodesAction feedNewEpisodesAction =
+ FeedPreferences.NewEpisodesAction.fromCode(cursor.getInt(indexNewEpisodesAction));
boolean showNotification = cursor.getInt(indexEpisodeNotification) > 0;
String tagsString = cursor.getString(indexTags);
if (TextUtils.isEmpty(tagsString)) {
@@ -69,6 +71,7 @@ public abstract class FeedPreferencesCursorMapper {
feedAutoSkipIntro,
feedAutoSkipEnding,
showNotification,
+ feedNewEpisodesAction,
new HashSet<>(Arrays.asList(tagsString.split(FeedPreferences.TAG_SEPARATOR))));
}
}
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 c7758d40e..37cfb4f19 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
@@ -13,6 +13,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.app.NotificationCompat;
import androidx.preference.PreferenceManager;
+import de.danoeh.antennapod.model.feed.FeedPreferences;
import org.json.JSONArray;
import org.json.JSONException;
@@ -67,6 +68,7 @@ public class UserPreferences {
public static final String PREF_QUEUE_KEEP_SORTED = "prefQueueKeepSorted";
public static final String PREF_QUEUE_KEEP_SORTED_ORDER = "prefQueueKeepSortedOrder";
+ public static final String PREF_NEW_EPISODES_ACTION = "prefNewEpisodesAction";
private static final String PREF_DOWNLOADS_SORTED_ORDER = "prefDownloadSortedOrder";
// Playback
@@ -944,6 +946,12 @@ public class UserPreferences {
.apply();
}
+ public static FeedPreferences.NewEpisodesAction getNewEpisodesAction() {
+ String str = prefs.getString(PREF_NEW_EPISODES_ACTION,
+ "" + FeedPreferences.NewEpisodesAction.ADD_TO_INBOX.code);
+ return FeedPreferences.NewEpisodesAction.fromCode(Integer.parseInt(str));
+ }
+
/**
* Returns the sort order for the downloads.
*/
diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml
index 4f98f2d86..a12119a6c 100644
--- a/ui/i18n/src/main/res/values/strings.xml
+++ b/ui/i18n/src/main/res/values/strings.xml
@@ -102,6 +102,7 @@
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="reset">Reset</string>
+ <string name="global_default">Global default</string>
<string name="url_label">URL</string>
<string name="support_funding_label">Support</string>
<string name="support_podcast">Support this Podcast</string>
@@ -124,9 +125,10 @@
<string name="feed_volume_reduction_light">Light</string>
<string name="feed_volume_reduction_heavy">Heavy</string>
<string name="parallel_downloads">%1$d parallel downloads</string>
- <string name="feed_auto_download_global">Global default</string>
<string name="feed_auto_download_always">Always</string>
<string name="feed_auto_download_never">Never</string>
+ <string name="feed_new_episodes_action_add_to_inbox">Add to Inbox</string>
+ <string name="feed_new_episodes_action_nothing">Nothing</string>
<string name="send_label">Send&#8230;</string>
<string name="episode_cleanup_never">Never</string>
<string name="episode_cleanup_except_favorite_removal">When not favorited</string>
@@ -529,6 +531,8 @@
<string name="pref_contribute">Contribute</string>
<string name="pref_show_subscription_title">Show Subscription Title</string>
<string name="pref_show_subscription_title_summary">Display the subscription title below the cover image.</string>
+ <string name="pref_new_episodes_action_title">New Episodes Action</string>
+ <string name="pref_new_episodes_action_sum">Action to take for new episodes</string>
<!-- About screen -->
<string name="about_pref">About</string>