From 6a9cae3de8cb11e60072d5aa376de00343e7c222 Mon Sep 17 00:00:00 2001 From: Mohammed Anas <6daf084a-8eaf-40fb-86c7-8500077c3b69@anonaddy.me> Date: Sun, 28 Mar 2021 16:32:40 +0000 Subject: [PATCH] Add channel details option to long-press menu (#5851) Add dialog item to open channel details Use `List` as type of `entries` Put channel details item last Only show channel option when channel is present --- .../newpipe/fragments/list/BaseListFragment.java | 12 +++++++++--- .../org/schabi/newpipe/util/StreamDialogEntry.java | 6 ++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index 3c37bd128..38fdbccab 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -45,6 +45,7 @@ import java.util.Arrays; import java.util.List; import java.util.Queue; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.ktx.ViewUtils.animate; import static org.schabi.newpipe.ktx.ViewUtils.animateHideRecyclerViewAllowingScrolling; @@ -124,8 +125,8 @@ public abstract class BaseListFragment extends BaseStateFragment /** * If the default implementation of {@link StateSaver.WriteRead} should be used. * - * @see StateSaver * @param useDefaultStateSaving Whether the default implementation should be used + * @see StateSaver */ public void setUseDefaultStateSaving(final boolean useDefaultStateSaving) { this.useDefaultStateSaving = useDefaultStateSaving; @@ -350,7 +351,7 @@ public abstract class BaseListFragment extends BaseStateFragment return; } - final ArrayList entries = new ArrayList<>(); + final List entries = new ArrayList<>(); if (PlayerHolder.getType() != null) { entries.add(StreamDialogEntry.enqueue); @@ -361,7 +362,7 @@ public abstract class BaseListFragment extends BaseStateFragment StreamDialogEntry.append_playlist, StreamDialogEntry.share )); - } else { + } else { entries.addAll(Arrays.asList( StreamDialogEntry.start_here_on_background, StreamDialogEntry.start_here_on_popup, @@ -372,6 +373,11 @@ public abstract class BaseListFragment extends BaseStateFragment if (KoreUtil.shouldShowPlayWithKodi(context, item.getServiceId())) { entries.add(StreamDialogEntry.play_with_kodi); } + + if (!isNullOrEmpty(item.getUploaderUrl())) { + entries.add(StreamDialogEntry.show_channel_details); + } + StreamDialogEntry.setEnabledEntries(entries); new InfoItemDialog(activity, item, StreamDialogEntry.getCommands(context), diff --git a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java index 73fee32f7..2d59febc2 100644 --- a/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java +++ b/app/src/main/java/org/schabi/newpipe/util/StreamDialogEntry.java @@ -24,6 +24,12 @@ public enum StreamDialogEntry { // enum values with DEFAULT actions // ////////////////////////////////////// + show_channel_details(R.string.show_channel_details, (fragment, item) -> + // For some reason `getParentFragmentManager()` doesn't work, but this does. + NavigationHelper.openChannelFragment(fragment.getActivity().getSupportFragmentManager(), + item.getServiceId(), item.getUploaderUrl(), item.getUploaderName()) + ), + /** * Enqueues the stream automatically to the current PlayerType.
*
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b372bee7f..f6c899919 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -466,6 +466,7 @@ Details Audio Settings Hold to enqueue + Show channel details Enqueue Enqueued Start playing here