Invert behavior of playback state swipe action to first remove from inbox

This commit is contained in:
ByteHamster 2022-05-06 23:14:47 +02:00
parent 01bddcc0a9
commit 5ae471ad0a
5 changed files with 10 additions and 10 deletions

View File

@ -59,6 +59,7 @@ public class SwipeActionsDialog {
switch (tag) {
case InboxFragment.TAG:
forFragment = context.getString(R.string.inbox_label);
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.TOGGLE_PLAYED)).toList();
break;
case EpisodesFragment.TAG:
forFragment = context.getString(R.string.episodes_label);

View File

@ -15,7 +15,7 @@ public interface SwipeAction {
String REMOVE_FROM_INBOX = "REMOVE_FROM_INBOX";
String START_DOWNLOAD = "START_DOWNLOAD";
String MARK_FAV = "MARK_FAV";
String MARK_PLAYED = "MARK_PLAYED";
String TOGGLE_PLAYED = "MARK_PLAYED";
String REMOVE_FROM_QUEUE = "REMOVE_FROM_QUEUE";
String getId();

View File

@ -38,7 +38,7 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life
public static final List<SwipeAction> swipeActions = Collections.unmodifiableList(
Arrays.asList(new AddToQueueSwipeAction(), new RemoveFromInboxSwipeAction(),
new StartDownloadSwipeAction(), new MarkFavoriteSwipeAction(),
new MarkPlayedSwipeAction(), new RemoveFromQueueSwipeAction())
new TogglePlaybackStateSwipeAction(), new RemoveFromQueueSwipeAction())
);
private final Fragment fragment;

View File

@ -9,11 +9,11 @@ import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedItemFilter;
public class MarkPlayedSwipeAction implements SwipeAction {
public class TogglePlaybackStateSwipeAction implements SwipeAction {
@Override
public String getId() {
return MARK_PLAYED;
return TOGGLE_PLAYED;
}
@Override
@ -28,19 +28,17 @@ public class MarkPlayedSwipeAction implements SwipeAction {
@Override
public String getTitle(Context context) {
return context.getString(R.string.mark_read_label);
return context.getString(R.string.toggle_played_label);
}
@Override
public void performAction(FeedItem item, Fragment fragment, FeedItemFilter filter) {
int togglePlayState =
item.getPlayState() != FeedItem.PLAYED ? FeedItem.PLAYED : FeedItem.UNPLAYED;
FeedItemMenuHandler.markReadWithUndo(fragment,
item, togglePlayState, willRemove(filter));
int newState = item.getPlayState() == FeedItem.UNPLAYED ? FeedItem.PLAYED : FeedItem.UNPLAYED;
FeedItemMenuHandler.markReadWithUndo(fragment, item, newState, willRemove(filter));
}
@Override
public boolean willRemove(FeedItemFilter filter) {
return filter.showUnplayed || filter.showPlayed;
return filter.showUnplayed || filter.showPlayed || filter.showNew;
}
}

View File

@ -207,6 +207,7 @@
<string name="remove_inbox_label">Remove from inbox</string>
<string name="removed_inbox_label">Removed from inbox</string>
<string name="mark_read_label">Mark as played</string>
<string name="toggle_played_label">Toggle played state</string>
<string name="marked_as_played_label">Marked as played</string>
<string name="marked_as_unplayed_label">Marked as unplayed</string>
<string name="mark_read_no_media_label">Mark as read</string>