Added the 'Show Channel Details' menu item to the Queue long press menu

Created a method in NavigationHelper that opens the channel fragment using an Intent to MainActivity instead of replacing fragments.
This commit is contained in:
ktprograms 2021-10-11 14:46:29 +08:00
parent 7baeb6eca7
commit a2ff770afc
3 changed files with 21 additions and 2 deletions

View File

@ -1,7 +1,5 @@
package org.schabi.newpipe;
import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText;
import android.content.Context;
import android.view.ContextThemeWrapper;
import android.view.View;
@ -17,6 +15,8 @@ import org.schabi.newpipe.util.NavigationHelper;
import java.util.Collections;
import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText;
public final class QueueItemMenuUtil {
public static void openPopupMenu(final PlayQueue playQueue,
final PlayQueueItem item,
@ -55,6 +55,10 @@ public final class QueueItemMenuUtil {
() -> PlaylistCreationDialog.newInstance(d)
.show(fragmentManager, "QueueItemMenuUtil@append_playlist"));
return true;
case R.id.menu_item_channel_details:
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());

View File

@ -491,6 +491,18 @@ public final class NavigationHelper {
context.startActivity(intent);
}
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);

View File

@ -10,6 +10,9 @@
<item
android:id="@+id/menu_item_append_playlist"
android:title="@string/append_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" />