diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-29 19:27:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 19:27:53 +0100 |
commit | 2fd73b148d012fba7308c86494689103b8aaace4 (patch) | |
tree | 75782c565600eadd67d0fca46acf637370fcf4a3 /app/src/main | |
parent | 6f3a9b16764a57e43994ccbeeada5224dee93f44 (diff) | |
download | AntennaPod-2fd73b148d012fba7308c86494689103b8aaace4.zip |
Move download service to module (#7041)
Diffstat (limited to 'app/src/main')
8 files changed, 70 insertions, 9 deletions
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/app/src/main/java/de/danoeh/antennapod/ClientConfigurator.java b/app/src/main/java/de/danoeh/antennapod/ClientConfigurator.java new file mode 100644 index 000000000..a0cf4bfc9 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/ClientConfigurator.java @@ -0,0 +1,62 @@ +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.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; +import de.danoeh.antennapod.net.sync.serviceinterface.SynchronizationQueueSink; +import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; +import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials; +import de.danoeh.antennapod.storage.preferences.PlaybackPreferences; +import de.danoeh.antennapod.storage.preferences.SleepTimerPreferences; +import de.danoeh.antennapod.storage.preferences.UsageStatistics; +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.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; +import de.danoeh.antennapod.storage.database.PodDBAdapter; + +import de.danoeh.antennapod.ui.notifications.NotificationUtils; +import java.io.File; + +public class ClientConfigurator { + private static boolean initialized = false; + + public static synchronized void initialize(Context context) { + if (initialized) { + return; + } + try { + PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); + UserAgentInterceptor.USER_AGENT = "AntennaPod/" + packageInfo.versionName; + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + PodDBAdapter.init(context); + UserPreferences.init(context); + SynchronizationCredentials.init(context); + SynchronizationSettings.init(context); + UsageStatistics.init(context); + PlaybackPreferences.init(context); + SslProviderInstaller.install(context); + NetworkUtils.init(context); + NetworkConnectionChangeHandler.init(context); + DownloadServiceInterface.setImpl(new DownloadServiceInterfaceImpl()); + FeedUpdateManager.setInstance(new FeedUpdateManagerImpl()); + AutoDownloadManager.setInstance(new AutoDownloadManagerImpl()); + SynchronizationQueueSink.setServiceStarterImpl(() -> SyncService.sync(context)); + AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp")); + AntennapodHttpClient.setProxyConfig(UserPreferences.getProxyConfig()); + SleepTimerPreferences.init(context); + NotificationUtils.createChannels(context); + initialized = true; + } +} 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; |