diff --git a/app/build.gradle b/app/build.gradle index fd3cab090..fefff30b1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -81,7 +81,9 @@ dependencies { implementation project(":core") implementation project(":event") implementation project(':model') + implementation project(':net:common') implementation project(':net:discovery') + implementation project(':net:download:service-interface') implementation project(':net:sync:gpoddernet') implementation project(':net:sync:model') implementation project(':parser:feed') diff --git a/app/src/androidTest/java/de/danoeh/antennapod/core/service/download/StubDownloader.java b/app/src/androidTest/java/de/danoeh/antennapod/core/service/download/StubDownloader.java index 6e39967c1..302301c85 100644 --- a/app/src/androidTest/java/de/danoeh/antennapod/core/service/download/StubDownloader.java +++ b/app/src/androidTest/java/de/danoeh/antennapod/core/service/download/StubDownloader.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.service.download; import androidx.annotation.NonNull; import androidx.core.util.Consumer; import de.danoeh.antennapod.model.download.DownloadStatus; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; public class StubDownloader extends Downloader { diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java index 4e255baeb..d61b46b3c 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/download/DownloadServiceTest.java @@ -9,7 +9,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.ext.junit.runners.AndroidJUnit4; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.test.antennapod.EspressoTestUtils; import org.awaitility.Awaitility; import org.awaitility.core.ConditionTimeoutException; @@ -27,7 +27,7 @@ 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.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.core.service.download.Downloader; 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 16e2ca1f4..fe1b9d59c 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 @@ -9,7 +9,7 @@ import java.io.IOException; import de.danoeh.antennapod.model.feed.FeedFile; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.service.download.HttpDownloader; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java index 81756d6c8..a57cf92af 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java @@ -4,11 +4,11 @@ import android.os.Bundle; import android.text.TextUtils; import androidx.appcompat.app.AppCompatActivity; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.feed.FeedPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.dialog.AuthenticationDialog; 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 03b802328..886052e04 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -35,14 +35,14 @@ import de.danoeh.antennapod.core.event.DownloadEvent; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; import de.danoeh.antennapod.core.feed.FeedUrlNotFoundException; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; import de.danoeh.antennapod.core.util.DownloadErrorLabel; import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.PlayerStatusEvent; import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.service.download.HttpDownloader; @@ -55,7 +55,7 @@ import de.danoeh.antennapod.parser.feed.FeedHandler; import de.danoeh.antennapod.parser.feed.FeedHandlerResult; import de.danoeh.antennapod.model.download.DownloadError; import de.danoeh.antennapod.core.util.IntentUtils; -import de.danoeh.antennapod.core.util.URLChecker; +import de.danoeh.antennapod.net.common.UrlChecker; import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer; import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText; import de.danoeh.antennapod.databinding.OnlinefeedviewActivityBinding; @@ -286,7 +286,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity { private void startFeedDownload(String url) { Log.d(TAG, "Starting feed download"); - selectedDownloadUrl = URLChecker.prepareURL(url); + selectedDownloadUrl = UrlChecker.prepareUrl(url); DownloadRequest request = DownloadRequestCreator.create(new Feed(selectedDownloadUrl, null)) .withAuthentication(username, password) .withInitiatedByUser(true) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java index 62c4be051..55f0bf6de 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java @@ -29,7 +29,7 @@ import de.danoeh.antennapod.core.export.opml.OpmlReader; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.databinding.OpmlSelectionBinding; import de.danoeh.antennapod.model.feed.Feed; import io.reactivex.Completable; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java index 4c46b6428..a0d86d5c0 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -11,9 +11,9 @@ import android.widget.Toast; import androidx.core.content.ContextCompat; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/CancelDownloadActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/CancelDownloadActionButton.java index 18127d289..f0b0c8172 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/CancelDownloadActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/CancelDownloadActionButton.java @@ -5,7 +5,7 @@ import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.core.preferences.UserPreferences; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DownloadActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DownloadActionButton.java index 60f55507d..3b54efc03 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DownloadActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DownloadActionButton.java @@ -11,7 +11,7 @@ import androidx.annotation.StringRes; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; import de.danoeh.antennapod.core.service.download.DownloadService; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.core.preferences.UsageStatistics; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MobileDownloadHelper.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MobileDownloadHelper.java index dfabcd0d9..015f46318 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MobileDownloadHelper.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MobileDownloadHelper.java @@ -5,7 +5,7 @@ import android.content.Context; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; diff --git a/app/src/main/java/de/danoeh/antennapod/config/DownloadServiceCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/DownloadServiceCallbacksImpl.java index 120134344..69f112c3b 100644 --- a/app/src/main/java/de/danoeh/antennapod/config/DownloadServiceCallbacksImpl.java +++ b/app/src/main/java/de/danoeh/antennapod/config/DownloadServiceCallbacksImpl.java @@ -10,7 +10,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.DownloadAuthenticationActivity; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.DownloadServiceCallbacks; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.fragment.CompletedDownloadsFragment; import de.danoeh.antennapod.fragment.QueueFragment; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index 3037a8554..08fc71082 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -39,7 +39,7 @@ import de.danoeh.antennapod.adapter.actionbutton.StreamActionButton; import de.danoeh.antennapod.adapter.actionbutton.VisitWebsiteActionButton; import de.danoeh.antennapod.core.event.DownloadEvent; import de.danoeh.antennapod.core.event.DownloaderUpdate; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.util.PlaybackStatus; import de.danoeh.antennapod.event.FeedItemEvent; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/actions/EpisodeMultiSelectActionHandler.java b/app/src/main/java/de/danoeh/antennapod/fragment/actions/EpisodeMultiSelectActionHandler.java index 1103a35d5..e076d35b6 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/actions/EpisodeMultiSelectActionHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/actions/EpisodeMultiSelectActionHandler.java @@ -11,9 +11,9 @@ import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.model.feed.FeedItem; 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 ed873b300..165bc40e5 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java @@ -7,7 +7,7 @@ import android.util.Log; import de.danoeh.antennapod.core.ClientConfigurator; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.storage.DBTasks; // modified from http://developer.android.com/training/monitoring-device-state/battery-monitoring.html 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 0ed60b23e..c566a1fd2 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java @@ -12,7 +12,7 @@ import java.util.Arrays; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.ClientConfigurator; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.model.feed.Feed; /** diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java index 4b83f70ef..112f94063 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java @@ -21,7 +21,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.CoverLoader; import de.danoeh.antennapod.adapter.actionbutton.ItemActionButton; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.util.PlaybackStatus; import de.danoeh.antennapod.core.util.download.MediaSizeLoader; diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java index 60422d74f..5293338b6 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java @@ -12,7 +12,7 @@ import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.CoverLoader; import de.danoeh.antennapod.adapter.actionbutton.ItemActionButton; import de.danoeh.antennapod.core.feed.util.ImageResourceUtils; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.util.DateFormatter; import de.danoeh.antennapod.core.util.PlaybackStatus; diff --git a/core/build.gradle b/core/build.gradle index 887f19b5c..cf34b5c48 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -23,6 +23,8 @@ android { dependencies { implementation project(':event') 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') diff --git a/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java b/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java index b70a3a61a..8dafa8ed8 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/ClientConfigurator.java @@ -6,7 +6,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.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.service.download.DownloadServiceInterfaceImpl; import de.danoeh.antennapod.core.sync.SyncService; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; diff --git a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java index ae9b47629..53ed63c2d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java @@ -3,7 +3,7 @@ package de.danoeh.antennapod.core; import android.app.PendingIntent; import android.content.Context; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; /** * Callbacks for the DownloadService of the core module. diff --git a/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java b/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java index d026e1a7b..9046b7165 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java +++ b/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java @@ -8,9 +8,9 @@ import android.content.Context; import android.os.ParcelFileDescriptor; import android.util.Log; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import org.apache.commons.io.IOUtils; import org.xmlpull.v1.XmlPullParserException; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java b/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java index 53160e242..77a58e682 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java @@ -3,7 +3,7 @@ package de.danoeh.antennapod.core.service; import android.text.TextUtils; import android.util.Log; import androidx.annotation.NonNull; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.HttpCredentialEncoder; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.util.URIUtil; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DefaultDownloaderFactory.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DefaultDownloaderFactory.java index c0de6c825..ff29e2e15 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DefaultDownloaderFactory.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DefaultDownloaderFactory.java @@ -4,6 +4,7 @@ import android.util.Log; import android.webkit.URLUtil; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; public class DefaultDownloaderFactory implements DownloaderFactory { private static final String TAG = "DefaultDwnldrFactory"; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequestCreator.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequestCreator.java index c33e6b4d6..55546a7db 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequestCreator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequestCreator.java @@ -6,6 +6,7 @@ import de.danoeh.antennapod.core.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.net.download.serviceinterface.DownloadRequest; import org.apache.commons.io.FilenameUtils; import java.io.File; 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 12bbf83d0..751cf0b9b 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 @@ -21,6 +21,8 @@ import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.core.feed.LocalFeedUpdater; import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithmFactory; import de.danoeh.antennapod.model.download.DownloadStatus; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import org.apache.commons.io.FileUtils; import org.greenrobot.eventbus.EventBus; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceImpl.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceImpl.java index f8d34174e..384a6070e 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceImpl.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceImpl.java @@ -5,6 +5,8 @@ import android.content.Intent; import androidx.core.content.ContextCompat; import com.google.android.exoplayer2.util.Log; import de.danoeh.antennapod.core.BuildConfig; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import java.util.ArrayList; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java index e24922ab0..ea1e68bbf 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java @@ -14,6 +14,7 @@ import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.core.util.gui.NotificationUtils; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import java.util.List; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java index 22c4e9b87..f7f5e8e9c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java @@ -10,6 +10,7 @@ import java.util.concurrent.Callable; import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.model.download.DownloadStatus; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; /** * Downloads files diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloaderFactory.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloaderFactory.java index d96210a6e..48601c4f7 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloaderFactory.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloaderFactory.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.service.download; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; public interface DownloaderFactory { @Nullable diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java index 9a2a10490..a0a0615cb 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/HttpDownloader.java @@ -6,6 +6,7 @@ import android.util.Log; import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.model.download.DownloadStatus; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import okhttp3.CacheControl; import okhttp3.internal.http.StatusLine; import org.apache.commons.io.IOUtils; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/LocalFeedStubDownloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/LocalFeedStubDownloader.java index feb5fc6be..750255958 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/LocalFeedStubDownloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/LocalFeedStubDownloader.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.core.service.download; import androidx.annotation.NonNull; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; /** * This does not actually download, but it keeps track of a local feed's refresh state. diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FailedDownloadHandler.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FailedDownloadHandler.java index 748559909..937f051ec 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FailedDownloadHandler.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FailedDownloadHandler.java @@ -2,7 +2,7 @@ package de.danoeh.antennapod.core.service.download.handler; import android.util.Log; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.storage.DBWriter; /** 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 dc5893b23..a5ed5c3dd 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 @@ -7,7 +7,7 @@ import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedPreferences; import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.parser.feed.FeedHandler; import de.danoeh.antennapod.parser.feed.FeedHandlerResult; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java index 5e97c233f..07670bff3 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java @@ -4,7 +4,7 @@ import android.content.Context; import androidx.annotation.NonNull; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.parser.feed.FeedHandlerResult; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java index b30f44eec..442e3173d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java @@ -12,7 +12,7 @@ import java.io.File; import java.util.concurrent.ExecutionException; import de.danoeh.antennapod.event.UnreadItemsUpdateEvent; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java b/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java index 4d8a0c25e..4ad2aa665 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/AutomaticDownloadAlgorithm.java @@ -7,9 +7,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.util.PlaybackStatus; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedPreferences; 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 13a18b0d7..9a9525324 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 @@ -10,9 +10,9 @@ import android.util.Log; import androidx.annotation.VisibleForTesting; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.storage.database.PodDBAdapter; import de.danoeh.antennapod.storage.database.mapper.FeedCursorMapper; import org.greenrobot.eventbus.EventBus; 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 fbcb86586..48d88f803 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 @@ -8,7 +8,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.NotificationManagerCompat; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; import de.danoeh.antennapod.storage.database.PodDBAdapter; import org.greenrobot.eventbus.EventBus; diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java index c304d67d2..952c047c7 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java @@ -20,10 +20,10 @@ import androidx.work.WorkManager; import androidx.work.Worker; import androidx.work.WorkerParameters; -import de.danoeh.antennapod.core.service.download.DownloadRequest; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import org.apache.commons.lang3.StringUtils; import org.greenrobot.eventbus.EventBus; @@ -42,7 +42,7 @@ import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueStorage; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.LongList; -import de.danoeh.antennapod.core.util.URLChecker; +import de.danoeh.antennapod.net.common.UrlChecker; import de.danoeh.antennapod.core.util.gui.NotificationUtils; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; @@ -150,7 +150,7 @@ public class SyncService extends Worker { Log.d(TAG, "Skipping url: " + downloadUrl); continue; } - if (!URLChecker.containsUrl(localSubscriptions, downloadUrl) && !queuedRemovedFeeds.contains(downloadUrl)) { + if (!UrlChecker.containsUrl(localSubscriptions, downloadUrl) && !queuedRemovedFeeds.contains(downloadUrl)) { Feed feed = new Feed(downloadUrl, null); DownloadRequest.Builder builder = DownloadRequestCreator.create(feed); DownloadServiceInterface.get().download(getApplicationContext(), false, builder.build()); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java b/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java index 0eca498c9..0547e353b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java @@ -2,7 +2,7 @@ package de.danoeh.antennapod.core.util.download; import android.content.Context; import com.google.android.exoplayer2.util.Log; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.util.NetworkUtils; diff --git a/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java b/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java index 095bed687..551b14d3b 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/feed/LocalFeedUpdaterTest.java @@ -10,8 +10,8 @@ import androidx.annotation.NonNull; import androidx.test.platform.app.InstrumentationRegistry; import de.danoeh.antennapod.core.preferences.PlaybackPreferences; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterfaceStub; +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; diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java index ba8877da6..91761d7ee 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java @@ -10,8 +10,8 @@ import androidx.core.util.Consumer; import androidx.preference.PreferenceManager; import androidx.test.platform.app.InstrumentationRegistry; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterface; -import de.danoeh.antennapod.core.service.download.DownloadServiceInterfaceStub; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; +import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterfaceStub; import de.danoeh.antennapod.storage.database.PodDBAdapter; import org.awaitility.Awaitility; import org.junit.After; diff --git a/net/common/README.md b/net/common/README.md new file mode 100644 index 000000000..3bd8b232e --- /dev/null +++ b/net/common/README.md @@ -0,0 +1,3 @@ +# :net:common + +This module contains general network related utilities. diff --git a/net/common/build.gradle b/net/common/build.gradle new file mode 100644 index 000000000..c519aa653 --- /dev/null +++ b/net/common/build.gradle @@ -0,0 +1,12 @@ +plugins { + id("com.android.library") +} +apply from: "../../common.gradle" + +dependencies { + annotationProcessor "androidx.annotation:annotation:$annotationVersion" + implementation "com.squareup.okhttp3:okhttp:$okhttpVersion" + + testImplementation "junit:junit:$junitVersion" + testImplementation "org.robolectric:robolectric:$robolectricVersion" +} diff --git a/net/common/src/main/AndroidManifest.xml b/net/common/src/main/AndroidManifest.xml new file mode 100644 index 000000000..702944daa --- /dev/null +++ b/net/common/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java b/net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java similarity index 79% rename from core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java rename to net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java index a72d2034b..4eb1fd6a5 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java +++ b/net/common/src/main/java/de/danoeh/antennapod/net/common/UrlChecker.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.util; +package de.danoeh.antennapod.net.common; import android.net.Uri; import android.text.TextUtils; @@ -11,22 +11,23 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * Provides methods for checking and editing a URL. */ -public final class URLChecker { +public final class UrlChecker { /** * Class shall not be instantiated. */ - private URLChecker() { + private UrlChecker() { } /** * Logging tag. */ - private static final String TAG = "URLChecker"; + private static final String TAG = "UrlChecker"; private static final String AP_SUBSCRIBE = "antennapod-subscribe://"; private static final String AP_SUBSCRIBE_DEEPLINK = "antennapod.org/deeplink/subscribe"; @@ -37,31 +38,31 @@ public final class URLChecker { * @param url The url which is going to be prepared * @return The prepared url */ - public static String prepareURL(@NonNull String url) { + public static String prepareUrl(@NonNull String url) { url = url.trim(); - String lowerCaseUrl = url.toLowerCase(); // protocol names are case insensitive + String lowerCaseUrl = url.toLowerCase(Locale.ROOT); // protocol names are case insensitive if (lowerCaseUrl.startsWith("feed://")) { Log.d(TAG, "Replacing feed:// with http://"); - return prepareURL(url.substring("feed://".length())); + return prepareUrl(url.substring("feed://".length())); } else if (lowerCaseUrl.startsWith("pcast://")) { Log.d(TAG, "Removing pcast://"); - return prepareURL(url.substring("pcast://".length())); + return prepareUrl(url.substring("pcast://".length())); } else if (lowerCaseUrl.startsWith("pcast:")) { Log.d(TAG, "Removing pcast:"); - return prepareURL(url.substring("pcast:".length())); + return prepareUrl(url.substring("pcast:".length())); } else if (lowerCaseUrl.startsWith("itpc")) { Log.d(TAG, "Replacing itpc:// with http://"); - return prepareURL(url.substring("itpc://".length())); + return prepareUrl(url.substring("itpc://".length())); } else if (lowerCaseUrl.startsWith(AP_SUBSCRIBE)) { Log.d(TAG, "Removing antennapod-subscribe://"); - return prepareURL(url.substring(AP_SUBSCRIBE.length())); + return prepareUrl(url.substring(AP_SUBSCRIBE.length())); } else if (lowerCaseUrl.contains(AP_SUBSCRIBE_DEEPLINK)) { Log.d(TAG, "Removing " + AP_SUBSCRIBE_DEEPLINK); String removedWebsite = url.substring(url.indexOf("?url=") + "?url=".length()); try { - return prepareURL(URLDecoder.decode(removedWebsite, "UTF-8")); + return prepareUrl(URLDecoder.decode(removedWebsite, "UTF-8")); } catch (UnsupportedEncodingException e) { - return prepareURL(removedWebsite); + return prepareUrl(removedWebsite); } } else if (!(lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://"))) { Log.d(TAG, "Adding http:// at the beginning of the URL"); @@ -80,18 +81,18 @@ public final class URLChecker { * the result of prepareURL(url) is returned instead. * @return The prepared url */ - public static String prepareURL(String url, String base) { + public static String prepareUrl(String url, String base) { if (base == null) { - return prepareURL(url); + return prepareUrl(url); } url = url.trim(); - base = prepareURL(base); + base = prepareUrl(base); Uri urlUri = Uri.parse(url); Uri baseUri = Uri.parse(base); if (urlUri.isRelative() && baseUri.isAbsolute()) { return urlUri.buildUpon().scheme(baseUri.getScheme()).build().toString(); } else { - return prepareURL(url); + return prepareUrl(url); } } @@ -130,7 +131,7 @@ public final class URLChecker { List result = new ArrayList<>(); for (String string : input) { if (!TextUtils.isEmpty(string)) { - result.add(string.toLowerCase()); + result.add(string.toLowerCase(Locale.ROOT)); } } return result; diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/URLCheckerTest.java b/net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java similarity index 63% rename from core/src/test/java/de/danoeh/antennapod/core/util/URLCheckerTest.java rename to net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java index 25db2e1c4..ba9f1dcbb 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/util/URLCheckerTest.java +++ b/net/common/src/test/java/de/danoeh/antennapod/net/common/UrlCheckerTest.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.util; +package de.danoeh.antennapod.net.common; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,107 +12,107 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** - * Test class for {@link URLChecker} + * Test class for {@link UrlChecker} */ @RunWith(RobolectricTestRunner.class) -public class URLCheckerTest { +public class UrlCheckerTest { @Test public void testCorrectURLHttp() { final String in = "http://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals(in, out); } @Test public void testCorrectURLHttps() { final String in = "https://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals(in, out); } @Test public void testMissingProtocol() { final String in = "example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("http://example.com", out); } @Test public void testFeedProtocol() { final String in = "feed://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("http://example.com", out); } @Test public void testPcastProtocolNoScheme() { final String in = "pcast://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("http://example.com", out); } @Test public void testItpcProtocol() { final String in = "itpc://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("http://example.com", out); } @Test public void testItpcProtocolWithScheme() { final String in = "itpc://https://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("https://example.com", out); } @Test public void testWhiteSpaceUrlShouldNotAppend() { final String in = "\n http://example.com \t"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("http://example.com", out); } @Test public void testWhiteSpaceShouldAppend() { final String in = "\n example.com \t"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("http://example.com", out); } @Test public void testAntennaPodSubscribeProtocolNoScheme() { final String in = "antennapod-subscribe://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("http://example.com", out); } @Test public void testPcastProtocolWithScheme() { final String in = "pcast://https://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("https://example.com", out); } @Test public void testAntennaPodSubscribeProtocolWithScheme() { final String in = "antennapod-subscribe://https://example.com"; - final String out = URLChecker.prepareURL(in); + final String out = UrlChecker.prepareUrl(in); assertEquals("https://example.com", out); } @Test public void testAntennaPodSubscribeDeeplink() throws UnsupportedEncodingException { final String feed = "http://example.org/podcast.rss"; - assertEquals(feed, URLChecker.prepareURL("https://antennapod.org/deeplink/subscribe?url=" + feed)); - assertEquals(feed, URLChecker.prepareURL("http://antennapod.org/deeplink/subscribe?url=" + feed)); - assertEquals(feed, URLChecker.prepareURL("http://antennapod.org/deeplink/subscribe/?url=" + feed)); - assertEquals(feed, URLChecker.prepareURL("https://www.antennapod.org/deeplink/subscribe?url=" + feed)); - assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe?url=" + feed)); - assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe/?url=" + feed)); - assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe?url=" + assertEquals(feed, UrlChecker.prepareUrl("https://antennapod.org/deeplink/subscribe?url=" + feed)); + assertEquals(feed, UrlChecker.prepareUrl("http://antennapod.org/deeplink/subscribe?url=" + feed)); + assertEquals(feed, UrlChecker.prepareUrl("http://antennapod.org/deeplink/subscribe/?url=" + feed)); + assertEquals(feed, UrlChecker.prepareUrl("https://www.antennapod.org/deeplink/subscribe?url=" + feed)); + assertEquals(feed, UrlChecker.prepareUrl("http://www.antennapod.org/deeplink/subscribe?url=" + feed)); + assertEquals(feed, UrlChecker.prepareUrl("http://www.antennapod.org/deeplink/subscribe/?url=" + feed)); + assertEquals(feed, UrlChecker.prepareUrl("http://www.antennapod.org/deeplink/subscribe?url=" + URLEncoder.encode(feed, "UTF-8"))); - assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe?url=" + assertEquals(feed, UrlChecker.prepareUrl("http://www.antennapod.org/deeplink/subscribe?url=" + "example.org/podcast.rss")); } @@ -120,7 +120,7 @@ public class URLCheckerTest { public void testProtocolRelativeUrlIsAbsolute() { final String in = "https://example.com"; final String inBase = "http://examplebase.com"; - final String out = URLChecker.prepareURL(in, inBase); + final String out = UrlChecker.prepareUrl(in, inBase); assertEquals(in, out); } @@ -128,7 +128,7 @@ public class URLCheckerTest { public void testProtocolRelativeUrlIsRelativeHttps() { final String in = "//example.com"; final String inBase = "https://examplebase.com"; - final String out = URLChecker.prepareURL(in, inBase); + final String out = UrlChecker.prepareUrl(in, inBase); assertEquals("https://example.com", out); } @@ -136,40 +136,40 @@ public class URLCheckerTest { public void testProtocolRelativeUrlIsHttpsWithApSubscribeProtocol() { final String in = "//example.com"; final String inBase = "antennapod-subscribe://https://examplebase.com"; - final String out = URLChecker.prepareURL(in, inBase); + final String out = UrlChecker.prepareUrl(in, inBase); assertEquals("https://example.com", out); } @Test public void testProtocolRelativeUrlBaseUrlNull() { final String in = "example.com"; - final String out = URLChecker.prepareURL(in, null); + final String out = UrlChecker.prepareUrl(in, null); assertEquals("http://example.com", out); } @Test public void testUrlEqualsSame() { - assertTrue(URLChecker.urlEquals("https://www.example.com/test", "https://www.example.com/test")); - assertTrue(URLChecker.urlEquals("https://www.example.com/test", "https://www.example.com/test/")); - assertTrue(URLChecker.urlEquals("https://www.example.com/test", "https://www.example.com//test")); - assertTrue(URLChecker.urlEquals("https://www.example.com", "https://www.example.com/")); - assertTrue(URLChecker.urlEquals("https://www.example.com", "http://www.example.com")); - assertTrue(URLChecker.urlEquals("http://www.example.com/", "https://www.example.com/")); - assertTrue(URLChecker.urlEquals("https://www.example.com/?id=42", "https://www.example.com/?id=42")); - assertTrue(URLChecker.urlEquals("https://example.com/podcast%20test", "https://example.com/podcast test")); - assertTrue(URLChecker.urlEquals("https://example.com/?a=podcast%20test", "https://example.com/?a=podcast test")); - assertTrue(URLChecker.urlEquals("https://example.com/?", "https://example.com/")); - assertTrue(URLChecker.urlEquals("https://example.com/?", "https://example.com")); - assertTrue(URLChecker.urlEquals("https://Example.com", "https://example.com")); - assertTrue(URLChecker.urlEquals("https://example.com/test", "https://example.com/Test")); + assertTrue(UrlChecker.urlEquals("https://www.example.com/test", "https://www.example.com/test")); + assertTrue(UrlChecker.urlEquals("https://www.example.com/test", "https://www.example.com/test/")); + assertTrue(UrlChecker.urlEquals("https://www.example.com/test", "https://www.example.com//test")); + assertTrue(UrlChecker.urlEquals("https://www.example.com", "https://www.example.com/")); + assertTrue(UrlChecker.urlEquals("https://www.example.com", "http://www.example.com")); + assertTrue(UrlChecker.urlEquals("http://www.example.com/", "https://www.example.com/")); + assertTrue(UrlChecker.urlEquals("https://www.example.com/?id=42", "https://www.example.com/?id=42")); + assertTrue(UrlChecker.urlEquals("https://example.com/podcast%20test", "https://example.com/podcast test")); + assertTrue(UrlChecker.urlEquals("https://example.com/?a=podcast%20test", "https://example.com/?a=podcast test")); + assertTrue(UrlChecker.urlEquals("https://example.com/?", "https://example.com/")); + assertTrue(UrlChecker.urlEquals("https://example.com/?", "https://example.com")); + assertTrue(UrlChecker.urlEquals("https://Example.com", "https://example.com")); + assertTrue(UrlChecker.urlEquals("https://example.com/test", "https://example.com/Test")); } @Test public void testUrlEqualsDifferent() { - assertFalse(URLChecker.urlEquals("https://www.example.com/test", "https://www.example2.com/test")); - assertFalse(URLChecker.urlEquals("https://www.example.com/test", "https://www.example.de/test")); - assertFalse(URLChecker.urlEquals("https://example.com/", "https://otherpodcast.example.com/")); - assertFalse(URLChecker.urlEquals("https://www.example.com/?id=42&a=b", "https://www.example.com/?id=43&a=b")); - assertFalse(URLChecker.urlEquals("https://example.com/podcast%25test", "https://example.com/podcast test")); + assertFalse(UrlChecker.urlEquals("https://www.example.com/test", "https://www.example2.com/test")); + assertFalse(UrlChecker.urlEquals("https://www.example.com/test", "https://www.example.de/test")); + assertFalse(UrlChecker.urlEquals("https://example.com/", "https://otherpodcast.example.com/")); + assertFalse(UrlChecker.urlEquals("https://www.example.com/?id=42&a=b", "https://www.example.com/?id=43&a=b")); + assertFalse(UrlChecker.urlEquals("https://example.com/podcast%25test", "https://example.com/podcast test")); } } diff --git a/net/download/README.md b/net/download/README.md new file mode 100644 index 000000000..57b2d2f31 --- /dev/null +++ b/net/download/README.md @@ -0,0 +1,3 @@ +# :net:download + +This folder contains the download service and its interface. diff --git a/net/download/service-interface/README.md b/net/download/service-interface/README.md new file mode 100644 index 000000000..fafe03230 --- /dev/null +++ b/net/download/service-interface/README.md @@ -0,0 +1,3 @@ +# :net:download:service-interface + +Interface of the download service. Enables other modules to call the download service without actually depending on the implementation. diff --git a/net/download/service-interface/build.gradle b/net/download/service-interface/build.gradle new file mode 100644 index 000000000..785326bab --- /dev/null +++ b/net/download/service-interface/build.gradle @@ -0,0 +1,21 @@ +plugins { + id("com.android.library") + id("java-test-fixtures") +} +apply from: "../../../common.gradle" + +android { + lintOptions { + disable 'ParcelClassLoader' + } +} + +dependencies { + implementation project(':model') + implementation project(':net:common') + + annotationProcessor "androidx.annotation:annotation:$annotationVersion" + + testImplementation "junit:junit:$junitVersion" + testImplementation "org.robolectric:robolectric:$robolectricVersion" +} diff --git a/net/download/service-interface/src/main/AndroidManifest.xml b/net/download/service-interface/src/main/AndroidManifest.xml new file mode 100644 index 000000000..df6365325 --- /dev/null +++ b/net/download/service-interface/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequest.java similarity index 97% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java rename to net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequest.java index c085bc007..e5c6662eb 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java +++ b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequest.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.serviceinterface; import android.os.Bundle; import android.os.Parcel; @@ -9,7 +9,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.core.util.URLChecker; +import de.danoeh.antennapod.net.common.UrlChecker; import de.danoeh.antennapod.model.feed.FeedMedia; public class DownloadRequest implements Parcelable { @@ -276,7 +276,7 @@ public class DownloadRequest implements Parcelable { public Builder(@NonNull String destination, @NonNull FeedMedia media) { this.destination = destination; - this.source = URLChecker.prepareURL(media.getDownload_url()); + this.source = UrlChecker.prepareUrl(media.getDownload_url()); this.title = media.getHumanReadableIdentifier(); this.feedfileId = media.getId(); this.feedfileType = media.getTypeAsInt(); @@ -284,7 +284,7 @@ public class DownloadRequest implements Parcelable { public Builder(@NonNull String destination, @NonNull Feed feed) { this.destination = destination; - this.source = feed.isLocalFeed() ? feed.getDownload_url() : URLChecker.prepareURL(feed.getDownload_url()); + this.source = feed.isLocalFeed() ? feed.getDownload_url() : UrlChecker.prepareUrl(feed.getDownload_url()); this.title = feed.getHumanReadableIdentifier(); this.feedfileId = feed.getId(); this.feedfileType = feed.getTypeAsInt(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterface.java b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadServiceInterface.java similarity index 91% rename from core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterface.java rename to net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadServiceInterface.java index aa4b16490..54987a83e 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterface.java +++ b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadServiceInterface.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.serviceinterface; import android.content.Context; diff --git a/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceStub.java b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadServiceInterfaceStub.java similarity index 87% rename from core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceStub.java rename to net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadServiceInterfaceStub.java index 952936f70..251c59c61 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadServiceInterfaceStub.java +++ b/net/download/service-interface/src/main/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadServiceInterfaceStub.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.serviceinterface; import android.content.Context; diff --git a/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadRequestTest.java b/net/download/service-interface/src/test/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequestTest.java similarity index 98% rename from core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadRequestTest.java rename to net/download/service-interface/src/test/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequestTest.java index d1bea221a..2709744f7 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadRequestTest.java +++ b/net/download/service-interface/src/test/java/de/danoeh/antennapod/net/download/serviceinterface/DownloadRequestTest.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.service.download; +package de.danoeh.antennapod.net.download.serviceinterface; import android.os.Bundle; import android.os.Parcel; diff --git a/settings.gradle b/settings.gradle index 96e06aabf..5006fe6ef 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,9 @@ include ':core' include ':event' include ':model' +include ':net:common' include ':net:discovery' +include ':net:download:service-interface' include ':net:ssl' include ':net:sync:gpoddernet' include ':net:sync:model'