summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-09-26 22:48:48 +0200
committerGitHub <noreply@github.com>2024-09-26 22:48:48 +0200
commit7b2ebd8ab0c44560b3ddc0797dcd1f4a3d8bff67 (patch)
treea0c14854e32bd535f647d921119c1019d231e8bb
parent7309f8e8b285e492ce809cf506962a7ff76503fc (diff)
downloadAntennaPod-7b2ebd8ab0c44560b3ddc0797dcd1f4a3d8bff67.zip
Only show relevant actions on multi-select (#7424)
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/SelectableAdapter.java10
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeItemListAdapter.java5
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeMultiSelectActionHandler.java17
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodesListFragment.java13
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/episodeslist/FeedItemMenuHandler.java119
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/episodeslist/HorizontalItemListAdapter.java3
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/InboxFragment.java3
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java13
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java5
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java9
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/playback/video/VideoplayerActivity.java4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/queue/QueueFragment.java12
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/swipeactions/DeleteSwipeAction.java2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/view/LocalDeleteModal.java2
-rw-r--r--app/src/main/res/layout/floating_select_menu.xml2
-rw-r--r--app/src/main/res/layout/floating_select_menu_item.xml5
-rw-r--r--app/src/main/res/menu/episodes_apply_action_speeddial.xml16
-rw-r--r--ui/i18n/src/main/res/values/strings.xml1
19 files changed, 146 insertions, 99 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/SelectableAdapter.java b/app/src/main/java/de/danoeh/antennapod/ui/SelectableAdapter.java
index 4f1317a31..7e67c1e2a 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/SelectableAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/SelectableAdapter.java
@@ -47,7 +47,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- updateTitle();
+ onSelectedItemsUpdated();
toggleSelectAllIcon(menu.findItem(R.id.select_toggle), false);
return false;
}
@@ -59,7 +59,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
shouldSelectLazyLoadedItems = selectAll;
setSelected(0, getItemCount(), selectAll);
toggleSelectAllIcon(item, selectAll);
- updateTitle();
+ onSelectedItemsUpdated();
return true;
}
return false;
@@ -74,7 +74,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
notifyDataSetChanged();
}
});
- updateTitle();
+ onSelectedItemsUpdated();
if (onSelectModeListener != null) {
onSelectModeListener.onStartSelectMode();
@@ -109,7 +109,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
} else {
selectedIds.remove(getItemId(pos));
}
- updateTitle();
+ onSelectedItemsUpdated();
}
/**
@@ -154,7 +154,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
}
}
- protected void updateTitle() {
+ protected void onSelectedItemsUpdated() {
if (actionMode == null) {
return;
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeItemListAdapter.java b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeItemListAdapter.java
index db7991261..9e2b964d4 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeItemListAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeItemListAdapter.java
@@ -20,6 +20,7 @@ import de.danoeh.antennapod.ui.common.ThemeUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import de.danoeh.antennapod.R;
@@ -53,7 +54,7 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol
public void updateItems(List<FeedItem> items) {
episodes = items;
notifyDataSetChanged();
- updateTitle();
+ onSelectedItemsUpdated();
}
@Override
@@ -209,7 +210,7 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol
}
inflater.inflate(R.menu.feeditemlist_context, menu);
menu.setHeaderTitle(longPressedItem.getTitle());
- FeedItemMenuHandler.onPrepareMenu(menu, longPressedItem, R.id.skip_episode_item);
+ FeedItemMenuHandler.onPrepareMenu(menu, Collections.singletonList(longPressedItem), R.id.skip_episode_item);
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeMultiSelectActionHandler.java b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeMultiSelectActionHandler.java
index a655982cb..07f1a8cbc 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeMultiSelectActionHandler.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodeMultiSelectActionHandler.java
@@ -28,19 +28,19 @@ public class EpisodeMultiSelectActionHandler {
}
public void handleAction(List<FeedItem> items) {
- if (actionId == R.id.add_to_queue_batch) {
+ if (actionId == R.id.add_to_queue_item) {
queueChecked(items);
- } else if (actionId == R.id.remove_from_queue_batch) {
+ } else if (actionId == R.id.remove_from_queue_item) {
removeFromQueueChecked(items);
- } else if (actionId == R.id.remove_from_inbox_batch) {
+ } else if (actionId == R.id.remove_inbox_item) {
removeFromInboxChecked(items);
- } else if (actionId == R.id.mark_read_batch) {
+ } else if (actionId == R.id.mark_read_item) {
markedCheckedPlayed(items);
- } else if (actionId == R.id.mark_unread_batch) {
+ } else if (actionId == R.id.mark_unread_item) {
markedCheckedUnplayed(items);
- } else if (actionId == R.id.download_batch) {
+ } else if (actionId == R.id.download_item) {
downloadChecked(items);
- } else if (actionId == R.id.delete_batch) {
+ } else if (actionId == R.id.remove_item) {
LocalDeleteModal.showLocalFeedDeleteWarningIfNecessary(activity, items, () -> deleteChecked(items));
} else {
Log.e(TAG, "Unrecognized speed dial action item. Do nothing. id=" + actionId);
@@ -112,6 +112,9 @@ public class EpisodeMultiSelectActionHandler {
}
private void showMessage(@PluralsRes int msgId, int numItems) {
+ if (numItems == 1) {
+ return;
+ }
totalNumItems += numItems;
activity.runOnUiThread(() -> {
String text = activity.getResources().getQuantityString(msgId, totalNumItems, totalNumItems);
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodesListFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodesListFragment.java
index 08ec14ec0..bd4a085bb 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodesListFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/EpisodesListFragment.java
@@ -177,7 +177,7 @@ public abstract class EpisodesListFragment extends Fragment
swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()));
- listAdapter = new EpisodeItemListAdapter((MainActivity) getActivity()) {
+ listAdapter = new EpisodeItemListAdapter(getActivity()) {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
@@ -186,6 +186,13 @@ public abstract class EpisodesListFragment extends Fragment
}
MenuItemUtils.setOnClickListeners(menu, EpisodesListFragment.this::onContextItemSelected);
}
+
+ @Override
+ protected void onSelectedItemsUpdated() {
+ super.onSelectedItemsUpdated();
+ FeedItemMenuHandler.onPrepareMenu(floatingSelectMenu.getMenu(), getSelectedItems());
+ floatingSelectMenu.updateItemVisibility();
+ }
};
listAdapter.setOnSelectModeListener(this);
recyclerView.setAdapter(listAdapter);
@@ -211,9 +218,9 @@ public abstract class EpisodesListFragment extends Fragment
int confirmationString = 0;
if (listAdapter.getSelectedItems().size() >= 25 || listAdapter.shouldSelectLazyLoadedItems()) {
// Should ask for confirmation
- if (menuItem.getItemId() == R.id.mark_read_batch) {
+ if (menuItem.getItemId() == R.id.mark_read_item) {
confirmationString = R.string.multi_select_mark_played_confirmation;
- } else if (menuItem.getItemId() == R.id.mark_unread_batch) {
+ } else if (menuItem.getItemId() == R.id.mark_unread_item) {
confirmationString = R.string.multi_select_mark_unplayed_confirmation;
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/FeedItemMenuHandler.java
index b03a23d10..874299074 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/FeedItemMenuHandler.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/FeedItemMenuHandler.java
@@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.snackbar.Snackbar;
import java.util.Arrays;
+import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
@@ -47,50 +48,88 @@ public class FeedItemMenuHandler {
* This method should be called in the prepare-methods of menus. It changes
* the visibility of the menu items depending on a FeedItem's attributes.
*
- * @param menu An instance of Menu
- * @param selectedItem The FeedItem for which the menu is supposed to be prepared
+ * @param menu An instance of Menu
+ * @param selectedItems The FeedItem for which the menu is supposed to be prepared
+ * @param excludeIds Menu item that should be excluded
* @return Returns true if selectedItem is not null.
*/
- public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem) {
- if (menu == null || selectedItem == null) {
+ public static boolean onPrepareMenu(Menu menu, List<FeedItem> selectedItems, int... excludeIds) {
+ if (menu == null || selectedItems == null) {
return false;
}
- final boolean hasMedia = selectedItem.getMedia() != null;
- final boolean isPlaying = hasMedia && PlaybackStatus.isPlaying(selectedItem.getMedia());
- final boolean isInQueue = selectedItem.isTagged(FeedItem.TAG_QUEUE);
- final boolean fileDownloaded = hasMedia && selectedItem.getMedia().fileExists();
- final boolean isLocalFile = hasMedia && selectedItem.getFeed().isLocalFeed();
- final boolean isFavorite = selectedItem.isTagged(FeedItem.TAG_FAVORITE);
- final boolean hasTranscript = selectedItem.hasTranscript();
+ boolean canSkip = false;
+ boolean canRemoveFromQueue = false;
+ boolean canAddToQueue = false;
+ boolean canVisitWebsite = selectedItems.size() == 1;
+ boolean canShare = selectedItems.size() == 1;
+ boolean canRemoveFromInbox = false;
+ boolean canMarkPlayed = false;
+ boolean canMarkUnplayed = false;
+ boolean canResetPosition = false;
+ boolean canDelete = false;
+ boolean canDownload = false;
+ boolean canAddFavorite = false;
+ boolean canRemoveFavorite = false;
+ boolean canShowTranscript = selectedItems.size() == 1;
+
+ for (FeedItem item : selectedItems) {
+ boolean hasMedia = item.getMedia() != null;
+ canSkip |= hasMedia && PlaybackStatus.isPlaying(item.getMedia());
+ canRemoveFromQueue |= item.isTagged(FeedItem.TAG_QUEUE);
+ canAddToQueue |= hasMedia && !item.isTagged(FeedItem.TAG_QUEUE);
+ canVisitWebsite |= !item.getFeed().isLocalFeed() && ShareUtils.hasLinkToShare(item);
+ canShare |= !item.getFeed().isLocalFeed();
+ canRemoveFromInbox |= item.isNew();
+ canMarkPlayed |= !item.isPlayed();
+ canMarkUnplayed |= item.isPlayed();
+ canResetPosition |= hasMedia && item.getMedia().getPosition() != 0;
+ canDelete |= hasMedia && item.getMedia().isDownloaded();
+ canDownload |= hasMedia && !item.getMedia().isDownloaded() && !item.getFeed().isLocalFeed();
+ canAddFavorite |= !item.isTagged(FeedItem.TAG_FAVORITE);
+ canRemoveFavorite |= item.isTagged(FeedItem.TAG_FAVORITE);
+ canShowTranscript |= item.hasTranscript();
+ }
- setItemVisibility(menu, R.id.skip_episode_item, isPlaying);
- setItemVisibility(menu, R.id.remove_from_queue_item, isInQueue);
- setItemVisibility(menu, R.id.add_to_queue_item, !isInQueue && selectedItem.getMedia() != null);
- setItemVisibility(menu, R.id.visit_website_item, !selectedItem.getFeed().isLocalFeed()
- && ShareUtils.hasLinkToShare(selectedItem));
- setItemVisibility(menu, R.id.share_item, !selectedItem.getFeed().isLocalFeed());
- setItemVisibility(menu, R.id.remove_inbox_item, selectedItem.isNew());
- setItemVisibility(menu, R.id.mark_read_item, !selectedItem.isPlayed());
- setItemVisibility(menu, R.id.mark_unread_item, selectedItem.isPlayed());
- setItemVisibility(menu, R.id.reset_position, hasMedia && selectedItem.getMedia().getPosition() != 0);
+ if (selectedItems.size() > 1) {
+ canVisitWebsite = false;
+ canShare = false;
+ canShowTranscript = false;
+ }
+
+ setItemVisibility(menu, R.id.skip_episode_item, canSkip);
+ setItemVisibility(menu, R.id.remove_from_queue_item, canRemoveFromQueue);
+ setItemVisibility(menu, R.id.add_to_queue_item, canAddToQueue);
+ setItemVisibility(menu, R.id.visit_website_item, canVisitWebsite);
+ setItemVisibility(menu, R.id.share_item, canShare);
+ setItemVisibility(menu, R.id.remove_inbox_item, canRemoveFromInbox);
+ setItemVisibility(menu, R.id.mark_read_item, canMarkPlayed);
+ setItemVisibility(menu, R.id.mark_unread_item, canMarkUnplayed);
+ setItemVisibility(menu, R.id.reset_position, canResetPosition);
// Display proper strings when item has no media
- if (hasMedia) {
- setItemTitle(menu, R.id.mark_read_item, R.string.mark_read_label);
- setItemTitle(menu, R.id.mark_unread_item, R.string.mark_unread_label);
- } else {
+ if (selectedItems.size() == 1 && selectedItems.get(0).getMedia() == null) {
setItemTitle(menu, R.id.mark_read_item, R.string.mark_read_no_media_label);
setItemTitle(menu, R.id.mark_unread_item, R.string.mark_unread_label_no_media);
+ } else {
+ setItemTitle(menu, R.id.mark_read_item, R.string.mark_read_label);
+ setItemTitle(menu, R.id.mark_unread_item, R.string.mark_unread_label);
}
- setItemVisibility(menu, R.id.add_to_favorites_item, !isFavorite);
- setItemVisibility(menu, R.id.remove_from_favorites_item, isFavorite);
- setItemVisibility(menu, R.id.remove_item, fileDownloaded || isLocalFile);
- setItemVisibility(menu, R.id.transcript_item, hasTranscript);
+ setItemVisibility(menu, R.id.add_to_favorites_item, canAddFavorite);
+ setItemVisibility(menu, R.id.remove_from_favorites_item, canRemoveFavorite);
+ setItemVisibility(menu, R.id.remove_item, canDelete);
+ setItemVisibility(menu, R.id.download_item, canDownload);
+ setItemVisibility(menu, R.id.transcript_item, canShowTranscript);
- if (selectedItem.getFeed().getState() != Feed.STATE_SUBSCRIBED) {
+ if (selectedItems.size() == 1 && selectedItems.get(0).getFeed().getState() != Feed.STATE_SUBSCRIBED) {
setItemVisibility(menu, R.id.mark_read_item, false);
}
+
+ if (excludeIds != null) {
+ for (int id : excludeIds) {
+ setItemVisibility(menu, id, false);
+ }
+ }
return true;
}
@@ -126,26 +165,6 @@ public class FeedItemMenuHandler {
}
/**
- * The same method as {@link #onPrepareMenu(Menu, FeedItem)}, but lets the
- * caller also specify a list of menu items that should not be shown.
- *
- * @param excludeIds Menu item that should be excluded
- * @return true if selectedItem is not null.
- */
- public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem, int... excludeIds) {
- if (menu == null || selectedItem == null) {
- return false;
- }
- boolean rc = onPrepareMenu(menu, selectedItem);
- if (rc && excludeIds != null) {
- for (int id : excludeIds) {
- setItemVisibility(menu, id, false);
- }
- }
- return rc;
- }
-
- /**
* Default menu handling for the given FeedItem.
*
* A Fragment instance, (rather than the more generic Context), is needed as a parameter
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/HorizontalItemListAdapter.java b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/HorizontalItemListAdapter.java
index d4407bf86..df121799f 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/HorizontalItemListAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/episodeslist/HorizontalItemListAdapter.java
@@ -14,6 +14,7 @@ import de.danoeh.antennapod.model.feed.FeedItem;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
public class HorizontalItemListAdapter extends RecyclerView.Adapter<HorizontalItemViewHolder>
@@ -125,7 +126,7 @@ public class HorizontalItemListAdapter extends RecyclerView.Adapter<HorizontalIt
menu.clear();
inflater.inflate(R.menu.feeditemlist_context, menu);
menu.setHeaderTitle(longPressedItem.getTitle());
- FeedItemMenuHandler.onPrepareMenu(menu, longPressedItem, R.id.skip_episode_item);
+ FeedItemMenuHandler.onPrepareMenu(menu, Collections.singletonList(longPressedItem), R.id.skip_episode_item);
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/InboxFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/InboxFragment.java
index 68d7accf6..efad44699 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/InboxFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/InboxFragment.java
@@ -48,9 +48,6 @@ public class InboxFragment extends EpisodesListFragment {
emptyView.setIcon(R.drawable.ic_inbox);
emptyView.setTitle(R.string.no_inbox_head_label);
emptyView.setMessage(R.string.no_inbox_label);
- floatingSelectMenu.getMenu().findItem(R.id.mark_unread_batch).setVisible(false);
- floatingSelectMenu.getMenu().findItem(R.id.remove_from_queue_batch).setVisible(false);
- floatingSelectMenu.getMenu().findItem(R.id.delete_batch).setVisible(false);
return root;
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java
index fa35b57ed..cd7681bf9 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/download/CompletedDownloadsFragment.java
@@ -117,17 +117,13 @@ public class CompletedDownloadsFragment extends Fragment
floatingSelectMenu = root.findViewById(R.id.floatingSelectMenu);
floatingSelectMenu.inflate(R.menu.episodes_apply_action_speeddial);
- floatingSelectMenu.getMenu().findItem(R.id.download_batch).setVisible(false);
- floatingSelectMenu.getMenu().findItem(R.id.mark_read_batch).setVisible(false);
- floatingSelectMenu.getMenu().findItem(R.id.mark_unread_batch).setVisible(false);
- floatingSelectMenu.getMenu().findItem(R.id.remove_from_inbox_batch).setVisible(false);
floatingSelectMenu.setOnMenuItemClickListener(menuItem -> {
if (adapter.getSelectedCount() == 0) {
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected,
Snackbar.LENGTH_SHORT);
return false;
}
- new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), menuItem.getItemId())
+ new EpisodeMultiSelectActionHandler(getActivity(), menuItem.getItemId())
.handleAction(adapter.getSelectedItems());
adapter.endSelectMode();
return true;
@@ -370,6 +366,13 @@ public class CompletedDownloadsFragment extends Fragment
}
MenuItemUtils.setOnClickListeners(menu, CompletedDownloadsFragment.this::onContextItemSelected);
}
+
+ @Override
+ protected void onSelectedItemsUpdated() {
+ super.onSelectedItemsUpdated();
+ FeedItemMenuHandler.onPrepareMenu(floatingSelectMenu.getMenu(), getSelectedItems());
+ floatingSelectMenu.updateItemVisibility();
+ }
}
public static class DownloadsSortDialog extends ItemSortDialog {
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java
index d474b108d..e53f664c9 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemPagerFragment.java
@@ -32,6 +32,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
+import java.util.Collections;
import java.util.List;
/**
@@ -144,10 +145,10 @@ public class ItemPagerFragment extends Fragment implements MaterialToolbar.OnMen
return;
}
if (item.hasMedia()) {
- FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(), item);
+ FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(), Collections.singletonList(item));
} else {
// these are already available via button1 and button2
- FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(), item,
+ FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(), Collections.singletonList(item),
R.id.mark_read_item, R.id.visit_website_item);
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java
index 6dabaa054..83ff50ad1 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java
@@ -412,8 +412,6 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
@Override
public void onStartSelectMode() {
swipeActions.detach();
- viewBinding.floatingSelectMenu.getMenu().findItem(R.id.download_batch).setVisible(!feed.isLocalFeed());
- viewBinding.floatingSelectMenu.setVisibility(View.VISIBLE);
updateRecyclerPadding();
updateToolbar();
}
@@ -695,5 +693,12 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
}
MenuItemUtils.setOnClickListeners(menu, FeedItemlistFragment.this::onContextItemSelected);
}
+
+ @Override
+ protected void onSelectedItemsUpdated() {
+ super.onSelectedItemsUpdated();
+ FeedItemMenuHandler.onPrepareMenu(viewBinding.floatingSelectMenu.getMenu(), getSelectedItems());
+ viewBinding.floatingSelectMenu.updateItemVisibility();
+ }
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java
index 36df4bcf3..269de7d6e 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/audio/AudioPlayerFragment.java
@@ -42,6 +42,7 @@ import org.greenrobot.eventbus.ThreadMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
+import java.util.Collections;
import java.util.List;
import de.danoeh.antennapod.R;
@@ -467,7 +468,8 @@ public class AudioPlayerFragment extends Fragment implements
boolean isFeedMedia = media instanceof FeedMedia;
toolbar.getMenu().findItem(R.id.open_feed_item).setVisible(isFeedMedia);
if (isFeedMedia) {
- FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(), ((FeedMedia) media).getItem());
+ FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(),
+ Collections.singletonList(((FeedMedia) media).getItem()));
}
toolbar.getMenu().findItem(R.id.set_sleeptimer_item).setVisible(!controller.sleepTimerActive());
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/video/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/video/VideoplayerActivity.java
index 2c3c335f9..834bffa5d 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/video/VideoplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/playback/video/VideoplayerActivity.java
@@ -74,6 +74,8 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
+import java.util.Collections;
+
/**
* Activity for playing video files.
*/
@@ -549,7 +551,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
menu.findItem(R.id.open_feed_item).setVisible(isFeedMedia); // FeedMedia implies it belongs to a Feed
if (isFeedMedia) {
- FeedItemMenuHandler.onPrepareMenu(menu, ((FeedMedia) media).getItem());
+ FeedItemMenuHandler.onPrepareMenu(menu, Collections.singletonList(((FeedMedia) media).getItem()));
}
menu.findItem(R.id.set_sleeptimer_item).setVisible(!controller.sleepTimerActive());
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/queue/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/queue/QueueFragment.java
index 2d5f8f629..7832007b3 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/queue/QueueFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/queue/QueueFragment.java
@@ -427,6 +427,14 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
super.onCreateContextMenu(menu, v, menuInfo);
MenuItemUtils.setOnClickListeners(menu, QueueFragment.this::onContextItemSelected);
}
+
+ @Override
+ protected void onSelectedItemsUpdated() {
+ super.onSelectedItemsUpdated();
+ FeedItemMenuHandler.onPrepareMenu(floatingSelectMenu.getMenu(), getSelectedItems(),
+ R.id.add_to_queue_item, R.id.remove_inbox_item);
+ floatingSelectMenu.updateItemVisibility();
+ }
};
recyclerAdapter.setOnSelectModeListener(this);
recyclerView.setAdapter(recyclerAdapter);
@@ -444,15 +452,13 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
floatingSelectMenu = root.findViewById(R.id.floatingSelectMenu);
floatingSelectMenu.inflate(R.menu.episodes_apply_action_speeddial);
- floatingSelectMenu.getMenu().findItem(R.id.add_to_queue_batch).setVisible(false);
- floatingSelectMenu.getMenu().findItem(R.id.remove_from_inbox_batch).setVisible(false);
floatingSelectMenu.setOnMenuItemClickListener(menuItem -> {
if (recyclerAdapter.getSelectedCount() == 0) {
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected,
Snackbar.LENGTH_SHORT);
return false;
}
- new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), menuItem.getItemId())
+ new EpisodeMultiSelectActionHandler(getActivity(), menuItem.getItemId())
.handleAction(recyclerAdapter.getSelectedItems());
recyclerAdapter.endSelectMode();
return true;
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/swipeactions/DeleteSwipeAction.java b/app/src/main/java/de/danoeh/antennapod/ui/swipeactions/DeleteSwipeAction.java
index 1ecfd11e0..affcfbb4b 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/swipeactions/DeleteSwipeAction.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/swipeactions/DeleteSwipeAction.java
@@ -30,7 +30,7 @@ public class DeleteSwipeAction implements SwipeAction {
@Override
public String getTitle(Context context) {
- return context.getString(R.string.delete_episode_label);
+ return context.getString(R.string.delete_label);
}
@Override
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/view/LocalDeleteModal.java b/app/src/main/java/de/danoeh/antennapod/ui/view/LocalDeleteModal.java
index f0a1105c1..1bc210733 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/view/LocalDeleteModal.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/view/LocalDeleteModal.java
@@ -23,7 +23,7 @@ public class LocalDeleteModal {
}
new MaterialAlertDialogBuilder(context)
- .setTitle(R.string.delete_episode_label)
+ .setTitle(R.string.delete_label)
.setMessage(R.string.delete_local_feed_warning_body)
.setPositiveButton(R.string.delete_label, (dialog, which) -> deleteCommand.run())
.setNegativeButton(R.string.cancel_label, null)
diff --git a/app/src/main/res/layout/floating_select_menu.xml b/app/src/main/res/layout/floating_select_menu.xml
index 4a72de0f7..5b422028e 100644
--- a/app/src/main/res/layout/floating_select_menu.xml
+++ b/app/src/main/res/layout/floating_select_menu.xml
@@ -11,7 +11,7 @@
android:layout_height="match_parent"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="16dp"
- app:cardCornerRadius="16dp">
+ app:cardCornerRadius="8dp">
<HorizontalScrollView
android:id="@+id/scrollView"
diff --git a/app/src/main/res/layout/floating_select_menu_item.xml b/app/src/main/res/layout/floating_select_menu_item.xml
index e84acde58..2972794c3 100644
--- a/app/src/main/res/layout/floating_select_menu_item.xml
+++ b/app/src/main/res/layout/floating_select_menu_item.xml
@@ -21,8 +21,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="?android:attr/textColorPrimary"
- android:lines="2"
+ android:maxLines="2"
android:textAlignment="center"
- android:ellipsize="end" />
+ android:ellipsize="end"
+ style="@style/TextAppearance.Material3.BodySmall" />
</LinearLayout>
diff --git a/app/src/main/res/menu/episodes_apply_action_speeddial.xml b/app/src/main/res/menu/episodes_apply_action_speeddial.xml
index 944d2e7c9..fe48c6097 100644
--- a/app/src/main/res/menu/episodes_apply_action_speeddial.xml
+++ b/app/src/main/res/menu/episodes_apply_action_speeddial.xml
@@ -8,37 +8,37 @@
visually it will be shown at the bottom of the list of actions.
-->
<item
- android:id="@+id/delete_batch"
+ android:id="@+id/remove_item"
android:icon="@drawable/ic_delete"
- android:title="@string/delete_episode_label" />
+ android:title="@string/delete_label" />
<item
- android:id="@+id/download_batch"
+ android:id="@+id/download_item"
android:icon="@drawable/ic_download"
android:title="@string/download_label" />
<item
- android:id="@+id/mark_unread_batch"
+ android:id="@+id/mark_unread_item"
android:icon="@drawable/ic_mark_unplayed"
android:title="@string/mark_unread_label" />
<item
- android:id="@+id/mark_read_batch"
+ android:id="@+id/mark_read_item"
android:icon="@drawable/ic_mark_played"
android:title="@string/mark_read_label" />
<item
- android:id="@+id/remove_from_queue_batch"
+ android:id="@+id/remove_from_queue_item"
android:icon="@drawable/ic_playlist_remove"
android:title="@string/remove_from_queue_label" />
<item
- android:id="@+id/add_to_queue_batch"
+ android:id="@+id/add_to_queue_item"
android:icon="@drawable/ic_playlist_play"
android:title="@string/add_to_queue_label" />
<item
- android:id="@+id/remove_from_inbox_batch"
+ android:id="@+id/remove_inbox_item"
android:icon="@drawable/ic_check"
android:title="@string/remove_inbox_label" />
diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml
index da7261498..42cab5f25 100644
--- a/ui/i18n/src/main/res/values/strings.xml
+++ b/ui/i18n/src/main/res/values/strings.xml
@@ -224,7 +224,6 @@
<string name="pause_label">Pause</string>
<string name="stream_label">Stream</string>
<string name="delete_label">Delete</string>
- <string name="delete_episode_label">Delete episode</string>
<plurals name="deleted_multi_episode_batch_label">
<item quantity="one">%d downloaded episode deleted.</item>
<item quantity="other">%d downloaded episodes deleted.</item>