Only show relevant actions on multi-select (#7424)
This commit is contained in:
parent
7309f8e8b2
commit
7b2ebd8ab0
|
@ -47,7 +47,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||||
updateTitle();
|
onSelectedItemsUpdated();
|
||||||
toggleSelectAllIcon(menu.findItem(R.id.select_toggle), false);
|
toggleSelectAllIcon(menu.findItem(R.id.select_toggle), false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
|
||||||
shouldSelectLazyLoadedItems = selectAll;
|
shouldSelectLazyLoadedItems = selectAll;
|
||||||
setSelected(0, getItemCount(), selectAll);
|
setSelected(0, getItemCount(), selectAll);
|
||||||
toggleSelectAllIcon(item, selectAll);
|
toggleSelectAllIcon(item, selectAll);
|
||||||
updateTitle();
|
onSelectedItemsUpdated();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,7 +74,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateTitle();
|
onSelectedItemsUpdated();
|
||||||
|
|
||||||
if (onSelectModeListener != null) {
|
if (onSelectModeListener != null) {
|
||||||
onSelectModeListener.onStartSelectMode();
|
onSelectModeListener.onStartSelectMode();
|
||||||
|
@ -109,7 +109,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
|
||||||
} else {
|
} else {
|
||||||
selectedIds.remove(getItemId(pos));
|
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) {
|
if (actionMode == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import de.danoeh.antennapod.ui.common.ThemeUtils;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
@ -53,7 +54,7 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol
|
||||||
public void updateItems(List<FeedItem> items) {
|
public void updateItems(List<FeedItem> items) {
|
||||||
episodes = items;
|
episodes = items;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
updateTitle();
|
onSelectedItemsUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -209,7 +210,7 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol
|
||||||
}
|
}
|
||||||
inflater.inflate(R.menu.feeditemlist_context, menu);
|
inflater.inflate(R.menu.feeditemlist_context, menu);
|
||||||
menu.setHeaderTitle(longPressedItem.getTitle());
|
menu.setHeaderTitle(longPressedItem.getTitle());
|
||||||
FeedItemMenuHandler.onPrepareMenu(menu, longPressedItem, R.id.skip_episode_item);
|
FeedItemMenuHandler.onPrepareMenu(menu, Collections.singletonList(longPressedItem), R.id.skip_episode_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,19 +28,19 @@ public class EpisodeMultiSelectActionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleAction(List<FeedItem> items) {
|
public void handleAction(List<FeedItem> items) {
|
||||||
if (actionId == R.id.add_to_queue_batch) {
|
if (actionId == R.id.add_to_queue_item) {
|
||||||
queueChecked(items);
|
queueChecked(items);
|
||||||
} else if (actionId == R.id.remove_from_queue_batch) {
|
} else if (actionId == R.id.remove_from_queue_item) {
|
||||||
removeFromQueueChecked(items);
|
removeFromQueueChecked(items);
|
||||||
} else if (actionId == R.id.remove_from_inbox_batch) {
|
} else if (actionId == R.id.remove_inbox_item) {
|
||||||
removeFromInboxChecked(items);
|
removeFromInboxChecked(items);
|
||||||
} else if (actionId == R.id.mark_read_batch) {
|
} else if (actionId == R.id.mark_read_item) {
|
||||||
markedCheckedPlayed(items);
|
markedCheckedPlayed(items);
|
||||||
} else if (actionId == R.id.mark_unread_batch) {
|
} else if (actionId == R.id.mark_unread_item) {
|
||||||
markedCheckedUnplayed(items);
|
markedCheckedUnplayed(items);
|
||||||
} else if (actionId == R.id.download_batch) {
|
} else if (actionId == R.id.download_item) {
|
||||||
downloadChecked(items);
|
downloadChecked(items);
|
||||||
} else if (actionId == R.id.delete_batch) {
|
} else if (actionId == R.id.remove_item) {
|
||||||
LocalDeleteModal.showLocalFeedDeleteWarningIfNecessary(activity, items, () -> deleteChecked(items));
|
LocalDeleteModal.showLocalFeedDeleteWarningIfNecessary(activity, items, () -> deleteChecked(items));
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Unrecognized speed dial action item. Do nothing. id=" + actionId);
|
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) {
|
private void showMessage(@PluralsRes int msgId, int numItems) {
|
||||||
|
if (numItems == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
totalNumItems += numItems;
|
totalNumItems += numItems;
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
String text = activity.getResources().getQuantityString(msgId, totalNumItems, totalNumItems);
|
String text = activity.getResources().getQuantityString(msgId, totalNumItems, totalNumItems);
|
||||||
|
|
|
@ -177,7 +177,7 @@ public abstract class EpisodesListFragment extends Fragment
|
||||||
swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
|
swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
|
||||||
swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()));
|
swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.getInstance().runOnceOrAsk(requireContext()));
|
||||||
|
|
||||||
listAdapter = new EpisodeItemListAdapter((MainActivity) getActivity()) {
|
listAdapter = new EpisodeItemListAdapter(getActivity()) {
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
|
@ -186,6 +186,13 @@ public abstract class EpisodesListFragment extends Fragment
|
||||||
}
|
}
|
||||||
MenuItemUtils.setOnClickListeners(menu, EpisodesListFragment.this::onContextItemSelected);
|
MenuItemUtils.setOnClickListeners(menu, EpisodesListFragment.this::onContextItemSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSelectedItemsUpdated() {
|
||||||
|
super.onSelectedItemsUpdated();
|
||||||
|
FeedItemMenuHandler.onPrepareMenu(floatingSelectMenu.getMenu(), getSelectedItems());
|
||||||
|
floatingSelectMenu.updateItemVisibility();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
listAdapter.setOnSelectModeListener(this);
|
listAdapter.setOnSelectModeListener(this);
|
||||||
recyclerView.setAdapter(listAdapter);
|
recyclerView.setAdapter(listAdapter);
|
||||||
|
@ -211,9 +218,9 @@ public abstract class EpisodesListFragment extends Fragment
|
||||||
int confirmationString = 0;
|
int confirmationString = 0;
|
||||||
if (listAdapter.getSelectedItems().size() >= 25 || listAdapter.shouldSelectLazyLoadedItems()) {
|
if (listAdapter.getSelectedItems().size() >= 25 || listAdapter.shouldSelectLazyLoadedItems()) {
|
||||||
// Should ask for confirmation
|
// 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;
|
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;
|
confirmationString = R.string.multi_select_mark_unplayed_confirmation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.activity.MainActivity;
|
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
|
* 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.
|
* the visibility of the menu items depending on a FeedItem's attributes.
|
||||||
*
|
*
|
||||||
* @param menu An instance of Menu
|
* @param menu An instance of Menu
|
||||||
* @param selectedItem The FeedItem for which the menu is supposed to be prepared
|
* @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.
|
* @return Returns true if selectedItem is not null.
|
||||||
*/
|
*/
|
||||||
public static boolean onPrepareMenu(Menu menu, FeedItem selectedItem) {
|
public static boolean onPrepareMenu(Menu menu, List<FeedItem> selectedItems, int... excludeIds) {
|
||||||
if (menu == null || selectedItem == null) {
|
if (menu == null || selectedItems == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final boolean hasMedia = selectedItem.getMedia() != null;
|
boolean canSkip = false;
|
||||||
final boolean isPlaying = hasMedia && PlaybackStatus.isPlaying(selectedItem.getMedia());
|
boolean canRemoveFromQueue = false;
|
||||||
final boolean isInQueue = selectedItem.isTagged(FeedItem.TAG_QUEUE);
|
boolean canAddToQueue = false;
|
||||||
final boolean fileDownloaded = hasMedia && selectedItem.getMedia().fileExists();
|
boolean canVisitWebsite = selectedItems.size() == 1;
|
||||||
final boolean isLocalFile = hasMedia && selectedItem.getFeed().isLocalFeed();
|
boolean canShare = selectedItems.size() == 1;
|
||||||
final boolean isFavorite = selectedItem.isTagged(FeedItem.TAG_FAVORITE);
|
boolean canRemoveFromInbox = false;
|
||||||
final boolean hasTranscript = selectedItem.hasTranscript();
|
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;
|
||||||
|
|
||||||
setItemVisibility(menu, R.id.skip_episode_item, isPlaying);
|
for (FeedItem item : selectedItems) {
|
||||||
setItemVisibility(menu, R.id.remove_from_queue_item, isInQueue);
|
boolean hasMedia = item.getMedia() != null;
|
||||||
setItemVisibility(menu, R.id.add_to_queue_item, !isInQueue && selectedItem.getMedia() != null);
|
canSkip |= hasMedia && PlaybackStatus.isPlaying(item.getMedia());
|
||||||
setItemVisibility(menu, R.id.visit_website_item, !selectedItem.getFeed().isLocalFeed()
|
canRemoveFromQueue |= item.isTagged(FeedItem.TAG_QUEUE);
|
||||||
&& ShareUtils.hasLinkToShare(selectedItem));
|
canAddToQueue |= hasMedia && !item.isTagged(FeedItem.TAG_QUEUE);
|
||||||
setItemVisibility(menu, R.id.share_item, !selectedItem.getFeed().isLocalFeed());
|
canVisitWebsite |= !item.getFeed().isLocalFeed() && ShareUtils.hasLinkToShare(item);
|
||||||
setItemVisibility(menu, R.id.remove_inbox_item, selectedItem.isNew());
|
canShare |= !item.getFeed().isLocalFeed();
|
||||||
setItemVisibility(menu, R.id.mark_read_item, !selectedItem.isPlayed());
|
canRemoveFromInbox |= item.isNew();
|
||||||
setItemVisibility(menu, R.id.mark_unread_item, selectedItem.isPlayed());
|
canMarkPlayed |= !item.isPlayed();
|
||||||
setItemVisibility(menu, R.id.reset_position, hasMedia && selectedItem.getMedia().getPosition() != 0);
|
canMarkUnplayed |= item.isPlayed();
|
||||||
|
canResetPosition |= hasMedia && item.getMedia().getPosition() != 0;
|
||||||
// Display proper strings when item has no media
|
canDelete |= hasMedia && item.getMedia().isDownloaded();
|
||||||
if (hasMedia) {
|
canDownload |= hasMedia && !item.getMedia().isDownloaded() && !item.getFeed().isLocalFeed();
|
||||||
setItemTitle(menu, R.id.mark_read_item, R.string.mark_read_label);
|
canAddFavorite |= !item.isTagged(FeedItem.TAG_FAVORITE);
|
||||||
setItemTitle(menu, R.id.mark_unread_item, R.string.mark_unread_label);
|
canRemoveFavorite |= item.isTagged(FeedItem.TAG_FAVORITE);
|
||||||
} else {
|
canShowTranscript |= item.hasTranscript();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setItemVisibility(menu, R.id.add_to_favorites_item, !isFavorite);
|
if (selectedItems.size() > 1) {
|
||||||
setItemVisibility(menu, R.id.remove_from_favorites_item, isFavorite);
|
canVisitWebsite = false;
|
||||||
setItemVisibility(menu, R.id.remove_item, fileDownloaded || isLocalFile);
|
canShare = false;
|
||||||
setItemVisibility(menu, R.id.transcript_item, hasTranscript);
|
canShowTranscript = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedItem.getFeed().getState() != Feed.STATE_SUBSCRIBED) {
|
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 (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, 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 (selectedItems.size() == 1 && selectedItems.get(0).getFeed().getState() != Feed.STATE_SUBSCRIBED) {
|
||||||
setItemVisibility(menu, R.id.mark_read_item, false);
|
setItemVisibility(menu, R.id.mark_read_item, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludeIds != null) {
|
||||||
|
for (int id : excludeIds) {
|
||||||
|
setItemVisibility(menu, id, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,26 +164,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.
|
* Default menu handling for the given FeedItem.
|
||||||
*
|
*
|
||||||
|
|
|
@ -14,6 +14,7 @@ import de.danoeh.antennapod.model.feed.FeedItem;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HorizontalItemListAdapter extends RecyclerView.Adapter<HorizontalItemViewHolder>
|
public class HorizontalItemListAdapter extends RecyclerView.Adapter<HorizontalItemViewHolder>
|
||||||
|
@ -125,7 +126,7 @@ public class HorizontalItemListAdapter extends RecyclerView.Adapter<HorizontalIt
|
||||||
menu.clear();
|
menu.clear();
|
||||||
inflater.inflate(R.menu.feeditemlist_context, menu);
|
inflater.inflate(R.menu.feeditemlist_context, menu);
|
||||||
menu.setHeaderTitle(longPressedItem.getTitle());
|
menu.setHeaderTitle(longPressedItem.getTitle());
|
||||||
FeedItemMenuHandler.onPrepareMenu(menu, longPressedItem, R.id.skip_episode_item);
|
FeedItemMenuHandler.onPrepareMenu(menu, Collections.singletonList(longPressedItem), R.id.skip_episode_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,6 @@ public class InboxFragment extends EpisodesListFragment {
|
||||||
emptyView.setIcon(R.drawable.ic_inbox);
|
emptyView.setIcon(R.drawable.ic_inbox);
|
||||||
emptyView.setTitle(R.string.no_inbox_head_label);
|
emptyView.setTitle(R.string.no_inbox_head_label);
|
||||||
emptyView.setMessage(R.string.no_inbox_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;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,17 +117,13 @@ public class CompletedDownloadsFragment extends Fragment
|
||||||
|
|
||||||
floatingSelectMenu = root.findViewById(R.id.floatingSelectMenu);
|
floatingSelectMenu = root.findViewById(R.id.floatingSelectMenu);
|
||||||
floatingSelectMenu.inflate(R.menu.episodes_apply_action_speeddial);
|
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 -> {
|
floatingSelectMenu.setOnMenuItemClickListener(menuItem -> {
|
||||||
if (adapter.getSelectedCount() == 0) {
|
if (adapter.getSelectedCount() == 0) {
|
||||||
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected,
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected,
|
||||||
Snackbar.LENGTH_SHORT);
|
Snackbar.LENGTH_SHORT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), menuItem.getItemId())
|
new EpisodeMultiSelectActionHandler(getActivity(), menuItem.getItemId())
|
||||||
.handleAction(adapter.getSelectedItems());
|
.handleAction(adapter.getSelectedItems());
|
||||||
adapter.endSelectMode();
|
adapter.endSelectMode();
|
||||||
return true;
|
return true;
|
||||||
|
@ -370,6 +366,13 @@ public class CompletedDownloadsFragment extends Fragment
|
||||||
}
|
}
|
||||||
MenuItemUtils.setOnClickListeners(menu, CompletedDownloadsFragment.this::onContextItemSelected);
|
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 {
|
public static class DownloadsSortDialog extends ItemSortDialog {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,10 +145,10 @@ public class ItemPagerFragment extends Fragment implements MaterialToolbar.OnMen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item.hasMedia()) {
|
if (item.hasMedia()) {
|
||||||
FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(), item);
|
FeedItemMenuHandler.onPrepareMenu(toolbar.getMenu(), Collections.singletonList(item));
|
||||||
} else {
|
} else {
|
||||||
// these are already available via button1 and button2
|
// 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);
|
R.id.mark_read_item, R.id.visit_website_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,8 +412,6 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||||
@Override
|
@Override
|
||||||
public void onStartSelectMode() {
|
public void onStartSelectMode() {
|
||||||
swipeActions.detach();
|
swipeActions.detach();
|
||||||
viewBinding.floatingSelectMenu.getMenu().findItem(R.id.download_batch).setVisible(!feed.isLocalFeed());
|
|
||||||
viewBinding.floatingSelectMenu.setVisibility(View.VISIBLE);
|
|
||||||
updateRecyclerPadding();
|
updateRecyclerPadding();
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
}
|
}
|
||||||
|
@ -695,5 +693,12 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||||
}
|
}
|
||||||
MenuItemUtils.setOnClickListeners(menu, FeedItemlistFragment.this::onContextItemSelected);
|
MenuItemUtils.setOnClickListeners(menu, FeedItemlistFragment.this::onContextItemSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSelectedItemsUpdated() {
|
||||||
|
super.onSelectedItemsUpdated();
|
||||||
|
FeedItemMenuHandler.onPrepareMenu(viewBinding.floatingSelectMenu.getMenu(), getSelectedItems());
|
||||||
|
viewBinding.floatingSelectMenu.updateItemVisibility();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
@ -467,7 +468,8 @@ public class AudioPlayerFragment extends Fragment implements
|
||||||
boolean isFeedMedia = media instanceof FeedMedia;
|
boolean isFeedMedia = media instanceof FeedMedia;
|
||||||
toolbar.getMenu().findItem(R.id.open_feed_item).setVisible(isFeedMedia);
|
toolbar.getMenu().findItem(R.id.open_feed_item).setVisible(isFeedMedia);
|
||||||
if (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());
|
toolbar.getMenu().findItem(R.id.set_sleeptimer_item).setVisible(!controller.sleepTimerActive());
|
||||||
|
|
|
@ -74,6 +74,8 @@ import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity for playing video files.
|
* 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
|
menu.findItem(R.id.open_feed_item).setVisible(isFeedMedia); // FeedMedia implies it belongs to a Feed
|
||||||
if (isFeedMedia) {
|
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());
|
menu.findItem(R.id.set_sleeptimer_item).setVisible(!controller.sleepTimerActive());
|
||||||
|
|
|
@ -427,6 +427,14 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
MenuItemUtils.setOnClickListeners(menu, QueueFragment.this::onContextItemSelected);
|
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);
|
recyclerAdapter.setOnSelectModeListener(this);
|
||||||
recyclerView.setAdapter(recyclerAdapter);
|
recyclerView.setAdapter(recyclerAdapter);
|
||||||
|
@ -444,15 +452,13 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
|
||||||
|
|
||||||
floatingSelectMenu = root.findViewById(R.id.floatingSelectMenu);
|
floatingSelectMenu = root.findViewById(R.id.floatingSelectMenu);
|
||||||
floatingSelectMenu.inflate(R.menu.episodes_apply_action_speeddial);
|
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 -> {
|
floatingSelectMenu.setOnMenuItemClickListener(menuItem -> {
|
||||||
if (recyclerAdapter.getSelectedCount() == 0) {
|
if (recyclerAdapter.getSelectedCount() == 0) {
|
||||||
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected,
|
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected,
|
||||||
Snackbar.LENGTH_SHORT);
|
Snackbar.LENGTH_SHORT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), menuItem.getItemId())
|
new EpisodeMultiSelectActionHandler(getActivity(), menuItem.getItemId())
|
||||||
.handleAction(recyclerAdapter.getSelectedItems());
|
.handleAction(recyclerAdapter.getSelectedItems());
|
||||||
recyclerAdapter.endSelectMode();
|
recyclerAdapter.endSelectMode();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class DeleteSwipeAction implements SwipeAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle(Context context) {
|
public String getTitle(Context context) {
|
||||||
return context.getString(R.string.delete_episode_label);
|
return context.getString(R.string.delete_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LocalDeleteModal {
|
||||||
}
|
}
|
||||||
|
|
||||||
new MaterialAlertDialogBuilder(context)
|
new MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.delete_episode_label)
|
.setTitle(R.string.delete_label)
|
||||||
.setMessage(R.string.delete_local_feed_warning_body)
|
.setMessage(R.string.delete_local_feed_warning_body)
|
||||||
.setPositiveButton(R.string.delete_label, (dialog, which) -> deleteCommand.run())
|
.setPositiveButton(R.string.delete_label, (dialog, which) -> deleteCommand.run())
|
||||||
.setNegativeButton(R.string.cancel_label, null)
|
.setNegativeButton(R.string.cancel_label, null)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
app:cardCornerRadius="16dp">
|
app:cardCornerRadius="8dp">
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:id="@+id/scrollView"
|
android:id="@+id/scrollView"
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:lines="2"
|
android:maxLines="2"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:ellipsize="end" />
|
android:ellipsize="end"
|
||||||
|
style="@style/TextAppearance.Material3.BodySmall" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -8,37 +8,37 @@
|
||||||
visually it will be shown at the bottom of the list of actions.
|
visually it will be shown at the bottom of the list of actions.
|
||||||
-->
|
-->
|
||||||
<item
|
<item
|
||||||
android:id="@+id/delete_batch"
|
android:id="@+id/remove_item"
|
||||||
android:icon="@drawable/ic_delete"
|
android:icon="@drawable/ic_delete"
|
||||||
android:title="@string/delete_episode_label" />
|
android:title="@string/delete_label" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/download_batch"
|
android:id="@+id/download_item"
|
||||||
android:icon="@drawable/ic_download"
|
android:icon="@drawable/ic_download"
|
||||||
android:title="@string/download_label" />
|
android:title="@string/download_label" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mark_unread_batch"
|
android:id="@+id/mark_unread_item"
|
||||||
android:icon="@drawable/ic_mark_unplayed"
|
android:icon="@drawable/ic_mark_unplayed"
|
||||||
android:title="@string/mark_unread_label" />
|
android:title="@string/mark_unread_label" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mark_read_batch"
|
android:id="@+id/mark_read_item"
|
||||||
android:icon="@drawable/ic_mark_played"
|
android:icon="@drawable/ic_mark_played"
|
||||||
android:title="@string/mark_read_label" />
|
android:title="@string/mark_read_label" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/remove_from_queue_batch"
|
android:id="@+id/remove_from_queue_item"
|
||||||
android:icon="@drawable/ic_playlist_remove"
|
android:icon="@drawable/ic_playlist_remove"
|
||||||
android:title="@string/remove_from_queue_label" />
|
android:title="@string/remove_from_queue_label" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/add_to_queue_batch"
|
android:id="@+id/add_to_queue_item"
|
||||||
android:icon="@drawable/ic_playlist_play"
|
android:icon="@drawable/ic_playlist_play"
|
||||||
android:title="@string/add_to_queue_label" />
|
android:title="@string/add_to_queue_label" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/remove_from_inbox_batch"
|
android:id="@+id/remove_inbox_item"
|
||||||
android:icon="@drawable/ic_check"
|
android:icon="@drawable/ic_check"
|
||||||
android:title="@string/remove_inbox_label" />
|
android:title="@string/remove_inbox_label" />
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,6 @@
|
||||||
<string name="pause_label">Pause</string>
|
<string name="pause_label">Pause</string>
|
||||||
<string name="stream_label">Stream</string>
|
<string name="stream_label">Stream</string>
|
||||||
<string name="delete_label">Delete</string>
|
<string name="delete_label">Delete</string>
|
||||||
<string name="delete_episode_label">Delete episode</string>
|
|
||||||
<plurals name="deleted_multi_episode_batch_label">
|
<plurals name="deleted_multi_episode_batch_label">
|
||||||
<item quantity="one">%d downloaded episode deleted.</item>
|
<item quantity="one">%d downloaded episode deleted.</item>
|
||||||
<item quantity="other">%d downloaded episodes deleted.</item>
|
<item quantity="other">%d downloaded episodes deleted.</item>
|
||||||
|
|
Loading…
Reference in New Issue