From a1f81d4144bacc01ed7f65efc3daaa063c8f32d6 Mon Sep 17 00:00:00 2001 From: Petar Kukolj Date: Thu, 29 Nov 2018 21:23:36 +0100 Subject: Add delete option to episode's context menu This PR makes following changes: - Adds delete option to episode's context menus in queue and feed list - Adds a storage preference that allows episodes to be automatically removed from queue when they are deleted (by clicking delete in context menu, or pressing trash can icon on `Completed` tab of `Downloads` page) - Adds a test for the aforementioned preference --- .../java/de/danoeh/antennapod/core/preferences/UserPreferences.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/src/main/java') 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 c44999c88..791ecfa1b 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"; @@ -309,6 +310,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); } -- cgit v1.2.3 From b53a3c2ecf32a2bbfaa33b886e31c04f3e0cb8ba Mon Sep 17 00:00:00 2001 From: Petar Kukolj Date: Sun, 2 Dec 2018 23:17:56 +0100 Subject: Move "Delete Removes from Queue" logic to DBWriter --- .../danoeh/antennapod/core/storage/DBWriter.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'core/src/main/java') 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..23ed04866 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); @@ -136,6 +130,20 @@ 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) { + if (UserPreferences.shouldDeleteRemoveFromQueue()) { + DBWriter.removeQueueItem(context, DBReader.getFeedMedia(mediaId).getItem(), false); + } + return doDeleteFeedMediaOfItem(context, mediaId); + } + /** * Deletes a Feed and all downloaded files of its components like images and downloaded episodes. * -- cgit v1.2.3 From ebc02009682d8ad0c724ed3f6d13f97e6668b622 Mon Sep 17 00:00:00 2001 From: Petar Kukolj Date: Thu, 3 Jan 2019 22:50:30 +0100 Subject: Fix a style issue and fix the test --- core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/src/main/java') 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 23ed04866..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 @@ -138,10 +138,11 @@ public class DBWriter { */ 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 doDeleteFeedMediaOfItem(context, mediaId); + return res; } /** -- cgit v1.2.3