diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-01-15 11:23:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-15 11:23:44 +0100 |
commit | cf477de365e44664fe4dd224c6c53cd8af680cc4 (patch) | |
tree | 48426e30285131a50995cbff0775bf597c6a8d0e /core | |
parent | 6d50be18dbe310c0665ef7179929420408856841 (diff) | |
parent | dfcb16d77b5e9b7ea3f5d19e528c9f4950eb4520 (diff) | |
download | AntennaPod-cf477de365e44664fe4dd224c6c53cd8af680cc4.zip |
Merge pull request #2921 from qkolj/delete-episodes
Add delete option to episode's context menu
Diffstat (limited to 'core')
3 files changed, 23 insertions, 7 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index b81a4f0df..9870582c9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -100,6 +100,7 @@ public class UserPreferences { // Other private static final String PREF_DATA_FOLDER = "prefDataFolder"; public static final String PREF_IMAGE_CACHE_SIZE = "prefImageCacheSize"; + public static final String PREF_DELETE_REMOVES_FROM_QUEUE = "prefDeleteRemovesFromQueue"; // Mediaplayer public static final String PREF_MEDIA_PLAYER = "prefMediaPlayer"; @@ -311,6 +312,10 @@ public class UserPreferences { return Integer.parseInt(prefs.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30")); } + public static boolean shouldDeleteRemoveFromQueue() { + return prefs.getBoolean(PREF_DELETE_REMOVES_FROM_QUEUE, false); + } + public static boolean isAutoFlattr() { return prefs.getBoolean(PREF_AUTO_FLATTR, false); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java index bbe6145ea..93f51d63c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java @@ -74,13 +74,7 @@ public class DBWriter { private DBWriter() { } - /** - * Deletes a downloaded FeedMedia file from the storage device. - * - * @param context A context that is used for opening a database connection. - * @param mediaId ID of the FeedMedia object whose downloaded file should be deleted. - */ - public static Future<?> deleteFeedMediaOfItem(final Context context, + private static Future<?> doDeleteFeedMediaOfItem(final Context context, final long mediaId) { return dbExec.submit(() -> { final FeedMedia media = DBReader.getFeedMedia(mediaId); @@ -137,6 +131,21 @@ public class DBWriter { } /** + * Deletes a downloaded FeedMedia file from the storage device. + * + * @param context A context that is used for opening a database connection. + * @param mediaId ID of the FeedMedia object whose downloaded file should be deleted. + */ + public static Future<?> deleteFeedMediaOfItem(final Context context, + final long mediaId) { + Future res = doDeleteFeedMediaOfItem(context, mediaId); + if (UserPreferences.shouldDeleteRemoveFromQueue()) { + DBWriter.removeQueueItem(context, DBReader.getFeedMedia(mediaId).getItem(), false); + } + return res; + } + + /** * Deletes a Feed and all downloaded files of its components like images and downloaded episodes. * * @param context A context that is used for opening a database connection. diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 74c7644bf..21314c80c 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -482,6 +482,8 @@ <string name="double_tap_toast">Tap back button again to exit</string> <string name="back_button_go_to_page">Go to pageā¦</string> <string name="back_button_go_to_page_title">Select page</string> + <string name="pref_delete_removes_from_queue_title">Delete removes from Queue</string> + <string name="pref_delete_removes_from_queue_sum">Automatically remove an episode from the queue when it is deleted.</string> <!-- Auto-Flattr dialog --> <string name="auto_flattr_enable">Enable automatic flattring</string> |