Merge pull request #6005 from ByteHamster/tweak-episodes-screen

Tweak 'all episodes' screen
This commit is contained in:
ByteHamster 2022-08-11 22:54:43 +02:00 committed by GitHub
commit 5265e41796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View File

@ -15,7 +15,8 @@ import de.danoeh.antennapod.model.feed.FeedItemFilter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import java.util.Collections; import java.util.ArrayList;
import java.util.HashSet;
/** /**
* Shows all episodes (possibly filtered by user). * Shows all episodes (possibly filtered by user).
@ -33,9 +34,8 @@ public class AllEpisodesFragment extends EpisodesListFragment {
toolbar.setTitle(R.string.episodes_label); toolbar.setTitle(R.string.episodes_label);
updateToolbar(); updateToolbar();
updateFilterUi(); updateFilterUi();
speedDialView.removeActionItemById(R.id.mark_unread_batch); txtvInformation.setOnClickListener(
speedDialView.removeActionItemById(R.id.remove_from_queue_batch); v -> AllEpisodesFilterDialog.newInstance(getFilter()).show(getChildFragmentManager(), null));
speedDialView.removeActionItemById(R.id.delete_batch);
return root; return root;
} }
@ -64,8 +64,13 @@ public class AllEpisodesFragment extends EpisodesListFragment {
AllEpisodesFilterDialog.newInstance(getFilter()).show(getChildFragmentManager(), null); AllEpisodesFilterDialog.newInstance(getFilter()).show(getChildFragmentManager(), null);
return true; return true;
} else if (item.getItemId() == R.id.action_favorites) { } else if (item.getItemId() == R.id.action_favorites) {
onFilterChanged(new AllEpisodesFilterDialog.AllEpisodesFilterChangedEvent(getFilter().showIsFavorite ArrayList<String> filter = new ArrayList<>(getFilter().getValuesList());
? Collections.emptySet() : Collections.singleton(FeedItemFilter.IS_FAVORITE))); if (filter.contains(FeedItemFilter.IS_FAVORITE)) {
filter.remove(FeedItemFilter.IS_FAVORITE);
} else {
filter.add(FeedItemFilter.IS_FAVORITE);
}
onFilterChanged(new AllEpisodesFilterDialog.AllEpisodesFilterChangedEvent(new HashSet<>(filter)));
return true; return true;
} }
return false; return false;
@ -91,5 +96,7 @@ public class AllEpisodesFragment extends EpisodesListFragment {
txtvInformation.setVisibility(View.GONE); txtvInformation.setVisibility(View.GONE);
emptyView.setMessage(R.string.no_all_episodes_label); emptyView.setMessage(R.string.no_all_episodes_label);
} }
toolbar.getMenu().findItem(R.id.action_favorites).setIcon(
getFilter().showIsFavorite ? R.drawable.ic_star : R.drawable.ic_star_border);
} }
} }

View File

@ -18,6 +18,7 @@
android:id="@+id/txtvInformation" android:id="@+id/txtvInformation"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center" android:gravity="center"
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"
android:paddingTop="2dp" android:paddingTop="2dp"

View File

@ -4,6 +4,7 @@ import android.text.TextUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
public class FeedItemFilter implements Serializable { public class FeedItemFilter implements Serializable {
@ -72,6 +73,10 @@ public class FeedItemFilter implements Serializable {
return properties.clone(); return properties.clone();
} }
public List<String> getValuesList() {
return Arrays.asList(properties);
}
public boolean matches(FeedItem item) { public boolean matches(FeedItem item) {
if (showNew && !item.isNew()) { if (showNew && !item.isNew()) {
return false; return false;