Skip to content

Commit

Permalink
Add channel details option to long-press menu (TeamNewPipe/NewPipe#5851)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
triallax authored and tossj committed Apr 22, 2021
1 parent bf38f97 commit 14b02b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -350,7 +351,7 @@ protected void showStreamDialog(final StreamInfoItem item) {
return;
}

final ArrayList<StreamDialogEntry> entries = new ArrayList<>();
final List<StreamDialogEntry> entries = new ArrayList<>();

if (PlayerHolder.getType() != null) {
entries.add(StreamDialogEntry.enqueue);
Expand All @@ -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,
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>
* <br>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@
<string name="play_queue_stream_detail">Details</string>
<string name="play_queue_audio_settings">Audio Settings</string>
<string name="hold_to_append">Hold to enqueue</string>
<string name="show_channel_details">Show channel details</string>
<string name="enqueue_stream">Enqueue</string>
<string name="enqueued">Enqueued</string>
<string name="start_here_on_main">Start playing here</string>
Expand Down

0 comments on commit 14b02b9

Please sign in to comment.