Merge pull request #6056 from ByteHamster/multi-select-remove-inbox

Multi-select to remove from inbox
This commit is contained in:
ByteHamster 2022-09-10 12:44:57 +02:00 committed by GitHub
commit 54bf4d149f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 18 deletions

View File

@ -60,13 +60,15 @@ 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();
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.TOGGLE_PLAYED)
&& !a.getId().equals(SwipeAction.DELETE)).toList();
break;
case AllEpisodesFragment.TAG:
forFragment = context.getString(R.string.episodes_label);
break;
case CompletedDownloadsFragment.TAG:
forFragment = context.getString(R.string.downloads_label);
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_INBOX)).toList();
break;
case FeedItemlistFragment.TAG:
forFragment = context.getString(R.string.feeds_label);

View File

@ -106,6 +106,7 @@ public class CompletedDownloadsFragment extends Fragment
speedDialView.removeActionItemById(R.id.mark_read_batch);
speedDialView.removeActionItemById(R.id.mark_unread_batch);
speedDialView.removeActionItemById(R.id.remove_from_queue_batch);
speedDialView.removeActionItemById(R.id.remove_all_inbox_item);
speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {
@Override
public boolean onMainActionSelected() {

View File

@ -371,6 +371,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
speedDialBinding.fabSD.removeActionItemById(R.id.download_batch);
speedDialBinding.fabSD.removeActionItemById(R.id.delete_batch);
}
speedDialBinding.fabSD.removeActionItemById(R.id.remove_all_inbox_item);
speedDialBinding.fabSD.setVisibility(View.VISIBLE);
updateToolbar();
}

View File

@ -490,6 +490,7 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
speedDialView.removeActionItemById(R.id.mark_read_batch);
speedDialView.removeActionItemById(R.id.mark_unread_batch);
speedDialView.removeActionItemById(R.id.add_to_queue_batch);
speedDialView.removeActionItemById(R.id.remove_all_inbox_item);
speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {
@Override
public boolean onMainActionSelected() {

View File

@ -35,6 +35,8 @@ public class EpisodeMultiSelectActionHandler {
queueChecked(items);
} else if (actionId == R.id.remove_from_queue_batch) {
removeFromQueueChecked(items);
} else if (actionId == R.id.remove_from_inbox_batch) {
removeFromInboxChecked(items);
} else if (actionId == R.id.mark_read_batch) {
markedCheckedPlayed(items);
} else if (actionId == R.id.mark_unread_batch) {
@ -66,6 +68,17 @@ public class EpisodeMultiSelectActionHandler {
showMessage(R.plurals.removed_from_queue_batch_label, checkedIds.length);
}
private void removeFromInboxChecked(List<FeedItem> items) {
LongList markUnplayed = new LongList();
for (FeedItem episode : items) {
if (episode.isNew()) {
markUnplayed.add(episode.getId());
}
}
DBWriter.markItemPlayed(FeedItem.UNPLAYED, markUnplayed.toArray());
showMessage(R.plurals.removed_from_inbox_batch_label, markUnplayed.size());
}
private void markedCheckedPlayed(List<FeedItem> items) {
long[] checkedIds = getSelectedIds(items);
DBWriter.markItemPlayed(FeedItem.PLAYED, checkedIds);

View File

@ -1,34 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the order is opposite of the typical menu:
catered to FAB speed dial, which somehow shows the item in reverse.
E.g., item @id/delete_batch is the first in the xml,
visually it will be shown at the bottom of the list of actions.
-->
<item android:id="@+id/delete_batch"
<item
android:id="@+id/delete_batch"
android:icon="@drawable/ic_delete"
android:title="@string/delete_episode_label"
/>
<item android:id="@+id/download_batch"
android:title="@string/delete_episode_label" />
<item
android:id="@+id/download_batch"
android:icon="@drawable/ic_download"
android:title="@string/download_label"
/>
<item android:id="@+id/mark_unread_batch"
android:title="@string/download_label" />
<item
android:id="@+id/mark_unread_batch"
android:icon="@drawable/ic_mark_unplayed"
android:title="@string/mark_unread_label"
/>
android:title="@string/mark_unread_label" />
<item
android:id="@+id/mark_read_batch"
android:icon="@drawable/ic_mark_played"
android:title="@string/mark_read_label"
/>
<item android:id="@+id/remove_from_queue_batch"
android:title="@string/mark_read_label" />
<item
android:id="@+id/remove_from_queue_batch"
android:icon="@drawable/ic_playlist_remove"
android:title="@string/remove_from_queue_label"
/>
android:title="@string/remove_from_queue_label" />
<item
android:id="@+id/add_to_queue_batch"
android:icon="@drawable/ic_playlist_play"
android:title="@string/add_to_queue_label"
/>
android:title="@string/add_to_queue_label" />
<item
android:id="@+id/remove_from_inbox_batch"
android:icon="@drawable/ic_check"
android:title="@string/remove_inbox_label" />
</menu>

View File

@ -237,6 +237,10 @@
<item quantity="one">%d episode removed from queue.</item>
<item quantity="other">%d episodes removed from queue.</item>
</plurals>
<plurals name="removed_from_inbox_batch_label">
<item quantity="one">%d episode removed from inbox.</item>
<item quantity="other">%d episodes removed from inbox.</item>
</plurals>
<string name="add_to_favorite_label">Add to Favorites</string>
<string name="remove_from_favorite_label">Remove from Favorites</string>
<string name="visit_website_label">Visit Website</string>