diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-29 17:45:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 17:45:14 +0100 |
commit | 6f3a9b16764a57e43994ccbeeada5224dee93f44 (patch) | |
tree | 24bd2a3ed120dd61b009e5a2b5b9a1c550579997 /app | |
parent | 0c8c9a89a371d6515c34d1c4f7417c26059ee969 (diff) | |
download | AntennaPod-6f3a9b16764a57e43994ccbeeada5224dee93f44.zip |
Create module for sync service and move DBWriter to database module (#7040)
Diffstat (limited to 'app')
41 files changed, 87 insertions, 76 deletions
diff --git a/app/build.gradle b/app/build.gradle index 1f813d092..84866a9e2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,6 +86,7 @@ dependencies { implementation project(':ui:widget') implementation project(':ui:preferences') implementation project(':ui:statistics') + implementation project(':net:sync:service-interface') annotationProcessor "androidx.annotation:annotation:$annotationVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" diff --git a/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java b/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java index e5fd1ad19..aa1560fe7 100644 --- a/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java +++ b/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java @@ -13,7 +13,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.storage.preferences.PlaybackPreferences; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.storage.database.LongList; import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.model.feed.FeedItem; 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 f7bfbce7b..ee8a80caf 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -35,10 +35,11 @@ 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.serviceinterface.FeedUpdateManager; +import de.danoeh.antennapod.net.sync.serviceinterface.SynchronizationQueueSink; import de.danoeh.antennapod.ui.appstartintent.MediaButtonStarter; import de.danoeh.antennapod.ui.common.ThemeSwitcher; -import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.dialog.rating.RatingDialogManager; import de.danoeh.antennapod.event.EpisodeDownloadEvent; import de.danoeh.antennapod.event.FeedUpdateRunningEvent; @@ -166,12 +167,12 @@ public class MainActivity extends CastEnabledActivity { sheetBehavior.setHideable(false); sheetBehavior.setBottomSheetCallback(bottomSheetCallback); - FeedUpdateManager.restartUpdateAlarm(this, false); + FeedUpdateManager.getInstance().restartUpdateAlarm(this, false); SynchronizationQueueSink.syncNowIfNotSyncedRecently(); AutomaticDatabaseExportWorker.enqueueIfNeeded(this, false); WorkManager.getInstance(this) - .getWorkInfosByTagLiveData(FeedUpdateManager.WORK_TAG_FEED_UPDATE) + .getWorkInfosByTagLiveData(FeedUpdateManagerImpl.WORK_TAG_FEED_UPDATE) .observe(this, workInfos -> { boolean isRefreshingFeeds = false; for (WorkInfo workInfo : workInfos) { @@ -301,7 +302,7 @@ public class MainActivity extends CastEnabledActivity { private void checkFirstLaunch() { SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE); if (prefs.getBoolean(PREF_IS_FIRST_LAUNCH, true)) { - FeedUpdateManager.restartUpdateAlarm(this, true); + FeedUpdateManager.getInstance().restartUpdateAlarm(this, true); SharedPreferences.Editor edit = prefs.edit(); edit.putBoolean(PREF_IS_FIRST_LAUNCH, false); @@ -630,7 +631,7 @@ public class MainActivity extends CastEnabledActivity { new DownloadLogFragment().show(getSupportFragmentManager(), null); } if (intent.getBooleanExtra(EXTRA_REFRESH_ON_START, false)) { - FeedUpdateManager.runOnceOrAsk(this); + FeedUpdateManager.getInstance().runOnceOrAsk(this); } // to avoid handling the intent twice when the configuration changes setIntent(new Intent(MainActivity.this, MainActivity.class)); 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 3a9fc9b46..4ad11588b 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -32,7 +32,7 @@ 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.discovery.FeedUrlNotFoundException; -import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; +import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; import de.danoeh.antennapod.core.util.DownloadErrorLabel; import de.danoeh.antennapod.databinding.EditTextDialogBinding; @@ -48,7 +48,7 @@ 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.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.net.discovery.CombinedSearcher; import de.danoeh.antennapod.net.discovery.PodcastSearchResult; import de.danoeh.antennapod.net.discovery.PodcastSearcherRegistry; 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 ed11e6910..d78f54b18 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java @@ -26,10 +26,10 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.ui.common.ThemeSwitcher; -import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; +import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.databinding.OpmlSelectionBinding; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.storage.importexport.OpmlElement; @@ -104,7 +104,7 @@ public class OpmlImportActivity extends AppCompatActivity { feed.setItems(Collections.emptyList()); FeedDatabaseWriter.updateFeed(this, feed, false); } - FeedUpdateManager.runOnce(this); + FeedUpdateManager.getInstance().runOnce(this); }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index 6e0a84bf6..eb777fda9 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -46,7 +46,7 @@ import de.danoeh.antennapod.fragment.ChaptersFragment; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.ui.common.Converter; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.IntentUtils; 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 b6df9526c..84c9709bb 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -10,9 +10,9 @@ import android.widget.Toast; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.actionbutton.DownloadActionButton; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.core.util.DownloadErrorLabel; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.model.download.DownloadError; import de.danoeh.antennapod.model.download.DownloadResult; import de.danoeh.antennapod.model.feed.Feed; @@ -105,7 +105,7 @@ public class DownloadLogAdapter extends BaseAdapter { Log.e(TAG, "Could not find feed for feed id: " + status.getFeedfileId()); return; } - FeedUpdateManager.runOnce(context, feed); + FeedUpdateManager.getInstance().runOnce(context, feed); }); } else if (status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) { holder.secondaryActionButton.setOnClickListener(v -> { 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 c9500340b..fa4b19b4d 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 @@ -9,7 +9,7 @@ import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterfa import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.storage.preferences.UserPreferences; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; public class CancelDownloadActionButton extends ItemActionButton { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DeleteActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DeleteActionButton.java index 8ee31a03c..6b9114e81 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DeleteActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/DeleteActionButton.java @@ -10,7 +10,7 @@ import java.util.Collections; import de.danoeh.antennapod.R; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.view.LocalDeleteModal; public class DeleteActionButton extends ItemActionButton { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MarkAsPlayedActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MarkAsPlayedActionButton.java index 8dc4ffe33..34fef11dc 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MarkAsPlayedActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/MarkAsPlayedActionButton.java @@ -7,7 +7,7 @@ import android.view.View; import de.danoeh.antennapod.R; import de.danoeh.antennapod.model.feed.FeedItem; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; public class MarkAsPlayedActionButton extends ItemActionButton { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java index e0a15191e..5f7f17670 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java @@ -5,7 +5,7 @@ import android.util.Log; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.model.feed.FeedItem; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EditUrlSettingsDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/EditUrlSettingsDialog.java index 0edb66b64..67c5d85cf 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/EditUrlSettingsDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/EditUrlSettingsDialog.java @@ -6,8 +6,8 @@ import android.view.LayoutInflater; import androidx.appcompat.app.AlertDialog; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.databinding.EditTextDialogBinding; import de.danoeh.antennapod.model.feed.Feed; @@ -48,7 +48,7 @@ public abstract class EditUrlSettingsDialog { try { DBWriter.updateFeedDownloadURL(original, updated).get(); feed.setDownloadUrl(updated); - FeedUpdateManager.runOnce(activityRef.get(), feed); + FeedUpdateManager.getInstance().runOnce(activityRef.get(), feed); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemFilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemFilterDialog.java index e91e88fbf..a88a6600a 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemFilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FeedItemFilterDialog.java @@ -1,7 +1,7 @@ package de.danoeh.antennapod.dialog; import android.os.Bundle; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.model.feed.Feed; import java.util.Set; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/RemoveFeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/RemoveFeedDialog.java index 363b87ca6..ffa374b6f 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/RemoveFeedDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/RemoveFeedDialog.java @@ -13,7 +13,7 @@ import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import io.reactivex.Completable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/RenameItemDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/RenameItemDialog.java index fd1403313..bbe6fd16c 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/RenameItemDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/RenameItemDialog.java @@ -12,7 +12,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import de.danoeh.antennapod.R; import de.danoeh.antennapod.storage.database.NavDrawerData; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.databinding.EditTextDialogBinding; import de.danoeh.antennapod.model.feed.FeedPreferences; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java index 4b3ed7db7..8112c0955 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java @@ -23,7 +23,7 @@ import java.util.Set; import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.SimpleChipAdapter; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.storage.database.NavDrawerData; import de.danoeh.antennapod.databinding.EditTagsDialogBinding; import de.danoeh.antennapod.model.feed.FeedCounter; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java index 1ec917176..4d1848296 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java @@ -26,9 +26,9 @@ import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.OpmlImportActivity; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; +import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.model.feed.SortOrder; import de.danoeh.antennapod.databinding.AddfeedBinding; import de.danoeh.antennapod.databinding.EditTextDialogBinding; @@ -204,7 +204,7 @@ public class AddFeedFragment extends Fragment { dirFeed.setItems(Collections.emptyList()); dirFeed.setSortOrder(SortOrder.EPISODE_TITLE_A_Z); Feed fromDatabase = FeedDatabaseWriter.updateFeed(getContext(), dirFeed, false); - FeedUpdateManager.runOnce(requireContext(), fromDatabase); + FeedUpdateManager.getInstance().runOnce(requireContext(), fromDatabase); return fromDatabase; } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java index 146ac6a9b..9db4f585a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java @@ -20,9 +20,9 @@ import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; import de.danoeh.antennapod.adapter.actionbutton.DeleteActionButton; import de.danoeh.antennapod.event.DownloadLogEvent; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.core.util.FeedItemUtil; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.dialog.ItemSortDialog; import de.danoeh.antennapod.event.EpisodeDownloadEvent; import de.danoeh.antennapod.event.FeedItemEvent; @@ -179,7 +179,7 @@ public class CompletedDownloadsFragment extends Fragment @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.refresh_item) { - FeedUpdateManager.runOnceOrAsk(requireContext()); + FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()); return true; } else if (item.getItemId() == R.id.action_download_logs) { new DownloadLogFragment().show(getChildFragmentManager(), null); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java index c963c8298..54c6d1a9b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java @@ -15,7 +15,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.DownloadLogAdapter; import de.danoeh.antennapod.event.DownloadLogEvent; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.databinding.DownloadLogFragmentBinding; import de.danoeh.antennapod.dialog.DownloadLogDetailsDialog; import de.danoeh.antennapod.model.download.DownloadResult; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java index 08714e971..0f9e21b6e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java @@ -24,6 +24,7 @@ import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.snackbar.Snackbar; import com.leinardi.android.speeddial.SpeedDialView; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -38,7 +39,6 @@ import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.core.util.FeedItemUtil; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.event.EpisodeDownloadEvent; import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.FeedListUpdateEvent; @@ -122,7 +122,7 @@ public abstract class EpisodesListFragment extends Fragment public boolean onMenuItemClick(MenuItem item) { final int itemId = item.getItemId(); if (itemId == R.id.refresh_item) { - FeedUpdateManager.runOnceOrAsk(requireContext()); + FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()); return true; } else if (itemId == R.id.action_search) { ((MainActivity) getActivity()).loadChildFragment(SearchFragment.newInstance()); @@ -182,7 +182,7 @@ public abstract class EpisodesListFragment extends Fragment swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); + swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.getInstance().runOnceOrAsk(requireContext())); listAdapter = new EpisodeItemListAdapter((MainActivity) getActivity()) { @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java index 49ea28765..c93837851 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java @@ -35,7 +35,7 @@ import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; +import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.ShareUtils; import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java index 680036aea..1884012ea 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java @@ -26,6 +26,7 @@ import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.snackbar.Snackbar; import com.leinardi.android.speeddial.SpeedDialView; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.greenrobot.eventbus.EventBus; @@ -42,12 +43,11 @@ import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; import de.danoeh.antennapod.event.FeedEvent; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.storage.database.FeedItemPermutors; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.ShareUtils; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil; import de.danoeh.antennapod.databinding.FeedItemListFragmentBinding; import de.danoeh.antennapod.databinding.MultiSelectSpeedDialBinding; @@ -171,7 +171,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem nextPageLoader = new MoreContentListFooterUtil(viewBinding.moreContent.moreContentListFooter); nextPageLoader.setClickListener(() -> { if (feed != null) { - FeedUpdateManager.runOnce(getContext(), feed, true); + FeedUpdateManager.getInstance().runOnce(getContext(), feed, true); } }); viewBinding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @@ -190,7 +190,8 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem EventBus.getDefault().register(this); viewBinding.swipeRefresh.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - viewBinding.swipeRefresh.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext(), feed)); + viewBinding.swipeRefresh.setOnRefreshListener(() -> + FeedUpdateManager.getInstance().runOnceOrAsk(requireContext(), feed)); loadItems(); @@ -273,14 +274,14 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem } else if (item.getItemId() == R.id.share_item) { ShareUtils.shareFeedLink(getContext(), feed); } else if (item.getItemId() == R.id.refresh_item) { - FeedUpdateManager.runOnceOrAsk(getContext(), feed); + FeedUpdateManager.getInstance().runOnceOrAsk(getContext(), feed); } else if (item.getItemId() == R.id.refresh_complete_item) { new Thread(() -> { feed.setNextPageLink(feed.getDownloadUrl()); feed.setPageNr(0); try { DBWriter.resetPagedFeedPage(feed).get(); - FeedUpdateManager.runOnce(getContext(), feed); + FeedUpdateManager.getInstance().runOnce(getContext(), feed); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java index 23a3489e0..69cfb0087 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java @@ -26,7 +26,6 @@ import androidx.preference.PreferenceFragmentCompat; import androidx.preference.SwitchPreferenceCompat; import androidx.recyclerview.widget.RecyclerView; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.event.settings.SkipIntroEndingChangedEvent; import de.danoeh.antennapod.event.settings.SpeedPresetChangedEvent; import de.danoeh.antennapod.event.settings.VolumeAdaptionChangedEvent; @@ -35,9 +34,10 @@ import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedFilter; import de.danoeh.antennapod.model.feed.FeedPreferences; import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.dialog.EpisodeFilterDialog; import de.danoeh.antennapod.dialog.FeedPreferenceSkipDialog; import de.danoeh.antennapod.dialog.TagSettingsDialog; @@ -313,7 +313,7 @@ public class FeedSettingsFragment extends Fragment { } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } - FeedUpdateManager.runOnce(getContext(), feed); + FeedUpdateManager.getInstance().runOnce(getContext(), feed); }, "RefreshAfterCredentialChange").start(); } }.show(); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/InboxFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/InboxFragment.java index 259d92a99..40ce3f823 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/InboxFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/InboxFragment.java @@ -15,7 +15,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.dialog.ItemSortDialog; import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.model.feed.FeedItem; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java index bc741f492..49ef099f9 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java @@ -52,7 +52,7 @@ import de.danoeh.antennapod.adapter.NavListAdapter; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.storage.database.NavDrawerData; import de.danoeh.antennapod.dialog.DrawerPreferencesDialog; import de.danoeh.antennapod.dialog.RemoveFeedDialog; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java index 2faa5ad62..18263b90f 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java @@ -10,7 +10,7 @@ import androidx.annotation.NonNull; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.event.playback.PlaybackHistoryEvent; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 65e16dc5b..126d0d748 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -28,6 +28,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; import com.leinardi.android.speeddial.SpeedDialView; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.ui.episodes.PlaybackSpeedUtils; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -42,10 +43,9 @@ import de.danoeh.antennapod.adapter.QueueRecyclerAdapter; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.ui.common.Converter; import de.danoeh.antennapod.core.util.FeedItemUtil; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.dialog.ItemSortDialog; import de.danoeh.antennapod.event.EpisodeDownloadEvent; import de.danoeh.antennapod.event.FeedItemEvent; @@ -279,7 +279,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte new QueueSortDialog().show(getChildFragmentManager().beginTransaction(), "SortDialog"); return true; } else if (itemId == R.id.refresh_item) { - FeedUpdateManager.runOnceOrAsk(requireContext()); + FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()); return true; } else if (itemId == R.id.clear_queue) { // make sure the user really wants to clear the queue @@ -428,7 +428,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); + swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.getInstance().runOnceOrAsk(requireContext())); emptyView = new EmptyViewHandler(getContext()); emptyView.attachToRecyclerView(recyclerView); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java index 299117aec..dcc78f152 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -22,6 +22,7 @@ import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.leinardi.android.speeddial.SpeedDialView; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -36,7 +37,6 @@ import de.danoeh.antennapod.adapter.SubscriptionsRecyclerAdapter; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.NavDrawerData; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.dialog.FeedSortDialog; import de.danoeh.antennapod.dialog.RenameItemDialog; import de.danoeh.antennapod.dialog.SubscriptionsFilterDialog; @@ -170,7 +170,7 @@ public class SubscriptionFragment extends Fragment swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); + swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.getInstance().runOnceOrAsk(requireContext())); speedDialView = root.findViewById(R.id.fabSD); speedDialView.setOverlayLayout(root.findViewById(R.id.fabSDOverlay)); @@ -204,7 +204,7 @@ public class SubscriptionFragment extends Fragment public boolean onMenuItemClick(MenuItem item) { final int itemId = item.getItemId(); if (itemId == R.id.refresh_item) { - FeedUpdateManager.runOnceOrAsk(requireContext()); + FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()); return true; } else if (itemId == R.id.subscriptions_filter) { new SubscriptionsFilterDialog().show(getChildFragmentManager(), "filter"); 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 ad23b8188..9325037ad 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,7 +11,7 @@ import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.storage.database.LongList; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.view.LocalDeleteModal; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java b/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java index b5a9215e6..5a6b4ffa9 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java @@ -14,7 +14,7 @@ import java.util.Locale; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.databinding.PlaybackSpeedFeedSettingDialogBinding; import de.danoeh.antennapod.dialog.RemoveFeedDialog; import de.danoeh.antennapod.dialog.TagSettingsDialog; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java index 27028eaa2..58e968155 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadsPreferencesFragment.java @@ -10,7 +10,7 @@ import androidx.preference.TwoStatePreference; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.PreferenceActivity; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.ui.preferences.screen.downloads.ChooseDataFolderDialog; import de.danoeh.antennapod.dialog.ProxyDialog; import de.danoeh.antennapod.storage.preferences.UserPreferences; @@ -90,7 +90,7 @@ public class DownloadsPreferencesFragment extends PreferenceFragmentCompat @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (UserPreferences.PREF_UPDATE_INTERVAL.equals(key)) { - FeedUpdateManager.restartUpdateAlarm(getContext(), true); + FeedUpdateManager.getInstance().restartUpdateAlarm(getContext(), true); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/AddToQueueSwipeAction.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/AddToQueueSwipeAction.java index 729f35291..06efda3ee 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/AddToQueueSwipeAction.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/AddToQueueSwipeAction.java @@ -5,7 +5,7 @@ import android.content.Context; import androidx.fragment.app.Fragment; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/DeleteSwipeAction.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/DeleteSwipeAction.java index 462fcf968..52f214eed 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/DeleteSwipeAction.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/DeleteSwipeAction.java @@ -6,7 +6,7 @@ import androidx.fragment.app.Fragment; import java.util.Collections; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; import de.danoeh.antennapod.view.LocalDeleteModal; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/MarkFavoriteSwipeAction.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/MarkFavoriteSwipeAction.java index 162003fab..dcea8c031 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/MarkFavoriteSwipeAction.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/MarkFavoriteSwipeAction.java @@ -5,7 +5,7 @@ import android.content.Context; import androidx.fragment.app.Fragment; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromHistorySwipeAction.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromHistorySwipeAction.java index 385beb2dd..46285734e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromHistorySwipeAction.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromHistorySwipeAction.java @@ -10,7 +10,7 @@ import java.util.Date; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromQueueSwipeAction.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromQueueSwipeAction.java index f4d2bb6c8..f5cbf66c6 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromQueueSwipeAction.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/RemoveFromQueueSwipeAction.java @@ -9,7 +9,7 @@ import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java index b4b6112ff..2465b162b 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -16,12 +16,12 @@ import java.util.Arrays; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.net.sync.serviceinterface.SynchronizationQueueSink; import de.danoeh.antennapod.storage.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.util.FeedUtil; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.storage.preferences.SynchronizationSettings; -import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.PlaybackStatus; @@ -30,6 +30,7 @@ import de.danoeh.antennapod.dialog.ShareDialog; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.net.sync.model.EpisodeAction; +import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.ui.appstartintent.MediaButtonStarter; import de.danoeh.antennapod.view.LocalDeleteModal; @@ -230,8 +231,14 @@ public class FeedItemMenuHandler { final Handler h = new Handler(fragment.requireContext().getMainLooper()); final Runnable r = () -> { FeedMedia media = item.getMedia(); + if (media == null) { + return; + } boolean shouldAutoDelete = FeedUtil.shouldAutoDeleteItemsOnThatFeed(item.getFeed()); - if (media != null && FeedItemUtil.hasAlmostEnded(media) && shouldAutoDelete) { + int smartMarkAsPlayedSecs = UserPreferences.getSmartMarkAsPlayedSecs(); + boolean almostEnded = media.getDuration() > 0 + && media.getPosition() >= media.getDuration() - smartMarkAsPlayedSecs * 1000; + if (almostEnded && shouldAutoDelete) { DBWriter.deleteFeedMediaOfItem(fragment.requireContext(), media); } }; diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java index eac1e9304..c0448884d 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java @@ -8,7 +8,7 @@ import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; -import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.dialog.RemoveFeedDialog; import de.danoeh.antennapod.dialog.RenameItemDialog; import de.danoeh.antennapod.dialog.TagSettingsDialog; 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 9b3b40b45..641355d5c 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java @@ -6,7 +6,7 @@ import android.content.Intent; import android.util.Log; import de.danoeh.antennapod.core.ClientConfigurator; -import de.danoeh.antennapod.core.storage.AutoDownloadManager; +import de.danoeh.antennapod.net.download.serviceinterface.AutoDownloadManager; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; @@ -32,7 +32,7 @@ public class PowerConnectionReceiver extends BroadcastReceiver { // downloading now. They shouldn't mind. // autodownloadUndownloadedItems will make sure we're on the right wifi networks, // etc... so we don't have to worry about it. - AutoDownloadManager.autodownloadUndownloadedItems(context); + AutoDownloadManager.getInstance().autodownloadUndownloadedItems(context); } else { // if we're not supposed to be auto-downloading when we're not charging, stop it if (!UserPreferences.isEnableAutodownloadOnBattery()) { 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 d6641a1e1..a48ee117b 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java @@ -12,8 +12,8 @@ import java.util.Collections; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.ClientConfigurator; -import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; +import de.danoeh.antennapod.storage.database.FeedDatabaseWriter; import de.danoeh.antennapod.model.feed.Feed; /** @@ -49,6 +49,6 @@ public class SPAReceiver extends BroadcastReceiver{ FeedDatabaseWriter.updateFeed(context, feed, false); } Toast.makeText(context, R.string.sp_apps_importing_feeds_msg, Toast.LENGTH_LONG).show(); - FeedUpdateManager.runOnce(context); + FeedUpdateManager.getInstance().runOnce(context); } } diff --git a/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java index 0837b5e8d..90d4817da 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java @@ -19,6 +19,7 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentContainerView; +import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.ui.echo.EchoConfig; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -32,7 +33,6 @@ import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.databinding.HomeFragmentBinding; import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.FeedUpdateRunningEvent; @@ -83,7 +83,8 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis updateWelcomeScreenVisibility(); viewBinding.swipeRefresh.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - viewBinding.swipeRefresh.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); + viewBinding.swipeRefresh.setOnRefreshListener(() -> + FeedUpdateManager.getInstance().runOnceOrAsk(requireContext())); return viewBinding.getRoot(); } @@ -156,7 +157,7 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis HomeSectionsSettingsDialog.open(getContext(), (dialogInterface, i) -> populateSectionList()); return true; } else if (item.getItemId() == R.id.refresh_item) { - FeedUpdateManager.runOnceOrAsk(requireContext()); + FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()); return true; } else if (item.getItemId() == R.id.action_search) { ((MainActivity) getActivity()).loadChildFragment(SearchFragment.newInstance()); |