1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

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
This commit is contained in:
Mohammed Anas 2021-03-28 16:32:40 +00:00 committed by GitHub
parent 9f59d4baa3
commit 6a9cae3de8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -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<I, N> extends BaseStateFragment<I>
/**
* 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<I, N> extends BaseStateFragment<I>
return;
}
final ArrayList<StreamDialogEntry> entries = new ArrayList<>();
final List<StreamDialogEntry> entries = new ArrayList<>();
if (PlayerHolder.getType() != null) {
entries.add(StreamDialogEntry.enqueue);
@ -361,7 +362,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
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<I, N> extends BaseStateFragment<I>
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),

View File

@ -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>

View File

@ -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>