diff options
author | ByteHamster <info@bytehamster.com> | 2022-04-02 11:59:41 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-04-02 12:03:44 +0200 |
commit | 4a91d6f5dea2c050b3713c8fc899d11ce9272dd6 (patch) | |
tree | bc371f7b6d7852b3fbc41a7f22a94b8486c32d33 /app/src | |
parent | 310eccc4ce0d90d95c7f34439ffcc3b29b007c42 (diff) | |
parent | 832b51de7def1f63780c285991733522e6fbd333 (diff) | |
download | AntennaPod-4a91d6f5dea2c050b3713c8fc899d11ce9272dd6.zip |
Merge branch 'master' into develop
Diffstat (limited to 'app/src')
14 files changed, 62 insertions, 21 deletions
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 3dfe661d1..7a26759cc 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -51,7 +51,6 @@ import de.danoeh.antennapod.core.service.download.HttpDownloader; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.core.util.FileNameGenerator; import de.danoeh.antennapod.parser.feed.FeedHandler; import de.danoeh.antennapod.parser.feed.FeedHandlerResult; import de.danoeh.antennapod.model.download.DownloadError; @@ -292,12 +291,11 @@ public class OnlineFeedViewActivity extends AppCompatActivity { Log.d(TAG, "Starting feed download"); url = URLChecker.prepareURL(url); feed = new Feed(url, null); - String fileUrl = new File(getExternalCacheDir(), - FileNameGenerator.generateFileName(feed.getDownload_url())).toString(); - feed.setFile_url(fileUrl); - final DownloadRequest request = new DownloadRequest(feed.getFile_url(), - feed.getDownload_url(), "OnlineFeed", 0, Feed.FEEDFILETYPE_FEED, username, password, - true, null, true); + DownloadRequest request = DownloadRequestCreator.create(feed) + .withAuthentication(username, password) + .withInitiatedByUser(true) + .build(); + feed.setFile_url(request.getDestination()); download = Observable.fromCallable(() -> { feeds = DBReader.getFeedList(); 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 80437abbb..cf0a96e91 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java @@ -266,7 +266,7 @@ public class CompletedDownloadsFragment extends Fragment implements speedDialView.setVisibility(View.GONE); } - private static class CompletedDownloadsListAdapter extends EpisodeItemListAdapter { + private class CompletedDownloadsListAdapter extends EpisodeItemListAdapter { public CompletedDownloadsListAdapter(MainActivity mainActivity) { super(mainActivity); @@ -286,6 +286,7 @@ public class CompletedDownloadsFragment extends Fragment implements if (!inActionMode()) { menu.findItem(R.id.multi_select).setVisible(true); } + MenuItemUtils.setOnClickListeners(menu, CompletedDownloadsFragment.this::onContextItemSelected); } } } 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 dd2afeeba..0a402a14b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.fragment; import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextMenu; import android.view.KeyEvent; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; @@ -286,7 +287,13 @@ public abstract class EpisodesListFragment extends Fragment { */ private void createRecycleAdapter(RecyclerView recyclerView, EmptyViewHandler emptyViewHandler) { MainActivity mainActivity = (MainActivity) getActivity(); - listAdapter = new EpisodeItemListAdapter(mainActivity); + listAdapter = new EpisodeItemListAdapter(mainActivity) { + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + MenuItemUtils.setOnClickListeners(menu, EpisodesListFragment.this::onContextItemSelected); + } + }; listAdapter.updateItems(episodes); recyclerView.setAdapter(listAdapter); emptyViewHandler.updateAdapter(listAdapter); 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 9784f521d..fbba99663 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java @@ -309,7 +309,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem if (itemId == R.id.rename_item) { new RenameItemDialog(getActivity(), feed).show(); return true; - } else if (itemId == R.id.remove_item) { + } else if (itemId == R.id.remove_feed) { ((MainActivity) getActivity()).loadFragment(EpisodesFragment.TAG, null); RemoveFeedDialog.show(getContext(), feed); return true; @@ -655,7 +655,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem } } - private static class FeedItemListAdapter extends EpisodeItemListAdapter { + private class FeedItemListAdapter extends EpisodeItemListAdapter { public FeedItemListAdapter(MainActivity mainActivity) { super(mainActivity); } @@ -671,6 +671,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem if (!inActionMode()) { menu.findItem(R.id.multi_select).setVisible(true); } + MenuItemUtils.setOnClickListeners(menu, FeedItemlistFragment.this::onContextItemSelected); } } } 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 a5cabeb29..bd4f3dd21 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java @@ -28,6 +28,7 @@ import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.adapter.NavListAdapter; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; +import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.QueueEvent; import de.danoeh.antennapod.event.UnreadItemsUpdateEvent; @@ -132,6 +133,7 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS } else { inflater.inflate(R.menu.nav_folder_context, menu); } + MenuItemUtils.setOnClickListeners(menu, this::onContextItemSelected); } @Override @@ -169,7 +171,7 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS } else if (itemId == R.id.rename_item) { new RenameItemDialog(getActivity(), feed).show(); return true; - } else if (itemId == R.id.remove_item) { + } else if (itemId == R.id.remove_feed) { ((MainActivity) getActivity()).loadFragment(EpisodesFragment.TAG, null); RemoveFeedDialog.show(getContext(), feed); return true; 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 54c98c0ce..857b59967 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.fragment; import android.os.Bundle; import android.util.Log; +import android.view.ContextMenu; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; @@ -17,6 +18,7 @@ import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; import de.danoeh.antennapod.core.event.DownloadEvent; import de.danoeh.antennapod.core.event.DownloaderUpdate; +import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.playback.PlaybackHistoryEvent; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; @@ -245,7 +247,7 @@ public class PlaybackHistoryFragment extends Fragment implements Toolbar.OnMenuI return history; } - private static class PlaybackHistoryListAdapter extends EpisodeItemListAdapter { + private class PlaybackHistoryListAdapter extends EpisodeItemListAdapter { public PlaybackHistoryListAdapter(MainActivity mainActivity) { super(mainActivity); @@ -258,5 +260,11 @@ public class PlaybackHistoryFragment extends Fragment implements Toolbar.OnMenuI // it harder to read. holder.itemView.setAlpha(1.0f); } + + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + MenuItemUtils.setOnClickListeners(menu, PlaybackHistoryFragment.this::onContextItemSelected); + } } } 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 a79e066e1..2a89519a5 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.util.Log; +import android.view.ContextMenu; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; @@ -522,7 +523,13 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi if (queue != null) { if (recyclerAdapter == null) { MainActivity activity = (MainActivity) getActivity(); - recyclerAdapter = new QueueRecyclerAdapter(activity, swipeActions); + recyclerAdapter = new QueueRecyclerAdapter(activity, swipeActions) { + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + MenuItemUtils.setOnClickListeners(menu, QueueFragment.this::onContextItemSelected); + } + }; recyclerAdapter.setOnSelectModeListener(this); recyclerView.setAdapter(recyclerAdapter); emptyView.updateAdapter(recyclerAdapter); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java index 1a3962de2..0142498a8 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java @@ -7,6 +7,7 @@ import android.os.Handler; import android.os.Looper; import android.util.Log; import android.util.Pair; +import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -29,6 +30,7 @@ import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; import de.danoeh.antennapod.adapter.FeedSearchResultAdapter; import de.danoeh.antennapod.core.event.DownloadEvent; import de.danoeh.antennapod.core.event.DownloaderUpdate; +import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; import de.danoeh.antennapod.event.PlayerStatusEvent; @@ -129,7 +131,13 @@ public class SearchFragment extends Fragment { recyclerView = layout.findViewById(R.id.recyclerView); recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool()); - adapter = new EpisodeItemListAdapter((MainActivity) getActivity()); + adapter = new EpisodeItemListAdapter((MainActivity) getActivity()) { + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + MenuItemUtils.setOnClickListeners(menu, SearchFragment.this::onContextItemSelected); + } + }; recyclerView.setAdapter(adapter); RecyclerView recyclerViewFeeds = layout.findViewById(R.id.recyclerViewFeeds); 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 75d8aea82..ec3240496 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -8,6 +8,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.util.Log; +import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -256,7 +257,13 @@ public class SubscriptionFragment extends Fragment @Override public void onViewCreated(@NonNull View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); - subscriptionAdapter = new SubscriptionsRecyclerAdapter((MainActivity) getActivity()); + subscriptionAdapter = new SubscriptionsRecyclerAdapter((MainActivity) getActivity()) { + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + MenuItemUtils.setOnClickListeners(menu, SubscriptionFragment.this::onContextItemSelected); + } + }; subscriptionAdapter.setOnSelectModeListener(this); subscriptionRecycler.setAdapter(subscriptionAdapter); setupEmptyView(); @@ -361,7 +368,7 @@ public class SubscriptionFragment extends Fragment } else if (itemId == R.id.rename_item) { new RenameItemDialog(getActivity(), feed).show(); return true; - } else if (itemId == R.id.remove_item) { + } else if (itemId == R.id.remove_feed) { RemoveFeedDialog.show(getContext(), feed); return true; } else if (itemId == R.id.multi_select) { 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 9067b17a7..5cd0f26ab 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 @@ -34,7 +34,7 @@ public class FeedMultiSelectActionHandler { } public void handleAction(int id) { - if (id == R.id.remove_item) { + if (id == R.id.remove_feed) { RemoveFeedDialog.show(activity, selectedItems); } else if (id == R.id.keep_updated) { keepUpdatedPrefHandler(); diff --git a/app/src/main/java/de/danoeh/antennapod/view/ShownotesWebView.java b/app/src/main/java/de/danoeh/antennapod/view/ShownotesWebView.java index ae6e88c45..22744eee6 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/ShownotesWebView.java +++ b/app/src/main/java/de/danoeh/antennapod/view/ShownotesWebView.java @@ -25,6 +25,7 @@ import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.NetworkUtils; @@ -170,6 +171,7 @@ public class ShownotesWebView extends WebView implements View.OnLongClickListene menu.add(Menu.NONE, R.id.share_url_item, Menu.NONE, R.string.share_url_label); menu.setHeaderTitle(selectedUrl); } + MenuItemUtils.setOnClickListeners(menu, this::onContextItemSelected); } public void setTimecodeSelectedListener(Consumer<Integer> timecodeSelectedListener) { diff --git a/app/src/main/res/menu/feedlist.xml b/app/src/main/res/menu/feedlist.xml index 12cbc2e5e..3c66ec4ba 100644 --- a/app/src/main/res/menu/feedlist.xml +++ b/app/src/main/res/menu/feedlist.xml @@ -70,7 +70,7 @@ custom:showAsAction="never" /> <item - android:id="@+id/remove_item" + android:id="@+id/remove_feed" android:icon="@drawable/ic_delete" android:menuCategory="container" android:title="@string/remove_feed_label" diff --git a/app/src/main/res/menu/nav_feed_action_speeddial.xml b/app/src/main/res/menu/nav_feed_action_speeddial.xml index d08aa645f..15f2511fb 100644 --- a/app/src/main/res/menu/nav_feed_action_speeddial.xml +++ b/app/src/main/res/menu/nav_feed_action_speeddial.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item - android:id="@+id/remove_item" + android:id="@+id/remove_feed" android:menuCategory="container" android:title="@string/remove_feed_label" android:icon="@drawable/ic_delete"/> diff --git a/app/src/main/res/menu/nav_feed_context.xml b/app/src/main/res/menu/nav_feed_context.xml index 3f5127f36..445ce91df 100644 --- a/app/src/main/res/menu/nav_feed_context.xml +++ b/app/src/main/res/menu/nav_feed_context.xml @@ -17,7 +17,7 @@ android:title="@string/rename_feed_label" /> <item - android:id="@+id/remove_item" + android:id="@+id/remove_feed" android:menuCategory="container" android:title="@string/remove_feed_label" /> |