diff --git a/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java b/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java index 5396b218d..1d2e3d9e8 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/AutoDownloadTest.java @@ -4,14 +4,12 @@ import android.content.Context; import androidx.annotation.NonNull; import androidx.test.core.app.ApplicationProvider; import de.danoeh.antennapod.core.ClientConfig; -import de.danoeh.antennapod.core.DBTasksCallbacks; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm; import de.danoeh.antennapod.core.storage.DBReader; -import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm; import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter; import de.test.antennapod.EspressoTestUtils; import de.test.antennapod.ui.UITestUtils; @@ -32,7 +30,7 @@ public class AutoDownloadTest { private Context context; private UITestUtils stubFeedsServer; - private DBTasksCallbacks dbTasksCallbacksOrig; + private AutomaticDownloadAlgorithm automaticDownloadAlgorithmOrig; @Before public void setUp() throws Exception { @@ -41,7 +39,7 @@ public class AutoDownloadTest { stubFeedsServer = new UITestUtils(context); stubFeedsServer.setup(); - dbTasksCallbacksOrig = ClientConfig.dbTasksCallbacks; + automaticDownloadAlgorithmOrig = ClientConfig.automaticDownloadAlgorithm; EspressoTestUtils.clearPreferences(); EspressoTestUtils.clearDatabase(); @@ -50,7 +48,7 @@ public class AutoDownloadTest { @After public void tearDown() throws Exception { - ClientConfig.dbTasksCallbacks = dbTasksCallbacksOrig; + ClientConfig.automaticDownloadAlgorithm = automaticDownloadAlgorithmOrig; EspressoTestUtils.tryKillPlaybackService(); stubFeedsServer.tearDown(); } @@ -79,7 +77,7 @@ public class AutoDownloadTest { // Setup: enable automatic download // it is not needed, as the actual automatic download is stubbed. StubDownloadAlgorithm stubDownloadAlgorithm = new StubDownloadAlgorithm(); - useDownloadAlgorithm(stubDownloadAlgorithm); + ClientConfig.automaticDownloadAlgorithm = stubDownloadAlgorithm; // Actual test // Play the first one in the queue @@ -113,20 +111,6 @@ public class AutoDownloadTest { .until(() -> item.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()); } - private void useDownloadAlgorithm(final AutomaticDownloadAlgorithm downloadAlgorithm) { - ClientConfig.dbTasksCallbacks = new DBTasksCallbacks() { - @Override - public AutomaticDownloadAlgorithm getAutomaticDownloadAlgorithm() { - return downloadAlgorithm; - } - - @Override - public EpisodeCleanupAlgorithm getEpisodeCacheCleanupAlgorithm() { - return dbTasksCallbacksOrig.getEpisodeCacheCleanupAlgorithm(); - } - }; - } - private static class StubDownloadAlgorithm implements AutomaticDownloadAlgorithm { private long currentlyPlaying = -1; diff --git a/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java b/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java index 6e584d34f..7a5cf431f 100644 --- a/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java +++ b/app/src/main/java/de/danoeh/antennapod/config/ClientConfigurator.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.config; import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.core.ClientConfig; +import de.danoeh.antennapod.core.storage.APDownloadAlgorithm; /** * Configures the ClientConfig class of the core package. @@ -15,7 +16,7 @@ class ClientConfigurator { ClientConfig.applicationCallbacks = new ApplicationCallbacksImpl(); ClientConfig.downloadServiceCallbacks = new DownloadServiceCallbacksImpl(); ClientConfig.playbackServiceCallbacks = new PlaybackServiceCallbacksImpl(); - ClientConfig.dbTasksCallbacks = new DBTasksCallbacksImpl(); + ClientConfig.automaticDownloadAlgorithm = new APDownloadAlgorithm(); ClientConfig.castCallbacks = new CastCallbackImpl(); } } diff --git a/app/src/main/java/de/danoeh/antennapod/config/DBTasksCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/DBTasksCallbacksImpl.java deleted file mode 100644 index c3f7ae9c8..000000000 --- a/app/src/main/java/de/danoeh/antennapod/config/DBTasksCallbacksImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.danoeh.antennapod.config; - -import de.danoeh.antennapod.core.DBTasksCallbacks; -import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.storage.APDownloadAlgorithm; -import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm; -import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm; - -public class DBTasksCallbacksImpl implements DBTasksCallbacks { - - @Override - public AutomaticDownloadAlgorithm getAutomaticDownloadAlgorithm() { - return new APDownloadAlgorithm(); - } - - @Override - public EpisodeCleanupAlgorithm getEpisodeCacheCleanupAlgorithm() { - return UserPreferences.getEpisodeCleanupAlgorithm(); - } -} diff --git a/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java b/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java index 04d74f2a2..8fd1df35c 100644 --- a/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java +++ b/core/src/free/java/de/danoeh/antennapod/core/ClientConfig.java @@ -9,6 +9,7 @@ import de.danoeh.antennapod.core.preferences.SleepTimerPreferences; import de.danoeh.antennapod.core.preferences.UsageStatistics; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.AntennapodHttpClient; +import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm; import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.core.util.gui.NotificationUtils; @@ -32,7 +33,7 @@ public class ClientConfig { public static PlaybackServiceCallbacks playbackServiceCallbacks; - public static DBTasksCallbacks dbTasksCallbacks; + public static AutomaticDownloadAlgorithm automaticDownloadAlgorithm; public static CastCallbacks castCallbacks; diff --git a/core/src/main/java/de/danoeh/antennapod/core/DBTasksCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/DBTasksCallbacks.java deleted file mode 100644 index 11a6b2c9f..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/DBTasksCallbacks.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.danoeh.antennapod.core; - -import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm; -import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm; - -/** - * Callbacks for the DBTasks class of the storage module. - */ -public interface DBTasksCallbacks { - - /** - * Returns the client's implementation of the AutomaticDownloadAlgorithm interface. - */ - AutomaticDownloadAlgorithm getAutomaticDownloadAlgorithm(); - - /** - * Returns the client's implementation of the EpisodeCacheCleanupAlgorithm interface. - */ - EpisodeCleanupAlgorithm getEpisodeCacheCleanupAlgorithm(); -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index de106a01e..a0e1a7041 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -429,7 +429,7 @@ public class DownloadService extends Service { + ", cleanupMedia=" + cleanupMedia); if (cleanupMedia) { - ClientConfig.dbTasksCallbacks.getEpisodeCacheCleanupAlgorithm() + UserPreferences.getEpisodeCleanupAlgorithm() .makeRoomForEpisodes(getApplicationContext(), requests.size()); } 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 c059e696a..e857cf610 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 @@ -290,7 +290,7 @@ public final class DBTasks { */ public static Future autodownloadUndownloadedItems(final Context context) { Log.d(TAG, "autodownloadUndownloadedItems"); - return autodownloadExec.submit(ClientConfig.dbTasksCallbacks.getAutomaticDownloadAlgorithm() + return autodownloadExec.submit(ClientConfig.automaticDownloadAlgorithm .autoDownloadUndownloadedItems(context)); } @@ -304,7 +304,7 @@ public final class DBTasks { * @param context Used for accessing the DB. */ public static void performAutoCleanup(final Context context) { - ClientConfig.dbTasksCallbacks.getEpisodeCacheCleanupAlgorithm().performCleanup(context); + UserPreferences.getEpisodeCleanupAlgorithm().performCleanup(context); } /** diff --git a/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java b/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java index 41e95d99e..4b5e4d588 100644 --- a/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java +++ b/core/src/play/java/de/danoeh/antennapod/core/ClientConfig.java @@ -12,6 +12,7 @@ import de.danoeh.antennapod.core.preferences.SleepTimerPreferences; import de.danoeh.antennapod.core.preferences.UsageStatistics; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.AntennapodHttpClient; +import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm; import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.core.util.gui.NotificationUtils; @@ -38,7 +39,7 @@ public class ClientConfig { public static PlaybackServiceCallbacks playbackServiceCallbacks; - public static DBTasksCallbacks dbTasksCallbacks; + public static AutomaticDownloadAlgorithm automaticDownloadAlgorithm; public static CastCallbacks castCallbacks;