Delete core module (#7060)

This commit is contained in:
ByteHamster 2024-04-05 19:20:27 +02:00 committed by GitHub
parent 2143ab1351
commit 92ab575b15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
104 changed files with 223 additions and 669 deletions

View File

@ -62,7 +62,6 @@ android {
}
dependencies {
implementation project(":core")
implementation project(":event")
implementation project(':model')
implementation project(':net:common')
@ -91,6 +90,7 @@ dependencies {
implementation project(':ui:statistics')
implementation project(':net:sync:service-interface')
implementation project(':playback:service')
implementation project(':ui:chapters')
annotationProcessor "androidx.annotation:annotation:$annotationVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"

View File

@ -4,12 +4,15 @@
android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.VIBRATE" />
<supports-screens
android:anyDensity="true"

View File

@ -6,7 +6,7 @@ import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
public class VisitWebsiteActionButton extends ItemActionButton {

View File

@ -22,7 +22,7 @@ import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.ui.common.Converter;
/**

View File

@ -16,7 +16,6 @@ import androidx.recyclerview.widget.RecyclerView;
import de.danoeh.antennapod.ui.SelectableAdapter;
import de.danoeh.antennapod.ui.common.ThemeUtils;
import org.apache.commons.lang3.ArrayUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -25,7 +24,6 @@ import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.ui.screen.episode.ItemPagerFragment;
/**
@ -90,9 +88,7 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol
holder.itemView.setOnClickListener(v -> {
MainActivity activity = mainActivityRef.get();
if (activity != null && !inActionMode()) {
long[] ids = FeedItemUtil.getIds(episodes);
int position = ArrayUtils.indexOf(ids, item.getId());
activity.loadChildFragment(ItemPagerFragment.newInstance(ids, position));
activity.loadChildFragment(ItemPagerFragment.newInstance(episodes, item));
} else {
toggleSelection(holder.getBindingAdapterPosition());
}

View File

@ -36,9 +36,8 @@ import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.util.ConfirmationDialog;
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedItemEvent;
import de.danoeh.antennapod.event.FeedListUpdateEvent;
@ -334,7 +333,7 @@ public abstract class EpisodesListFragment extends Fragment
public void onEventMainThread(FeedItemEvent event) {
Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]");
for (FeedItem item : event.items) {
int pos = FeedItemUtil.indexOfItemWithId(episodes, item.getId());
int pos = FeedItemEvent.indexOfItemWithId(episodes, item.getId());
if (pos >= 0) {
episodes.remove(pos);
if (getFilter().matches(item)) {
@ -378,7 +377,7 @@ public abstract class EpisodesListFragment extends Fragment
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(EpisodeDownloadEvent event) {
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(episodes, downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(episodes, downloadUrl);
if (pos >= 0) {
listAdapter.notifyItemChangedCompat(pos);
}

View File

@ -18,12 +18,10 @@ 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.playback.service.PlaybackServiceInterface;
import de.danoeh.antennapod.storage.database.DBWriter;
import de.danoeh.antennapod.storage.preferences.SynchronizationSettings;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
import de.danoeh.antennapod.playback.service.PlaybackStatus;
import de.danoeh.antennapod.ui.share.ShareUtils;
import de.danoeh.antennapod.ui.share.ShareDialog;
@ -198,7 +196,7 @@ public class FeedItemMenuHandler {
}
DBWriter.markItemPlayed(selectedItem, FeedItem.UNPLAYED, true);
} else if (menuItemId == R.id.visit_website_item) {
IntentUtils.openInBrowser(context, FeedItemUtil.getLinkWithFallback(selectedItem));
IntentUtils.openInBrowser(context, selectedItem.getLinkWithFallback());
} else if (menuItemId == R.id.share_item) {
ShareDialog shareDialog = ShareDialog.newInstance(selectedItem);
shareDialog.show((fragment.getActivity().getSupportFragmentManager()), "ShareEpisodeDialog");
@ -234,7 +232,8 @@ public class FeedItemMenuHandler {
if (media == null) {
return;
}
boolean shouldAutoDelete = FeedUtil.shouldAutoDeleteItemsOnThatFeed(item.getFeed());
boolean shouldAutoDelete = UserPreferences.isAutoDelete()
&& (!item.getFeed().isLocalFeed() || UserPreferences.isAutoDeleteLocal());
int smartMarkAsPlayedSecs = UserPreferences.getSmartMarkAsPlayedSecs();
boolean almostEnded = media.getDuration() > 0
&& media.getPosition() >= media.getDuration() - smartMarkAsPlayedSecs * 1000;

View File

@ -9,10 +9,8 @@ import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.ui.screen.episode.ItemPagerFragment;
import de.danoeh.antennapod.model.feed.FeedItem;
import org.apache.commons.lang3.ArrayUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -68,9 +66,7 @@ public class HorizontalItemListAdapter extends RecyclerView.Adapter<HorizontalIt
holder.card.setOnClickListener(v -> {
MainActivity activity = mainActivityRef.get();
if (activity != null) {
long[] ids = FeedItemUtil.getIds(data);
int clickPosition = ArrayUtils.indexOf(ids, item.getId());
activity.loadChildFragment(ItemPagerFragment.newInstance(ids, clickPosition));
activity.loadChildFragment(ItemPagerFragment.newInstance(data, item));
}
});
}

View File

@ -3,8 +3,7 @@ package de.danoeh.antennapod.ui.episodeslist;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.R;
/**
* Utility methods for the more_content_list_footer layout.

View File

@ -8,7 +8,7 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.util.ConfirmationDialog;
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.storage.database.DBWriter;
import de.danoeh.antennapod.event.playback.PlaybackHistoryEvent;

View File

@ -40,7 +40,6 @@ import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
import de.danoeh.antennapod.ui.episodeslist.EpisodeMultiSelectActionHandler;
import de.danoeh.antennapod.model.feed.Feed;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.ui.episodeslist.FeedItemMenuHandler;
import de.danoeh.antennapod.net.discovery.CombinedSearcher;
import de.danoeh.antennapod.storage.database.DBReader;
@ -327,7 +326,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
}
for (int i = 0, size = event.items.size(); i < size; i++) {
FeedItem item = event.items.get(i);
int pos = FeedItemUtil.indexOfItemWithId(results, item.getId());
int pos = FeedItemEvent.indexOfItemWithId(results, item.getId());
if (pos >= 0) {
results.remove(pos);
results.add(pos, item);
@ -342,7 +341,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
return;
}
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(results, downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(results, downloadUrl);
if (pos >= 0) {
adapter.notifyItemChangedCompat(pos);
}

View File

@ -19,13 +19,13 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.util.ChapterUtils;
import de.danoeh.antennapod.event.playback.PlaybackPositionEvent;
import de.danoeh.antennapod.model.feed.Chapter;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.model.playback.Playable;
import de.danoeh.antennapod.playback.base.PlayerStatus;
import de.danoeh.antennapod.playback.service.PlaybackController;
import de.danoeh.antennapod.ui.chapters.ChapterUtils;
import io.reactivex.Maybe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
@ -130,7 +130,7 @@ public class ChaptersFragment extends AppCompatDialogFragment {
if (controller == null) {
return -1;
}
return ChapterUtils.getCurrentChapterIndex(media, controller.getPosition());
return Chapter.getAfterPosition(media.getChapters(), controller.getPosition());
}
private void loadMediaInfo(boolean forceRefresh) {

View File

@ -19,7 +19,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.model.feed.Chapter;
import de.danoeh.antennapod.ui.common.Converter;
import de.danoeh.antennapod.model.feed.EmbeddedChapterImage;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
import de.danoeh.antennapod.model.playback.Playable;
import de.danoeh.antennapod.ui.common.CircularProgressBar;

View File

@ -23,7 +23,6 @@ import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.ui.screen.SearchFragment;
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.ui.screen.feed.ItemSortDialog;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedItemEvent;
@ -209,7 +208,7 @@ public class CompletedDownloadsFragment extends Fragment
return; // Refreshed anyway
}
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(items, downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(items, downloadUrl);
if (pos >= 0) {
adapter.notifyItemChangedCompat(pos);
}
@ -249,7 +248,7 @@ public class CompletedDownloadsFragment extends Fragment
}
for (int i = 0, size = event.items.size(); i < size; i++) {
FeedItem item = event.items.get(i);
int pos = FeedItemUtil.indexOfItemWithId(items, item.getId());
int pos = FeedItemEvent.indexOfItemWithId(items, item.getId());
if (pos >= 0) {
items.remove(pos);
if (item.getMedia().isDownloaded()) {
@ -305,7 +304,7 @@ public class CompletedDownloadsFragment extends Fragment
return downloadedItems;
}
for (String url : runningDownloads) {
if (FeedItemUtil.indexOfItemWithDownloadUrl(downloadedItems, url) != -1) {
if (EpisodeDownloadEvent.indexOfItemWithDownloadUrl(downloadedItems, url) != -1) {
continue; // Already in list
}
mediaUrls.add(url);

View File

@ -1,8 +1,8 @@
package de.danoeh.antennapod.ui.screen.download;
import androidx.annotation.StringRes;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.model.download.DownloadError;
/**

View File

@ -55,7 +55,7 @@ import java.util.Set;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.screen.preferences.PreferenceActivity;
import de.danoeh.antennapod.core.util.ConfirmationDialog;
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.storage.database.DBWriter;

View File

@ -29,6 +29,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
/**
* Displays information about a list of FeedItems.
*/
@ -41,15 +43,21 @@ public class ItemPagerFragment extends Fragment implements MaterialToolbar.OnMen
/**
* Creates a new instance of an ItemPagerFragment.
*
* @param feeditems The IDs of the FeedItems that belong to the same list
* @param feedItemPos The position of the FeedItem that is currently shown
* @return The ItemFragment instance
*/
public static ItemPagerFragment newInstance(long[] feeditems, int feedItemPos) {
public static ItemPagerFragment newInstance(List<FeedItem> allItems, FeedItem currentItem) {
int position = 0;
long[] ids = new long[allItems.size()];
for (int i = 0; i < allItems.size(); i++) {
ids[i] = allItems.get(i).getId();
if (ids[i] == currentItem.getId()) {
position = i;
}
}
ItemPagerFragment fragment = new ItemPagerFragment();
Bundle args = new Bundle();
args.putLongArray(ARG_FEEDITEMS, feeditems);
args.putInt(ARG_FEEDITEM_POS, Math.max(0, feedItemPos));
args.putLongArray(ARG_FEEDITEMS, ids);
args.putInt(ARG_FEEDITEM_POS, position);
fragment.setArguments(args);
return fragment;
}

View File

@ -37,7 +37,7 @@ import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.TransitionEffect;
import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.storage.database.FeedDatabaseWriter;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
import de.danoeh.antennapod.ui.share.ShareUtils;
import de.danoeh.antennapod.ui.cleaner.HtmlToPlainText;
import de.danoeh.antennapod.model.feed.Feed;

View File

@ -1,6 +1,6 @@
package de.danoeh.antennapod.ui.screen.feed;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.model.feed.FeedItemFilter;
public enum FeedItemFilterGroup {

View File

@ -50,8 +50,7 @@ import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.storage.database.DBReader;
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.ui.common.IntentUtils;
import de.danoeh.antennapod.ui.share.ShareUtils;
import de.danoeh.antennapod.ui.episodeslist.MoreContentListFooterUtil;
import de.danoeh.antennapod.databinding.FeedItemListFragmentBinding;
@ -321,8 +320,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
MainActivity activity = (MainActivity) getActivity();
long[] ids = FeedItemUtil.getIds(feed.getItems());
activity.loadChildFragment(ItemPagerFragment.newInstance(ids, position));
activity.loadChildFragment(ItemPagerFragment.newInstance(feed.getItems(), feed.getItems().get(position)));
}
@Subscribe(threadMode = ThreadMode.MAIN)
@ -341,7 +339,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
}
for (int i = 0, size = event.items.size(); i < size; i++) {
FeedItem item = event.items.get(i);
int pos = FeedItemUtil.indexOfItemWithId(feed.getItems(), item.getId());
int pos = FeedItemEvent.indexOfItemWithId(feed.getItems(), item.getId());
if (pos >= 0) {
feed.getItems().remove(pos);
feed.getItems().add(pos, item);
@ -356,7 +354,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
return;
}
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(feed.getItems(), downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(feed.getItems(), downloadUrl);
if (pos >= 0) {
adapter.notifyItemChangedCompat(pos);
}

View File

@ -11,7 +11,7 @@ import java.util.Collections;
import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.util.ConfirmationDialog;
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
import de.danoeh.antennapod.model.feed.Feed;
import de.danoeh.antennapod.storage.database.DBWriter;
import io.reactivex.Completable;

View File

@ -54,8 +54,8 @@ public class RenameFeedDialog {
renameTag(newTitle);
}
})
.setNeutralButton(de.danoeh.antennapod.core.R.string.reset, null)
.setNegativeButton(de.danoeh.antennapod.core.R.string.cancel_label, null)
.setNeutralButton(R.string.reset, null)
.setNegativeButton(R.string.cancel_label, null)
.show();
// To prevent cancelling the dialog on button click

View File

@ -15,7 +15,6 @@ import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.episodeslist.HorizontalItemListAdapter;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedItemEvent;
import de.danoeh.antennapod.event.PlayerStatusEvent;
@ -105,7 +104,7 @@ public class EpisodesSurpriseSection extends HomeSection {
Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]");
for (int i = 0, size = event.items.size(); i < size; i++) {
FeedItem item = event.items.get(i);
int pos = FeedItemUtil.indexOfItemWithId(episodes, item.getId());
int pos = FeedItemEvent.indexOfItemWithId(episodes, item.getId());
if (pos >= 0) {
episodes.remove(pos);
episodes.add(pos, item);
@ -117,7 +116,7 @@ public class EpisodesSurpriseSection extends HomeSection {
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(EpisodeDownloadEvent event) {
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(episodes, downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(episodes, downloadUrl);
if (pos >= 0) {
listAdapter.notifyItemChangedCompat(pos);
}

View File

@ -16,7 +16,6 @@ import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedItemEvent;
import de.danoeh.antennapod.event.FeedListUpdateEvent;
@ -99,7 +98,7 @@ public class InboxSection extends HomeSection {
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(EpisodeDownloadEvent event) {
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(items, downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(items, downloadUrl);
if (pos >= 0) {
adapter.notifyItemChangedCompat(pos);
}

View File

@ -15,7 +15,6 @@ import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.episodeslist.HorizontalItemListAdapter;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedItemEvent;
import de.danoeh.antennapod.event.PlayerStatusEvent;
@ -92,7 +91,7 @@ public class QueueSection extends HomeSection {
}
for (int i = 0, size = event.items.size(); i < size; i++) {
FeedItem item = event.items.get(i);
int pos = FeedItemUtil.indexOfItemWithId(queue, item.getId());
int pos = FeedItemEvent.indexOfItemWithId(queue, item.getId());
if (pos >= 0) {
queue.remove(pos);
queue.add(pos, item);
@ -104,7 +103,7 @@ public class QueueSection extends HomeSection {
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(EpisodeDownloadEvent event) {
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(queue, downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(queue, downloadUrl);
if (pos >= 0) {
listAdapter.notifyItemChangedCompat(pos);
}

View File

@ -54,7 +54,7 @@ import de.danoeh.antennapod.net.discovery.PodcastSearcherRegistry;
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.ui.common.IntentUtils;
import de.danoeh.antennapod.net.common.UrlChecker;
import de.danoeh.antennapod.ui.cleaner.HtmlToPlainText;
import de.danoeh.antennapod.databinding.OnlinefeedviewActivityBinding;

View File

@ -27,6 +27,7 @@ import com.google.android.material.elevation.SurfaceColors;
import de.danoeh.antennapod.playback.service.PlaybackController;
import de.danoeh.antennapod.ui.appstartintent.MediaButtonStarter;
import de.danoeh.antennapod.ui.chapters.ChapterUtils;
import de.danoeh.antennapod.ui.episodes.PlaybackSpeedUtils;
import de.danoeh.antennapod.ui.episodes.TimeSpeedConverter;
import de.danoeh.antennapod.ui.screen.playback.MediaPlayerErrorDialog;
@ -43,7 +44,6 @@ import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.util.ChapterUtils;
import de.danoeh.antennapod.ui.common.Converter;
import de.danoeh.antennapod.ui.screen.feed.preferences.SkipPreferenceDialog;
import de.danoeh.antennapod.event.FavoritesEvent;
@ -360,7 +360,7 @@ public class AudioPlayerFragment extends Fragment implements
int currentPosition = converter.convert(event.getPosition());
int duration = converter.convert(event.getDuration());
int remainingTime = converter.convert(Math.max(event.getDuration() - event.getPosition(), 0));
currentChapterIndex = ChapterUtils.getCurrentChapterIndex(controller.getMedia(), currentPosition);
currentChapterIndex = Chapter.getAfterPosition(controller.getMedia().getChapters(), currentPosition);
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
if (currentPosition == Playable.INVALID_TIME || duration == Playable.INVALID_TIME) {
Log.w(TAG, "Could not react to position observer update because of invalid time");
@ -406,7 +406,7 @@ public class AudioPlayerFragment extends Fragment implements
float prog = progress / ((float) seekBar.getMax());
TimeSpeedConverter converter = new TimeSpeedConverter(controller.getCurrentPlaybackSpeedMultiplier());
int position = converter.convert((int) (prog * controller.getDuration()));
int newChapterIndex = ChapterUtils.getCurrentChapterIndex(controller.getMedia(), position);
int newChapterIndex = Chapter.getAfterPosition(controller.getMedia().getChapters(), position);
if (newChapterIndex > -1) {
if (!sbPosition.isPressed() && currentChapterIndex != newChapterIndex) {
currentChapterIndex = newChapterIndex;

View File

@ -32,7 +32,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.util.ChapterUtils;
import de.danoeh.antennapod.ui.chapters.ChapterUtils;
import de.danoeh.antennapod.ui.screen.chapter.ChaptersFragment;
import de.danoeh.antennapod.playback.service.PlaybackController;
import de.danoeh.antennapod.ui.common.DateFormatter;
@ -160,7 +160,7 @@ public class CoverFragment extends Fragment {
});
displayedChapterIndex = -1;
refreshChapterData(ChapterUtils.getCurrentChapterIndex(media, media.getPosition())); //calls displayCoverImage
refreshChapterData(Chapter.getAfterPosition(media.getChapters(), media.getPosition()));
updateChapterControlVisibility();
}
@ -261,7 +261,7 @@ public class CoverFragment extends Fragment {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(PlaybackPositionEvent event) {
int newChapterIndex = ChapterUtils.getCurrentChapterIndex(media, event.getPosition());
int newChapterIndex = Chapter.getAfterPosition(media.getChapters(), event.getPosition());
if (newChapterIndex > -1 && newChapterIndex != displayedChapterIndex) {
refreshChapterData(newChapterIndex);
}

View File

@ -48,8 +48,7 @@ import de.danoeh.antennapod.storage.preferences.UserPreferences;
import de.danoeh.antennapod.storage.database.DBReader;
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;
import de.danoeh.antennapod.ui.common.IntentUtils;
import de.danoeh.antennapod.ui.share.ShareUtils;
import de.danoeh.antennapod.databinding.VideoplayerActivityBinding;
import de.danoeh.antennapod.ui.share.ShareDialog;
@ -636,7 +635,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
} else if (StringUtils.isNotBlank(media.getWebsiteLink())) {
return media.getWebsiteLink();
} else if (media instanceof FeedMedia) {
return FeedItemUtil.getLinkWithFallback(((FeedMedia) media).getItem());
return (((FeedMedia) media).getItem()).getLinkWithFallback();
}
return null;
}

View File

@ -25,7 +25,7 @@ import de.danoeh.antennapod.ui.common.ThemeSwitcher;
import de.danoeh.antennapod.CrashReportWriter;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.storage.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
import org.apache.commons.io.IOUtils;
import java.io.File;

View File

@ -13,7 +13,7 @@ import com.bytehamster.lib.preferencesearch.SearchConfiguration;
import com.bytehamster.lib.preferencesearch.SearchPreference;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
import de.danoeh.antennapod.ui.preferences.screen.about.AboutFragment;
public class MainPreferencesFragment extends PreferenceFragmentCompat {

View File

@ -40,12 +40,11 @@ import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter;
import de.danoeh.antennapod.core.util.ConfirmationDialog;
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.storage.database.DBReader;
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.ui.screen.feed.ItemSortDialog;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedItemEvent;
@ -150,7 +149,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
break;
case REMOVED:
case IRREVERSIBLE_REMOVED:
int position = FeedItemUtil.indexOfItemWithId(queue, event.item.getId());
int position = FeedItemEvent.indexOfItemWithId(queue, event.item.getId());
queue.remove(position);
recyclerAdapter.notifyItemRemoved(position);
break;
@ -178,7 +177,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
}
for (int i = 0, size = event.items.size(); i < size; i++) {
FeedItem item = event.items.get(i);
int pos = FeedItemUtil.indexOfItemWithId(queue, item.getId());
int pos = FeedItemEvent.indexOfItemWithId(queue, item.getId());
if (pos >= 0) {
queue.remove(pos);
queue.add(pos, item);
@ -194,7 +193,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
return;
}
for (String downloadUrl : event.getUrls()) {
int pos = FeedItemUtil.indexOfItemWithDownloadUrl(queue, downloadUrl);
int pos = EpisodeDownloadEvent.indexOfItemWithDownloadUrl(queue, downloadUrl);
if (pos >= 0) {
recyclerAdapter.notifyItemChangedCompat(pos);
}
@ -357,7 +356,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
return super.onContextItemSelected(item);
}
int position = FeedItemUtil.indexOfItemWithId(queue, selectedItem.getId());
int position = FeedItemEvent.indexOfItemWithId(queue, selectedItem.getId());
if (position < 0) {
Log.i(TAG, "Selected item no longer exist, ignoring selection");
return super.onContextItemSelected(item);

View File

@ -12,7 +12,7 @@ import androidx.core.text.HtmlCompat;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
import de.danoeh.antennapod.databinding.RatingDialogBinding;
import de.danoeh.antennapod.ui.common.DateFormatter;

View File

@ -7,7 +7,7 @@ import java.util.concurrent.TimeUnit;
import android.util.Log;
import androidx.fragment.app.FragmentActivity;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.storage.database.StatisticsItem;
import io.reactivex.Observable;

View File

@ -7,7 +7,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.util.ConfirmationDialog;
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
import de.danoeh.antennapod.storage.database.DBWriter;
import de.danoeh.antennapod.ui.screen.feed.RemoveFeedDialog;
import de.danoeh.antennapod.ui.screen.feed.RenameFeedDialog;

View File

@ -1,6 +1,6 @@
package de.danoeh.antennapod.ui.screen.subscriptions;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.R;
public enum SubscriptionsFilterGroup {
COUNTER_GREATER_ZERO(new ItemProperties(R.string.subscriptions_counter_greater_zero, "counter_greater_zero")),

View File

@ -9,12 +9,11 @@ import androidx.annotation.NonNull;
import androidx.core.app.ShareCompat;
import androidx.core.content.FileProvider;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.ui.common.Converter;
import java.io.File;
import java.net.URLEncoder;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.model.feed.Feed;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
@ -46,7 +45,7 @@ public class ShareUtils {
}
public static boolean hasLinkToShare(FeedItem item) {
return FeedItemUtil.getLinkWithFallback(item) != null;
return item.getLinkWithFallback() != null;
}
public static void shareMediaDownloadLink(Context context, FeedMedia media) {
@ -64,7 +63,7 @@ public class ShareUtils {
if (hasLinkToShare(item)) {
text += "\n\n" + context.getResources().getString(R.string.share_dialog_episode_website_label) + ": ";
text += FeedItemUtil.getLinkWithFallback(item);
text += item.getLinkWithFallback();
}
if (item.getMedia() != null && item.getMedia().getDownloadUrl() != null) {

View File

@ -26,7 +26,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.ui.common.Converter;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.ui.common.IntentUtils;
import de.danoeh.antennapod.net.common.NetworkUtils;
import de.danoeh.antennapod.ui.share.ShareUtils;
import de.danoeh.antennapod.ui.cleaner.ShownotesCleaner;

1
core/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1,65 +0,0 @@
plugins {
id("com.android.library")
}
apply from: "../common.gradle"
apply from: "../playFlavor.gradle"
android {
namespace "de.danoeh.antennapod.core"
lint {
disable "InvalidPeriodicWorkRequestInterval", "ObsoleteLintCustomCheck", "DefaultLocale", "UnusedAttribute",
"ParcelClassLoader", "CheckResult", "TrustAllX509TrustManager",
"StaticFieldLeak", "IconDensities", "IconDuplicates", "UnsafeOptInUsageError"
}
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = [eventBusIndex: 'de.danoeh.antennapod.core.ApCoreEventBusIndex']
}
}
}
}
dependencies {
implementation project(':model')
implementation project(':net:common')
implementation project(':net:download:service-interface')
implementation project(':parser:feed')
implementation project(':parser:media')
implementation project(':storage:preferences')
implementation project(':storage:database')
implementation project(':ui:common')
annotationProcessor "androidx.annotation:annotation:$annotationVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.core:core:$coreVersion"
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation "androidx.fragment:fragment:$fragmentVersion"
implementation "androidx.preference:preference:$preferenceVersion"
implementation "androidx.work:work-runtime:$workManagerVersion"
implementation "com.google.android.material:material:$googleMaterialVersion"
implementation "org.apache.commons:commons-lang3:$commonslangVersion"
implementation "commons-io:commons-io:$commonsioVersion"
implementation "org.jsoup:jsoup:$jsoupVersion"
implementation "com.github.bumptech.glide:glide:$glideVersion"
implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion@aar"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVersion"
implementation "org.greenrobot:eventbus:$eventbusVersion"
annotationProcessor "org.greenrobot:eventbus-annotation-processor:$eventbusVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
testImplementation "androidx.test:core:$testCoreVersion"
testImplementation "org.awaitility:awaitility:$awaitilityVersion"
testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation 'javax.inject:javax.inject:1'
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test:runner:$runnerVersion"
androidTestImplementation "androidx.test:rules:$rulesVersion"
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="VectorPath">
<ignore path="res/drawable/ic_settings.xml" />
<ignore path="res/drawable/ic_settings_white.xml" />
</issue>
</lint>

View File

@ -1,15 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
</manifest>

View File

@ -1,69 +0,0 @@
package de.danoeh.antennapod.core.util;
import androidx.annotation.NonNull;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import de.danoeh.antennapod.model.feed.FeedItem;
public class FeedItemUtil {
private FeedItemUtil(){}
public static int indexOfItemWithId(List<FeedItem> items, long id) {
for(int i=0; i < items.size(); i++) {
FeedItem item = items.get(i);
if(item != null && item.getId() == id) {
return i;
}
}
return -1;
}
public static int indexOfItemWithDownloadUrl(List<FeedItem> items, String downloadUrl) {
for (int i = 0; i < items.size(); i++) {
FeedItem item = items.get(i);
if (item != null && item.getMedia() != null && item.getMedia().getDownloadUrl().equals(downloadUrl)) {
return i;
}
}
return -1;
}
public static long[] getIds(List<FeedItem> items) {
if(items == null || items.size() == 0) {
return new long[0];
}
long[] result = new long[items.size()];
for(int i=0; i < items.size(); i++) {
result[i] = items.get(i).getId();
}
return result;
}
@NonNull
public static List<Long> getIdList(List<? extends FeedItem> items) {
List<Long> result = new ArrayList<>();
for (FeedItem item : items) {
result.add(item.getId());
}
return result;
}
/**
* Get the link for the feed item for the purpose of Share. It fallbacks to
* use the feed's link if the named feed item has no link.
*/
public static String getLinkWithFallback(FeedItem item) {
if (item == null) {
return null;
} else if (StringUtils.isNotBlank(item.getLink())) {
return item.getLink();
} else if (StringUtils.isNotBlank(item.getFeed().getLink())) {
return item.getFeed().getLink();
}
return null;
}
}

View File

@ -1,13 +0,0 @@
package de.danoeh.antennapod.core.util;
import de.danoeh.antennapod.model.feed.Feed;
import de.danoeh.antennapod.storage.preferences.UserPreferences;
public abstract class FeedUtil {
public static boolean shouldAutoDeleteItemsOnThatFeed(Feed feed) {
if (!UserPreferences.isAutoDelete()) {
return false;
}
return !feed.isLocalFeed() || UserPreferences.isAutoDeleteLocal();
}
}