From 2fd73b148d012fba7308c86494689103b8aaace4 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 29 Mar 2024 19:27:53 +0100 Subject: [PATCH] Move download service to module (#7041) --- app/build.gradle | 4 ++ .../service/download/HttpDownloaderTest.java | 4 +- app/src/main/AndroidManifest.xml | 2 +- .../antennapod}/ClientConfigurator.java | 6 +-- .../java/de/danoeh/antennapod/PodcastApp.java | 1 - .../antennapod/activity/MainActivity.java | 2 +- .../activity/OnlineFeedViewActivity.java | 6 +-- .../receiver/ConnectivityActionReceiver.java | 2 +- .../receiver/PowerConnectionReceiver.java | 2 +- .../antennapod/receiver/SPAReceiver.java | 2 +- core/build.gradle | 6 --- .../core/receiver/FeedUpdateReceiver.java | 3 -- .../core/receiver/MediaButtonReceiver.java | 3 -- core/src/main/res/values/ids.xml | 4 -- .../core/util/FilenameGeneratorTest.java | 1 + net/download/service-interface/build.gradle | 3 ++ .../DownloadRequestCreator.java | 9 ++-- .../serviceinterface}/FileNameGenerator.java | 2 +- net/download/service/README.md | 3 ++ net/download/service/build.gradle | 47 ++++++++++++++++++ .../service/src/main/AndroidManifest.xml | 7 +++ .../episode}/EpisodeDownloadWorker.java | 10 ++-- .../episode}/MediaDownloadedHandler.java | 2 +- .../feed}/DownloadServiceInterfaceImpl.java | 3 +- .../service/feed}/FeedUpdateManagerImpl.java | 3 +- .../service/feed}/FeedUpdateWorker.java | 22 ++++---- .../feed}/NewEpisodesNotification.java | 2 +- .../service/feed/local}/FastDocumentFile.java | 2 +- .../service/feed/local}/LocalFeedUpdater.java | 5 +- .../remote}/DefaultDownloaderFactory.java | 2 +- .../service/feed/remote}/Downloader.java | 4 +- .../feed/remote}/DownloaderFactory.java | 2 +- .../service/feed/remote}/FeedParserTask.java | 3 +- .../service/feed/remote}/HttpDownloader.java | 7 +-- .../feed/remote}/InvalidFeedException.java | 2 +- .../service/src/main/res/values/ids.xml | 6 +++ .../src/test/assets/local-feed1/track1.mp3 | Bin .../src/test/assets/local-feed2/folder.png | Bin .../src/test/assets/local-feed2/track1.mp3 | Bin .../src/test/assets/local-feed2/track2.mp3 | Bin .../feed/local}/LocalFeedUpdaterTest.java | 9 ++-- settings.gradle | 1 + storage/importexport/build.gradle | 1 + .../importexport}/OpmlBackupAgent.java | 5 +- .../res/drawable/ic_notification_cancel.xml | 5 ++ .../GpodderAuthenticationFragment.java | 3 +- 46 files changed, 134 insertions(+), 84 deletions(-) rename {core/src/main/java/de/danoeh/antennapod/core => app/src/main/java/de/danoeh/antennapod}/ClientConfigurator.java (93%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface}/DownloadRequestCreator.java (95%) rename {core/src/main/java/de/danoeh/antennapod/core/util => net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface}/FileNameGenerator.java (97%) create mode 100644 net/download/service/README.md create mode 100644 net/download/service/build.gradle create mode 100644 net/download/service/src/main/AndroidManifest.xml rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode}/EpisodeDownloadWorker.java (97%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download/handler => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode}/MediaDownloadedHandler.java (98%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed}/DownloadServiceInterfaceImpl.java (97%) rename {core/src/main/java/de/danoeh/antennapod/core/util/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed}/FeedUpdateManagerImpl.java (98%) rename {core/src/main/java/de/danoeh/antennapod/core/service => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed}/FeedUpdateWorker.java (91%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed}/NewEpisodesNotification.java (99%) rename {core/src/main/java/de/danoeh/antennapod/core/util => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local}/FastDocumentFile.java (97%) rename {core/src/main/java/de/danoeh/antennapod/core/feed => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local}/LocalFeedUpdater.java (98%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote}/DefaultDownloaderFactory.java (91%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote}/Downloader.java (92%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote}/DownloaderFactory.java (79%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download/handler => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote}/FeedParserTask.java (97%) rename {core/src/main/java/de/danoeh/antennapod/core/service/download => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote}/HttpDownloader.java (98%) rename {core/src/main/java/de/danoeh/antennapod/core/util => net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote}/InvalidFeedException.java (79%) create mode 100644 net/download/service/src/main/res/values/ids.xml rename {core => net/download/service}/src/test/assets/local-feed1/track1.mp3 (100%) rename {core => net/download/service}/src/test/assets/local-feed2/folder.png (100%) rename {core => net/download/service}/src/test/assets/local-feed2/track1.mp3 (100%) rename {core => net/download/service}/src/test/assets/local-feed2/track2.mp3 (100%) rename {core/src/test/java/de/danoeh/antennapod/core/feed => net/download/service/src/test/java/de/danoeh/antennapod/net/download/service/feed/local}/LocalFeedUpdaterTest.java (98%) rename {core/src/main/java/de/danoeh/antennapod/core/backup => storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport}/OpmlBackupAgent.java (96%) create mode 100644 ui/notifications/src/main/res/drawable/ic_notification_cancel.xml diff --git a/app/build.gradle b/app/build.gradle index 84866a9e2..150c8a584 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -68,7 +68,10 @@ dependencies { implementation project(':net:common') implementation project(':net:discovery') implementation project(':net:download:service-interface') + implementation project(':net:download:service') + implementation project(':net:ssl') implementation project(':net:sync:gpoddernet') + implementation project(':net:sync:service') implementation project(':net:sync:model') implementation project(':parser:feed') implementation project(':playback:base') @@ -83,6 +86,7 @@ dependencies { implementation project(':ui:episodes') implementation project(':ui:glide') implementation project(':ui:i18n') + implementation project(':ui:notifications') implementation project(':ui:widget') implementation project(':ui:preferences') implementation project(':ui:statistics') diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java index dcd27d3b4..19dd55f85 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java @@ -8,11 +8,11 @@ import java.io.File; import java.io.IOException; import de.danoeh.antennapod.model.feed.Feed; +import de.danoeh.antennapod.net.download.service.feed.remote.Downloader; +import de.danoeh.antennapod.net.download.service.feed.remote.HttpDownloader; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.model.download.DownloadRequest; import de.danoeh.antennapod.model.download.DownloadResult; -import de.danoeh.antennapod.core.service.download.Downloader; -import de.danoeh.antennapod.core.service.download.HttpDownloader; import de.danoeh.antennapod.model.download.DownloadError; import de.test.antennapod.util.service.download.HTTPBin; import org.junit.After; diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b4323f782..66f0b8766 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,7 +33,7 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:label="@string/app_name" - android:backupAgent=".core.backup.OpmlBackupAgent" + android:backupAgent=".storage.importexport.OpmlBackupAgent" android:restoreAnyVersion="true" android:theme="@style/Theme.AntennaPod.Splash" android:usesCleartextTraffic="true" diff --git a/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java b/app/src/main/java/de/danoeh/antennapod/ClientConfigurator.java similarity index 93% rename from core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java rename to app/src/main/java/de/danoeh/antennapod/ClientConfigurator.java index 8b5f9f286..a0cf4bfc9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java +++ b/app/src/main/java/de/danoeh/antennapod/ClientConfigurator.java @@ -1,10 +1,10 @@ -package de.danoeh.antennapod.core; +package de.danoeh.antennapod; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import de.danoeh.antennapod.core.storage.AutoDownloadManagerImpl; -import de.danoeh.antennapod.core.util.download.FeedUpdateManagerImpl; +import de.danoeh.antennapod.net.download.service.feed.FeedUpdateManagerImpl; import de.danoeh.antennapod.net.download.serviceinterface.AutoDownloadManager; import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.net.sync.service.SyncService; @@ -18,7 +18,7 @@ import de.danoeh.antennapod.net.common.UserAgentInterceptor; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.net.common.AntennapodHttpClient; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterfaceImpl; +import de.danoeh.antennapod.net.download.service.feed.DownloadServiceInterfaceImpl; import de.danoeh.antennapod.net.common.NetworkUtils; import de.danoeh.antennapod.core.util.download.NetworkConnectionChangeHandler; import de.danoeh.antennapod.net.ssl.SslProviderInstaller; diff --git a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java index 34672141c..7052fa8b5 100644 --- a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java +++ b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java @@ -6,7 +6,6 @@ import android.os.StrictMode; import com.google.android.material.color.DynamicColors; import de.danoeh.antennapod.core.ApCoreEventBusIndex; -import de.danoeh.antennapod.core.ClientConfigurator; import de.danoeh.antennapod.error.CrashReportWriter; import de.danoeh.antennapod.error.RxJavaErrorHandlerSetup; import de.danoeh.antennapod.preferences.PreferenceUpgrader; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index ee8a80caf..32884c9c9 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -35,7 +35,7 @@ import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.util.download.FeedUpdateManagerImpl; +import de.danoeh.antennapod.net.download.service.feed.FeedUpdateManagerImpl; import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.net.sync.serviceinterface.SynchronizationQueueSink; import de.danoeh.antennapod.ui.appstartintent.MediaButtonStarter; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 4ad11588b..02b847059 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -28,9 +28,11 @@ import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter; +import de.danoeh.antennapod.net.download.service.feed.remote.Downloader; +import de.danoeh.antennapod.net.download.service.feed.remote.HttpDownloader; import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter; import de.danoeh.antennapod.ui.common.ThemeSwitcher; -import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequestCreator; import de.danoeh.antennapod.net.discovery.FeedUrlNotFoundException; import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; @@ -45,8 +47,6 @@ import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterfa import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.model.download.DownloadRequest; import de.danoeh.antennapod.model.download.DownloadResult; -import de.danoeh.antennapod.core.service.download.Downloader; -import de.danoeh.antennapod.core.service.download.HttpDownloader; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.net.discovery.CombinedSearcher; diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java b/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java index 3d7344b9b..100869120 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java @@ -7,7 +7,7 @@ import android.net.ConnectivityManager; import android.text.TextUtils; import android.util.Log; -import de.danoeh.antennapod.core.ClientConfigurator; +import de.danoeh.antennapod.ClientConfigurator; import de.danoeh.antennapod.core.util.download.NetworkConnectionChangeHandler; public class ConnectivityActionReceiver extends BroadcastReceiver { diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java index 641355d5c..6e179647e 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java @@ -5,7 +5,7 @@ import android.content.Context; import android.content.Intent; import android.util.Log; -import de.danoeh.antennapod.core.ClientConfigurator; +import de.danoeh.antennapod.ClientConfigurator; import de.danoeh.antennapod.net.download.serviceinterface.AutoDownloadManager; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java b/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java index a48ee117b..1628229be 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java @@ -11,7 +11,7 @@ import java.util.Arrays; import java.util.Collections; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.ClientConfigurator; +import de.danoeh.antennapod.ClientConfigurator; import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.model.feed.Feed; diff --git a/core/build.gradle b/core/build.gradle index b2fffa68b..f7d736968 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -27,22 +27,16 @@ dependencies { implementation project(':model') implementation project(':net:common') implementation project(':net:download:service-interface') - implementation project(':net:ssl') - implementation project(':net:sync:gpoddernet') - implementation project(':net:sync:model') - implementation project(':net:sync:service') implementation project(':net:sync:service-interface') implementation project(':parser:feed') implementation project(':parser:media') implementation project(':playback:base') implementation project(':playback:cast') implementation project(':storage:database') - implementation project(':storage:importexport') implementation project(':storage:preferences') implementation project(':ui:app-start-intent') implementation project(':ui:common') implementation project(':ui:episodes') - implementation project(':ui:i18n') implementation project(':ui:notifications') implementation project(':ui:widget') diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java index 098c9bfa4..6b9644c41 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java +++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java @@ -5,7 +5,6 @@ import android.content.Context; import android.content.Intent; import android.util.Log; -import de.danoeh.antennapod.core.ClientConfigurator; import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; /** @@ -18,8 +17,6 @@ public class FeedUpdateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Received intent"); - ClientConfigurator.initialize(context); - FeedUpdateManager.getInstance().runOnce(context); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java index 8721ebb35..20621fd45 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java +++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/MediaButtonReceiver.java @@ -7,8 +7,6 @@ import androidx.core.content.ContextCompat; import android.util.Log; import android.view.KeyEvent; -import de.danoeh.antennapod.core.ClientConfigurator; - /** * Receives media button events. */ @@ -30,7 +28,6 @@ public class MediaButtonReceiver extends BroadcastReceiver { } KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { - ClientConfigurator.initialize(context); Intent serviceIntent = new Intent(PLAYBACK_SERVICE_INTENT); serviceIntent.setPackage(context.getPackageName()); serviceIntent.putExtra(EXTRA_KEYCODE, event.getKeyCode()); diff --git a/core/src/main/res/values/ids.xml b/core/src/main/res/values/ids.xml index 7bb78c1c9..8678b4413 100644 --- a/core/src/main/res/values/ids.xml +++ b/core/src/main/res/values/ids.xml @@ -16,10 +16,6 @@ - - - - \ No newline at end of file diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/FilenameGeneratorTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/FilenameGeneratorTest.java index af22a4b9d..4c225322a 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/util/FilenameGeneratorTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/util/FilenameGeneratorTest.java @@ -5,6 +5,7 @@ import android.text.TextUtils; import java.io.File; +import de.danoeh.antennapod.net.download.serviceinterface.FileNameGenerator; import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/net/download/service-interface/build.gradle b/net/download/service-interface/build.gradle index 84a8dfd05..a6ecd8c58 100644 --- a/net/download/service-interface/build.gradle +++ b/net/download/service-interface/build.gradle @@ -16,8 +16,11 @@ android { dependencies { implementation project(':model') implementation project(':net:common') + implementation project(':storage:preferences') annotationProcessor "androidx.annotation:annotation:$annotationVersion" + implementation "org.apache.commons:commons-lang3:$commonslangVersion" + implementation "commons-io:commons-io:$commonsioVersion" testImplementation "junit:junit:$junitVersion" testImplementation "org.robolectric:robolectric:$robolectricVersion" diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequestCreator.java b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequestCreator.java similarity index 95% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequestCreator.java rename to net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequestCreator.java index 3e94e9f6b..c0d70523c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequestCreator.java +++ b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequestCreator.java @@ -1,12 +1,10 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.serviceinterface; import android.util.Log; import android.webkit.URLUtil; -import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequestBuilder; -import de.danoeh.antennapod.storage.preferences.UserPreferences; -import de.danoeh.antennapod.core.util.FileNameGenerator; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedMedia; +import de.danoeh.antennapod.storage.preferences.UserPreferences; import org.apache.commons.io.FilenameUtils; import java.io.File; @@ -22,7 +20,8 @@ public class DownloadRequestCreator { public static DownloadRequestBuilder create(Feed feed) { File dest = new File(getFeedfilePath(), getFeedfileName(feed)); if (dest.exists()) { - dest.delete(); + boolean deleted = dest.delete(); + Log.d(TAG, "deleted" + dest.getPath() + ": " + deleted); } Log.d(TAG, "Requesting download of url " + feed.getDownloadUrl()); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/FileNameGenerator.java b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/FileNameGenerator.java similarity index 97% rename from core/src/main/java/de/danoeh/antennapod/core/util/FileNameGenerator.java rename to net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/FileNameGenerator.java index 69c23efc2..85e73836f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/FileNameGenerator.java +++ b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/FileNameGenerator.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.util; +package de.danoeh.antennapod.net.download.serviceinterface; import android.text.TextUtils; diff --git a/net/download/service/README.md b/net/download/service/README.md new file mode 100644 index 000000000..ecee50402 --- /dev/null +++ b/net/download/service/README.md @@ -0,0 +1,3 @@ +# :net:download:service + +The download service. diff --git a/net/download/service/build.gradle b/net/download/service/build.gradle new file mode 100644 index 000000000..75d6b26de --- /dev/null +++ b/net/download/service/build.gradle @@ -0,0 +1,47 @@ +plugins { + id("com.android.library") + id("java-test-fixtures") +} +apply from: "../../../common.gradle" +apply from: "../../../playFlavor.gradle" + +android { + namespace "de.danoeh.antennapod.net.download.service" +} + +dependencies { + implementation project(":core") + implementation project(':event') + implementation project(':model') + implementation project(':net:common') + implementation project(':net:download:service-interface') + implementation project(':net:sync:model') + implementation project(':net:sync:service-interface') + implementation project(':parser:media') + implementation project(':parser:feed') + implementation project(':storage:database') + implementation project(':ui:notifications') + implementation project(':storage:preferences') + implementation project(':ui:app-start-intent') + + annotationProcessor "androidx.annotation:annotation:$annotationVersion" + implementation "androidx.core:core:$coreVersion" + implementation 'androidx.documentfile:documentfile:1.0.1' + implementation "androidx.work:work-runtime:$workManagerVersion" + implementation "com.google.android.material:material:$googleMaterialVersion" + + implementation "com.squareup.okhttp3:okhttp:$okhttpVersion" + implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVersion" + implementation "commons-io:commons-io:$commonsioVersion" + implementation "org.apache.commons:commons-lang3:$commonslangVersion" + implementation "org.greenrobot:eventbus:$eventbusVersion" + implementation "com.github.bumptech.glide:glide:$glideVersion" + implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion" + implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion" + implementation "com.google.guava:guava:31.0.1-android" + + testImplementation "junit:junit:$junitVersion" + testImplementation "org.robolectric:robolectric:$robolectricVersion" + testImplementation "org.awaitility:awaitility:$awaitilityVersion" + testImplementation 'org.mockito:mockito-core:5.11.0' +} diff --git a/net/download/service/src/main/AndroidManifest.xml b/net/download/service/src/main/AndroidManifest.xml new file mode 100644 index 000000000..1319b5274 --- /dev/null +++ b/net/download/service/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/EpisodeDownloadWorker.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java similarity index 97% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/EpisodeDownloadWorker.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java index a2b4ed100..ff548c039 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/EpisodeDownloadWorker.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/EpisodeDownloadWorker.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.service.episode; import android.Manifest; import android.app.Notification; @@ -19,9 +19,10 @@ import androidx.work.Worker; import androidx.work.WorkerParameters; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import de.danoeh.antennapod.core.ClientConfigurator; -import de.danoeh.antennapod.core.R; -import de.danoeh.antennapod.core.service.download.handler.MediaDownloadedHandler; +import de.danoeh.antennapod.net.download.service.R; +import de.danoeh.antennapod.net.download.service.feed.remote.DefaultDownloaderFactory; +import de.danoeh.antennapod.net.download.service.feed.remote.Downloader; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequestCreator; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.event.MessageEvent; @@ -55,7 +56,6 @@ public class EpisodeDownloadWorker extends Worker { @Override @NonNull public Result doWork() { - ClientConfigurator.initialize(getApplicationContext()); long mediaId = getInputData().getLong(DownloadServiceInterface.WORK_DATA_MEDIA_ID, 0); FeedMedia media = DBReader.getFeedMedia(mediaId); if (media == null) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/MediaDownloadedHandler.java similarity index 98% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/MediaDownloadedHandler.java index 24b157c88..dd930c62f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/episode/MediaDownloadedHandler.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download.handler; +package de.danoeh.antennapod.net.download.service.episode; import android.content.Context; import android.media.MediaMetadataRetriever; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceImpl.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/DownloadServiceInterfaceImpl.java similarity index 97% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceImpl.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/DownloadServiceInterfaceImpl.java index e2489b493..37a7f30e0 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceImpl.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/DownloadServiceInterfaceImpl.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.service.feed; import android.content.Context; import androidx.work.Constraints; @@ -9,6 +9,7 @@ import androidx.work.OneTimeWorkRequest; import androidx.work.OutOfQuotaPolicy; import androidx.work.WorkInfo; import androidx.work.WorkManager; +import de.danoeh.antennapod.net.download.service.episode.EpisodeDownloadWorker; import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/download/FeedUpdateManagerImpl.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/FeedUpdateManagerImpl.java similarity index 98% rename from core/src/main/java/de/danoeh/antennapod/core/util/download/FeedUpdateManagerImpl.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/FeedUpdateManagerImpl.java index 17077c237..ae9b25564 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/download/FeedUpdateManagerImpl.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/FeedUpdateManagerImpl.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.util.download; +package de.danoeh.antennapod.net.download.service.feed; import android.content.Context; import android.util.Log; @@ -15,7 +15,6 @@ import androidx.work.PeriodicWorkRequest; import androidx.work.WorkManager; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import de.danoeh.antennapod.core.R; -import de.danoeh.antennapod.core.service.FeedUpdateWorker; import de.danoeh.antennapod.net.common.NetworkUtils; import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.model.feed.Feed; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/FeedUpdateWorker.java similarity index 91% rename from core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/FeedUpdateWorker.java index e5828ac6e..d12249f11 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/FeedUpdateWorker.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service; +package de.danoeh.antennapod.net.download.service.feed; import android.Manifest; import android.app.Notification; @@ -16,16 +16,13 @@ import androidx.work.Worker; import androidx.work.WorkerParameters; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import de.danoeh.antennapod.core.ClientConfigurator; -import de.danoeh.antennapod.core.R; -import de.danoeh.antennapod.core.feed.LocalFeedUpdater; -import de.danoeh.antennapod.core.service.download.DefaultDownloaderFactory; -import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.Downloader; -import de.danoeh.antennapod.core.service.download.NewEpisodesNotification; -import de.danoeh.antennapod.core.service.download.handler.FeedParserTask; -import de.danoeh.antennapod.core.util.download.FeedUpdateManagerImpl; +import de.danoeh.antennapod.net.download.service.R; +import de.danoeh.antennapod.net.download.service.feed.local.LocalFeedUpdater; +import de.danoeh.antennapod.net.download.service.feed.remote.DefaultDownloaderFactory; +import de.danoeh.antennapod.net.download.service.feed.remote.Downloader; +import de.danoeh.antennapod.net.download.service.feed.remote.FeedParserTask; import de.danoeh.antennapod.net.download.serviceinterface.AutoDownloadManager; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequestCreator; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.storage.database.DBWriter; @@ -58,7 +55,6 @@ public class FeedUpdateWorker extends Worker { @Override @NonNull public Result doWork() { - ClientConfigurator.initialize(getApplicationContext()); newEpisodesNotification.loadCountersBeforeRefresh(); List toUpdate; @@ -125,14 +121,14 @@ public class FeedUpdateWorker extends Worker { .setStyle(new NotificationCompat.BigTextStyle().bigText(bigText)) .setSmallIcon(R.drawable.ic_notification_sync) .setOngoing(true) - .addAction(R.drawable.ic_cancel, context.getString(R.string.cancel_label), + .addAction(R.drawable.ic_notification_cancel, context.getString(R.string.cancel_label), WorkManager.getInstance(context).createCancelPendingIntent(getId())) .build(); } @NonNull @Override - public ListenableFuture getForegroundInfoAsync() { + public ListenableFuture getForegroundInfoAsync() { return Futures.immediateFuture(new ForegroundInfo(R.id.notification_updating_feeds, createNotification(null))); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/NewEpisodesNotification.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/NewEpisodesNotification.java similarity index 99% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/NewEpisodesNotification.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/NewEpisodesNotification.java index eff5816be..e326601ce 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/NewEpisodesNotification.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/NewEpisodesNotification.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.service.feed; import android.Manifest; import android.app.Notification; diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/FastDocumentFile.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local/FastDocumentFile.java similarity index 97% rename from core/src/main/java/de/danoeh/antennapod/core/util/FastDocumentFile.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local/FastDocumentFile.java index a86bf0bcf..13cfaa4bf 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/FastDocumentFile.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local/FastDocumentFile.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.util; +package de.danoeh.antennapod.net.download.service.feed.local; import android.content.Context; import android.database.Cursor; diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local/LocalFeedUpdater.java similarity index 98% rename from core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local/LocalFeedUpdater.java index 8230924f9..015cd9146 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/local/LocalFeedUpdater.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.feed; +package de.danoeh.antennapod.net.download.service.feed.local; import android.content.Context; import android.media.MediaMetadataRetriever; @@ -26,10 +26,9 @@ import java.util.UUID; import androidx.annotation.VisibleForTesting; import androidx.documentfile.provider.DocumentFile; -import de.danoeh.antennapod.core.R; -import de.danoeh.antennapod.core.util.FastDocumentFile; import de.danoeh.antennapod.model.MediaMetadataRetrieverCompat; import de.danoeh.antennapod.model.download.DownloadResult; +import de.danoeh.antennapod.net.download.service.R; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.storage.database.DBWriter; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DefaultDownloaderFactory.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/DefaultDownloaderFactory.java similarity index 91% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/DefaultDownloaderFactory.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/DefaultDownloaderFactory.java index a1cc9bf6d..b87e339e3 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DefaultDownloaderFactory.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/DefaultDownloaderFactory.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.service.feed.remote; import android.util.Log; import android.webkit.URLUtil; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/Downloader.java similarity index 92% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/Downloader.java index 7010d61ba..329b42805 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/Downloader.java @@ -1,13 +1,13 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.service.feed.remote; import androidx.annotation.NonNull; import java.util.Date; import java.util.concurrent.Callable; -import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.model.download.DownloadResult; import de.danoeh.antennapod.model.download.DownloadRequest; +import de.danoeh.antennapod.net.download.service.R; /** * Downloads files diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloaderFactory.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/DownloaderFactory.java similarity index 79% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/DownloaderFactory.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/DownloaderFactory.java index 45ad45381..cdf32b4a9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloaderFactory.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/DownloaderFactory.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.service.feed.remote; import androidx.annotation.NonNull; import androidx.annotation.Nullable; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/FeedParserTask.java similarity index 97% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/FeedParserTask.java index 37775ab94..dde7bc8b5 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/FeedParserTask.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download.handler; +package de.danoeh.antennapod.net.download.service.feed.remote; import android.text.TextUtils; import android.util.Log; @@ -13,7 +13,6 @@ import de.danoeh.antennapod.parser.feed.FeedHandler; import de.danoeh.antennapod.parser.feed.FeedHandlerResult; import de.danoeh.antennapod.parser.feed.UnsupportedFeedtypeException; import de.danoeh.antennapod.model.download.DownloadError; -import de.danoeh.antennapod.core.util.InvalidFeedException; import org.xml.sax.SAXException; import javax.xml.parsers.ParserConfigurationException; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/HttpDownloader.java similarity index 98% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/HttpDownloader.java index 5e2a82f33..f3c3e657c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/HttpDownloader.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.service.feed.remote; import androidx.annotation.NonNull; import android.text.TextUtils; @@ -8,6 +8,7 @@ import de.danoeh.antennapod.net.common.NetworkUtils; import de.danoeh.antennapod.model.download.DownloadResult; import de.danoeh.antennapod.model.download.DownloadRequest; import de.danoeh.antennapod.net.common.AntennapodHttpClient; +import de.danoeh.antennapod.net.download.service.R; import okhttp3.CacheControl; import okhttp3.internal.http.StatusLine; import org.apache.commons.io.IOUtils; @@ -24,8 +25,8 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.Locale; -import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.parser.feed.util.DateUtils; import de.danoeh.antennapod.model.download.DownloadError; @@ -98,7 +99,7 @@ public class HttpDownloader extends Downloader { String contentEncodingHeader = response.header("Content-Encoding"); boolean isGzip = false; if (!TextUtils.isEmpty(contentEncodingHeader)) { - isGzip = TextUtils.equals(contentEncodingHeader.toLowerCase(), "gzip"); + isGzip = TextUtils.equals(contentEncodingHeader.toLowerCase(Locale.US), "gzip"); } Log.d(TAG, "Response code is " + response.code()); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/InvalidFeedException.java similarity index 79% rename from core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java rename to net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/InvalidFeedException.java index a45136432..353b86406 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java +++ b/net/download/service/src/main/java/de/danoeh/antennapod/net/download/service/feed/remote/InvalidFeedException.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.util; +package de.danoeh.antennapod.net.download.service.feed.remote; /** * Thrown if a feed has invalid attribute values. diff --git a/net/download/service/src/main/res/values/ids.xml b/net/download/service/src/main/res/values/ids.xml new file mode 100644 index 000000000..cfd4c941b --- /dev/null +++ b/net/download/service/src/main/res/values/ids.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/core/src/test/assets/local-feed1/track1.mp3 b/net/download/service/src/test/assets/local-feed1/track1.mp3 similarity index 100% rename from core/src/test/assets/local-feed1/track1.mp3 rename to net/download/service/src/test/assets/local-feed1/track1.mp3 diff --git a/core/src/test/assets/local-feed2/folder.png b/net/download/service/src/test/assets/local-feed2/folder.png similarity index 100% rename from core/src/test/assets/local-feed2/folder.png rename to net/download/service/src/test/assets/local-feed2/folder.png diff --git a/core/src/test/assets/local-feed2/track1.mp3 b/net/download/service/src/test/assets/local-feed2/track1.mp3 similarity index 100% rename from core/src/test/assets/local-feed2/track1.mp3 rename to net/download/service/src/test/assets/local-feed2/track1.mp3 diff --git a/core/src/test/assets/local-feed2/track2.mp3 b/net/download/service/src/test/assets/local-feed2/track2.mp3 similarity index 100% rename from core/src/test/assets/local-feed2/track2.mp3 rename to net/download/service/src/test/assets/local-feed2/track2.mp3 diff --git a/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java b/net/download/service/src/test/java/de/danoeh/antennapod/net/download/service/feed/local/LocalFeedUpdaterTest.java similarity index 98% rename from core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java rename to net/download/service/src/test/java/de/danoeh/antennapod/net/download/service/feed/local/LocalFeedUpdaterTest.java index 9703894f5..484929136 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java +++ b/net/download/service/src/test/java/de/danoeh/antennapod/net/download/service/feed/local/LocalFeedUpdaterTest.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.feed; +package de.danoeh.antennapod.net.download.service.feed.local; import android.content.Context; import android.media.MediaMetadataRetriever; @@ -11,7 +11,6 @@ import androidx.test.platform.app.InstrumentationRegistry; import de.danoeh.antennapod.storage.preferences.PlaybackPreferences; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterfaceStub; -import de.danoeh.antennapod.core.util.FastDocumentFile; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.storage.database.PodDBAdapter; @@ -37,13 +36,13 @@ import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.DBWriter; -import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.endsWith; +import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.any; +import static org.mockito.ArgumentMatchers.any; import static org.robolectric.Shadows.shadowOf; /** diff --git a/settings.gradle b/settings.gradle index e81206376..8971c4e10 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,6 +23,7 @@ include ':model' include ':net:common' include ':net:discovery' include ':net:download:service-interface' +include ':net:download:service' include ':net:ssl' include ':net:sync:gpoddernet' include ':net:sync:model' diff --git a/storage/importexport/build.gradle b/storage/importexport/build.gradle index dfe5fa535..8f3599dc0 100644 --- a/storage/importexport/build.gradle +++ b/storage/importexport/build.gradle @@ -15,6 +15,7 @@ dependencies { implementation project(':ui:i18n') implementation project(':ui:notifications') implementation project(':model') + implementation project(':net:download:service-interface') annotationProcessor "androidx.annotation:annotation:$annotationVersion" implementation "androidx.core:core:$coreVersion" diff --git a/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java b/storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/OpmlBackupAgent.java similarity index 96% rename from core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java rename to storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/OpmlBackupAgent.java index b30f657a1..4c9256fdc 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java +++ b/storage/importexport/src/main/java/de/danoeh/antennapod/storage/importexport/OpmlBackupAgent.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.backup; +package de.danoeh.antennapod.storage.importexport; import android.app.backup.BackupAgentHelper; import android.app.backup.BackupDataInputStream; @@ -10,9 +10,6 @@ import android.util.Log; import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; -import de.danoeh.antennapod.storage.importexport.OpmlElement; -import de.danoeh.antennapod.storage.importexport.OpmlReader; -import de.danoeh.antennapod.storage.importexport.OpmlWriter; import org.apache.commons.io.IOUtils; import org.xmlpull.v1.XmlPullParserException; diff --git a/ui/notifications/src/main/res/drawable/ic_notification_cancel.xml b/ui/notifications/src/main/res/drawable/ic_notification_cancel.xml new file mode 100644 index 000000000..a5480c71f --- /dev/null +++ b/ui/notifications/src/main/res/drawable/ic_notification_cancel.xml @@ -0,0 +1,5 @@ + + + diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java index 53f620fc3..204287207 100644 --- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java +++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/synchronization/GpodderAuthenticationFragment.java @@ -24,7 +24,6 @@ import de.danoeh.antennapod.net.sync.serviceinterface.SynchronizationProviderVie import de.danoeh.antennapod.net.sync.serviceinterface.SynchronizationQueueSink; import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials; import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; -import de.danoeh.antennapod.core.util.FileNameGenerator; import de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService; import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice; import de.danoeh.antennapod.ui.preferences.R; @@ -215,7 +214,7 @@ public class GpodderAuthenticationFragment extends DialogFragment { private String generateDeviceId(String name) { // devices names must be of a certain form: // https://gpoddernet.readthedocs.org/en/latest/api/reference/general.html#devices - return FileNameGenerator.generateFileName(name).replaceAll("\\W", "_").toLowerCase(Locale.US); + return name.replaceAll("[^a-zA-Z0-9]", "_").toLowerCase(Locale.US); } private boolean isDeviceInList(String name) {