From 14b02b94a88c7fd4184d8e883bd33c7b6ab148ac 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 (TeamNewPipe/NewPipe#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 --- .../fragments/list/BaseListFragment.java | 12 +++++++++--- .../schabi/newpipelegacy/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/newpipelegacy/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipelegacy/fragments/list/BaseListFragment.java index 92ce65a3b..379120cb6 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipelegacy/fragments/list/BaseListFragment.java @@ -45,6 +45,7 @@ import java.util.List; import java.util.Queue; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipelegacy.ktx.ViewUtils.animate; import static org.schabi.newpipelegacy.ktx.ViewUtils.animateHideRecyclerViewAllowingScrolling; @@ -124,8 +125,8 @@ public void onResume() { /** * 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 @@ protected void showStreamDialog(final StreamInfoItem item) { return; } - final ArrayList entries = new ArrayList<>(); + final List entries = new ArrayList<>(); if (PlayerHolder.getType() != null) { entries.add(StreamDialogEntry.enqueue); @@ -361,7 +362,7 @@ protected void showStreamDialog(final StreamInfoItem item) { 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 @@ protected void showStreamDialog(final StreamInfoItem item) { 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/newpipelegacy/util/StreamDialogEntry.java b/app/src/main/java/org/schabi/newpipelegacy/util/StreamDialogEntry.java index 2f668b347..8391425c6 100644 --- a/app/src/main/java/org/schabi/newpipelegacy/util/StreamDialogEntry.java +++ b/app/src/main/java/org/schabi/newpipelegacy/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