Browse Source

Merge pull request #7222 from ktprograms/queue-menu-channel-details

Added the 'Show Channel Details' menu item to the Queue long press menu
pull/7265/head
litetex 2 months ago
committed by GitHub
parent
commit
7edef8d5a2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java
  2. 21
      app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
  3. 3
      app/src/main/res/menu/menu_play_queue_item.xml

12
app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java

@ -18,6 +18,9 @@ import org.schabi.newpipe.util.NavigationHelper;
import java.util.Collections;
public final class QueueItemMenuUtil {
private QueueItemMenuUtil() {
}
public static void openPopupMenu(final PlayQueue playQueue,
final PlayQueueItem item,
final View view,
@ -57,6 +60,13 @@ public final class QueueItemMenuUtil {
);
return true;
case R.id.menu_item_channel_details:
// An intent must be used here.
// Opening with FragmentManager transactions is not working,
// as PlayQueueActivity doesn't use fragments.
NavigationHelper.openChannelFragmentUsingIntent(context, item.getServiceId(),
item.getUploaderUrl(), item.getUploader());
return true;
case R.id.menu_item_share:
shareText(context, item.getTitle(), item.getUrl(),
item.getThumbnailUrl());
@ -67,6 +77,4 @@ public final class QueueItemMenuUtil {
popupMenu.show();
}
private QueueItemMenuUtil() { }
}

21
app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java

@ -495,6 +495,27 @@ public final class NavigationHelper {
context.startActivity(intent);
}
/**
* Opens {@link ChannelFragment}.
* Use this instead of {@link #openChannelFragment(FragmentManager, int, String, String)}
* when no fragments are used / no FragmentManager is available.
* @param context
* @param serviceId
* @param url
* @param title
*/
public static void openChannelFragmentUsingIntent(final Context context,
final int serviceId,
final String url,
@NonNull final String title) {
final Intent intent = getOpenIntent(context, url, serviceId,
StreamingService.LinkType.CHANNEL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Constants.KEY_TITLE, title);
context.startActivity(intent);
}
public static void openMainActivity(final Context context) {
final Intent mIntent = new Intent(context, MainActivity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

3
app/src/main/res/menu/menu_play_queue_item.xml

@ -10,6 +10,9 @@
<item
android:id="@+id/menu_item_append_playlist"
android:title="@string/add_to_playlist" />
<item
android:id="@+id/menu_item_channel_details"
android:title="@string/show_channel_details" />
<item
android:id="@+id/menu_item_share"
android:title="@string/share" />

Loading…
Cancel
Save