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 4b5c260e0..199b8b2da 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
@@ -409,7 +409,7 @@ public abstract class BaseListFragment extends BaseStateFragment
return;
}
- new InfoItemDialog.Builder(activity, this, item).create().show();
+ new InfoItemDialog.Builder(activity, context, this, item).create().show();
}
/*//////////////////////////////////////////////////////////////////////////
diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java
index 14d77b31d..3485678d6 100644
--- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java
@@ -142,8 +142,8 @@ public class PlaylistFragment extends BaseListInfoFragment Create a Builder instance that automatically adds the some default entries
+ * at the top and bottom of the dialog. Create an instance of this Builder Create an instance of this Builder. If {@code addDefaultEntriesAutomatically} is set to {@code true},
+ * some default entries are added to the top and bottom of the dialog.
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ * | ENQUEUE |
+ * | ENQUEUE_HERE |
+ * | START_ON_BACKGROUND |
+ * | START_ON_POPUP |
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ * | entries added manually with |
+ * | addEntry() and addAllEntries() |
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ * | APPEND_PLAYLIST |
+ * | SHARE |
+ * | OPEN_IN_BROWSER |
+ * | PLAY_WITH_KODI |
+ * | MARK_AS_WATCHED |
+ * | SHOW_CHANNEL_DETAILS |
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ *
+ * Please note that some entries are not added depending on the user's preferences,
+ * the item's {@link StreamType} and the current player state.
+ *
+ * @param activity
+ * @param context
+ * @param fragment
+ * @param infoItem the item for this dialog; all entries and their actions work with
+ * this {@link org.schabi.newpipe.extractor.InfoItem}
+ */
public Builder(@NonNull final Activity activity,
+ @NonNull final Context context,
@NonNull final Fragment fragment,
@NonNull final StreamInfoItem infoItem) {
- this(activity, fragment, infoItem, true);
+ this(activity, context, fragment, infoItem, true);
}
/**
- *
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ * | ENQUEUE |
+ * | ENQUEUE_HERE |
+ * | START_ON_BACKGROUND |
+ * | START_ON_POPUP |
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ * | entries added manually with |
+ * | addEntry() and addAllEntries() |
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ * | APPEND_PLAYLIST |
+ * | SHARE |
+ * | OPEN_IN_BROWSER |
+ * | PLAY_WITH_KODI |
+ * | MARK_AS_WATCHED |
+ * | SHOW_CHANNEL_DETAILS |
+ * + - - - - - - - - - - - - - - - - - - - - - -+
+ *
+ * Please note that some entries are not added depending on the user's preferences,
+ * the item's {@link StreamType} and the current player state.
+ *
* @param activity
+ * @param context
* @param fragment
* @param infoItem
- * @param addDefaultEntriesAutomatically whether default entries added with
- * {@link #addDefaultEntriesAtBeginning()} and
- * {@link #addDefaultEntriesAtEnd()}
- * are added automatically when generating
- * the {@link InfoItemDialog}.
+ * @param addDefaultEntriesAutomatically
+ * whether default entries added with {@link #addDefaultBeginningEntries()}
+ * and {@link #addDefaultEndEntries()} are added automatically when generating
+ * the {@link InfoItemDialog}.
+ *
+ * Entries added with {@link #addEntry(StreamDialogDefaultEntry)} and
+ * {@link #addAllEntries(StreamDialogDefaultEntry...)} are added in between.
*/
public Builder(@NonNull final Activity activity,
+ @NonNull final Context context,
@NonNull final Fragment fragment,
@NonNull final StreamInfoItem infoItem,
final boolean addDefaultEntriesAutomatically) {
this.activity = activity;
+ this.context = context;
this.fragment = fragment;
this.infoItem = infoItem;
this.addDefaultEntriesAutomatically = addDefaultEntriesAutomatically;
if (addDefaultEntriesAutomatically) {
- addDefaultEntriesAtBeginning();
+ addDefaultBeginningEntries();
}
}
@@ -139,12 +208,11 @@ public final class InfoItemDialog {
}
}
- public void addChannelDetailsEntryIfPossible() {
- if (!isNullOrEmpty(infoItem.getUploaderUrl())) {
- addEntry(StreamDialogDefaultEntry.SHOW_CHANNEL_DETAILS);
- }
- }
-
+ /**
+ * Adds {@link StreamDialogDefaultEntry#ENQUEUE} if the player is open and
+ * {@link StreamDialogDefaultEntry#ENQUEUE_NEXT} if there are multiple streams
+ * in the play queue.
+ */
public void addEnqueueEntriesIfNeeded() {
if (PlayerHolder.getInstance().isPlayerOpen()) {
addEntry(StreamDialogDefaultEntry.ENQUEUE);
@@ -155,6 +223,11 @@ public final class InfoItemDialog {
}
}
+ /**
+ * Adds the {@link StreamDialogDefaultEntry#START_HERE_ON_BACKGROUND}.
+ * If the {@link #infoItem} is not a pure audio (live) stream,
+ * {@link StreamDialogDefaultEntry#START_HERE_ON_POPUP} is added, too.
+ */
public void addStartHereEntries() {
addEntry(StreamDialogDefaultEntry.START_HERE_ON_BACKGROUND);
if (infoItem.getStreamType() != StreamType.AUDIO_STREAM
@@ -169,8 +242,8 @@ public final class InfoItemDialog {
*/
public void addMarkAsWatchedEntryIfNeeded() {
final boolean isWatchHistoryEnabled = PreferenceManager
- .getDefaultSharedPreferences(activity)
- .getBoolean(activity.getString(R.string.enable_watch_history_key), false);
+ .getDefaultSharedPreferences(context)
+ .getBoolean(context.getString(R.string.enable_watch_history_key), false);
if (isWatchHistoryEnabled
&& infoItem.getStreamType() != StreamType.LIVE_STREAM
&& infoItem.getStreamType() != StreamType.AUDIO_LIVE_STREAM) {
@@ -179,17 +252,26 @@ public final class InfoItemDialog {
}
public void addPlayWithKodiEntryIfNeeded() {
- if (KoreUtils.shouldShowPlayWithKodi(activity, infoItem.getServiceId())) {
+ if (KoreUtils.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
addEntry(StreamDialogDefaultEntry.PLAY_WITH_KODI);
}
}
- public void addDefaultEntriesAtBeginning() {
+ /**
+ * Add the entries which are usually at the top of the action list.
+ *
+ * This method adds the "enqueue" (see {@link #addEnqueueEntriesIfNeeded()})
+ * and "start here" (see {@link #addStartHereEntries()} entries.
+ */
+ public void addDefaultBeginningEntries() {
addEnqueueEntriesIfNeeded();
addStartHereEntries();
}
- public void addDefaultEntriesAtEnd() {
+ /**
+ * Add the entries which are usually at the bottom of the action list.
+ */
+ public void addDefaultEndEntries() {
addAllEntries(
StreamDialogDefaultEntry.APPEND_PLAYLIST,
StreamDialogDefaultEntry.SHARE,
@@ -197,7 +279,7 @@ public final class InfoItemDialog {
);
addPlayWithKodiEntryIfNeeded();
addMarkAsWatchedEntryIfNeeded();
- addChannelDetailsEntryIfPossible();
+ addEntry(StreamDialogDefaultEntry.SHOW_CHANNEL_DETAILS);
}
/**
@@ -206,7 +288,7 @@ public final class InfoItemDialog {
*/
public InfoItemDialog create() {
if (addDefaultEntriesAutomatically) {
- addDefaultEntriesAtEnd();
+ addDefaultEndEntries();
}
return new InfoItemDialog(this.activity, this.fragment, this.infoItem, this.entries);
}
diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt
index 63e918739..5c1c78902 100644
--- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt
+++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt
@@ -357,7 +357,7 @@ class FeedFragment : BaseStateFragment
+ * This enum provides entries that are accepted
+ * by the {@link org.schabi.newpipe.info_list.InfoItemDialog.Builder}.
+ *
+ * These entries contain a String {@link #resource} which is displayed in the dialog and
+ * a default {@link #action} that is executed
+ * when the entry is selected (via onClick()
).
+ *
+ * They action can be overridden by using the Builder's
+ * {@link org.schabi.newpipe.info_list.InfoItemDialog.Builder#setAction(
+ * StreamDialogDefaultEntry, StreamDialogEntry.StreamDialogEntryAction)}
+ * method.
+ *