mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Fix showing popup options with audio-only streams
This commit is contained in:
		| @@ -25,6 +25,7 @@ import org.schabi.newpipe.extractor.channel.ChannelInfoItem; | |||||||
| import org.schabi.newpipe.extractor.comments.CommentsInfoItem; | import org.schabi.newpipe.extractor.comments.CommentsInfoItem; | ||||||
| import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; | import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; | ||||||
| import org.schabi.newpipe.extractor.stream.StreamInfoItem; | import org.schabi.newpipe.extractor.stream.StreamInfoItem; | ||||||
|  | import org.schabi.newpipe.extractor.stream.StreamType; | ||||||
| import org.schabi.newpipe.fragments.BaseStateFragment; | import org.schabi.newpipe.fragments.BaseStateFragment; | ||||||
| import org.schabi.newpipe.fragments.OnScrollBelowItemsListener; | import org.schabi.newpipe.fragments.OnScrollBelowItemsListener; | ||||||
| import org.schabi.newpipe.info_list.InfoItemDialog; | import org.schabi.newpipe.info_list.InfoItemDialog; | ||||||
| @@ -263,40 +264,49 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem | |||||||
|         final Activity activity = getActivity(); |         final Activity activity = getActivity(); | ||||||
|         if (context == null || context.getResources() == null || activity == null) return; |         if (context == null || context.getResources() == null || activity == null) return; | ||||||
|  |  | ||||||
|         final String[] commands = new String[]{ |         boolean isAudioStream = (item.getStreamType() == StreamType.AUDIO_STREAM); | ||||||
|                 context.getResources().getString(R.string.enqueue_on_background), |  | ||||||
|                 context.getResources().getString(R.string.enqueue_on_popup), |         final String[] commands; | ||||||
|                 context.getResources().getString(R.string.start_here_on_background), |         if (isAudioStream) { | ||||||
|                 context.getResources().getString(R.string.start_here_on_popup), |             commands = new String[]{ | ||||||
|                 context.getResources().getString(R.string.append_playlist), |                     context.getResources().getString(R.string.enqueue_on_background), | ||||||
|                 context.getResources().getString(R.string.share) |                     context.getResources().getString(R.string.start_here_on_background), | ||||||
|         }; |                     context.getResources().getString(R.string.append_playlist), | ||||||
|  |                     context.getResources().getString(R.string.share) | ||||||
|  |             }; | ||||||
|  |         } else { | ||||||
|  |             commands = new String[]{ | ||||||
|  |                     context.getResources().getString(R.string.enqueue_on_background), | ||||||
|  |                     context.getResources().getString(R.string.enqueue_on_popup), | ||||||
|  |                     context.getResources().getString(R.string.start_here_on_background), | ||||||
|  |                     context.getResources().getString(R.string.start_here_on_popup), | ||||||
|  |                     context.getResources().getString(R.string.append_playlist), | ||||||
|  |                     context.getResources().getString(R.string.share) | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { |         final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { | ||||||
|             switch (i) { |             if (i == 0) { | ||||||
|                 case 0: |                 NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item), false); | ||||||
|                     NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item), false); |  | ||||||
|                     break; |             } else if (i == (isAudioStream ? -1 : 1)) { // disabled with audio streams | ||||||
|                 case 1: |                 NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(item), false); | ||||||
|                     NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(item), false); |  | ||||||
|                     break; |             } else if (i == (isAudioStream ?  1 : 2)) { | ||||||
|                 case 2: |                 NavigationHelper.playOnBackgroundPlayer(context, new SinglePlayQueue(item), true); | ||||||
|                     NavigationHelper.playOnBackgroundPlayer(context, new SinglePlayQueue(item), true); |  | ||||||
|                     break; |             } else if (i == (isAudioStream ? -1 : 3)) { // disabled with audio streams | ||||||
|                 case 3: |                 NavigationHelper.playOnPopupPlayer(context, new SinglePlayQueue(item), true); | ||||||
|                     NavigationHelper.playOnPopupPlayer(context, new SinglePlayQueue(item), true); |  | ||||||
|                     break; |             } else if (i == (isAudioStream ?  2 : 4)) { | ||||||
|                 case 4: |                 if (getFragmentManager() != null) { | ||||||
|                     if (getFragmentManager() != null) { |                     PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)) | ||||||
|                         PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)) |                             .show(getFragmentManager(), TAG); | ||||||
|                                 .show(getFragmentManager(), TAG); |                 } | ||||||
|                     } |  | ||||||
|                     break; |             } else if (i == (isAudioStream ?  3 : 5)) { | ||||||
|                 case 5: |                 ShareUtils.shareUrl(context, item.getName(), item.getUrl()); | ||||||
|                     ShareUtils.shareUrl(context, item.getName(), item.getUrl()); |  | ||||||
|                     break; |  | ||||||
|                 default: |  | ||||||
|                     break; |  | ||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,6 +25,7 @@ import org.schabi.newpipe.R; | |||||||
| import org.schabi.newpipe.database.LocalItem; | import org.schabi.newpipe.database.LocalItem; | ||||||
| import org.schabi.newpipe.database.stream.StreamStatisticsEntry; | import org.schabi.newpipe.database.stream.StreamStatisticsEntry; | ||||||
| import org.schabi.newpipe.extractor.stream.StreamInfoItem; | import org.schabi.newpipe.extractor.stream.StreamInfoItem; | ||||||
|  | import org.schabi.newpipe.extractor.stream.StreamType; | ||||||
| import org.schabi.newpipe.info_list.InfoItemDialog; | import org.schabi.newpipe.info_list.InfoItemDialog; | ||||||
| import org.schabi.newpipe.local.BaseLocalListFragment; | import org.schabi.newpipe.local.BaseLocalListFragment; | ||||||
| import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; | import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; | ||||||
| @@ -362,47 +363,59 @@ public class StatisticsPlaylistFragment | |||||||
|         final Context context = getContext(); |         final Context context = getContext(); | ||||||
|         final Activity activity = getActivity(); |         final Activity activity = getActivity(); | ||||||
|         if (context == null || context.getResources() == null || activity == null) return; |         if (context == null || context.getResources() == null || activity == null) return; | ||||||
|         final StreamInfoItem infoItem = item.toStreamInfoItem(); |  | ||||||
|  |  | ||||||
|         final String[] commands = new String[]{ |         final StreamInfoItem infoItem = item.toStreamInfoItem(); | ||||||
|                 context.getResources().getString(R.string.enqueue_on_background), |         boolean isAudioStream = (infoItem.getStreamType() == StreamType.AUDIO_STREAM); | ||||||
|                 context.getResources().getString(R.string.enqueue_on_popup), |  | ||||||
|                 context.getResources().getString(R.string.start_here_on_background), |         final String[] commands; | ||||||
|                 context.getResources().getString(R.string.start_here_on_popup), |         if (isAudioStream) { | ||||||
|                 context.getResources().getString(R.string.delete), |             commands = new String[]{ | ||||||
|                 context.getResources().getString(R.string.append_playlist), |                     context.getResources().getString(R.string.enqueue_on_background), | ||||||
|                 context.getResources().getString(R.string.share) |                     context.getResources().getString(R.string.start_here_on_background), | ||||||
|         }; |                     context.getResources().getString(R.string.delete), | ||||||
|  |                     context.getResources().getString(R.string.append_playlist), | ||||||
|  |                     context.getResources().getString(R.string.share) | ||||||
|  |             }; | ||||||
|  |         } else { | ||||||
|  |             commands = new String[]{ | ||||||
|  |                     context.getResources().getString(R.string.enqueue_on_background), | ||||||
|  |                     context.getResources().getString(R.string.enqueue_on_popup), | ||||||
|  |                     context.getResources().getString(R.string.start_here_on_background), | ||||||
|  |                     context.getResources().getString(R.string.start_here_on_popup), | ||||||
|  |                     context.getResources().getString(R.string.delete), | ||||||
|  |                     context.getResources().getString(R.string.append_playlist), | ||||||
|  |                     context.getResources().getString(R.string.share) | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { |         final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { | ||||||
|             final int index = Math.max(itemListAdapter.getItemsList().indexOf(item), 0); |             final int index = Math.max(itemListAdapter.getItemsList().indexOf(item), 0); | ||||||
|             switch (i) { |  | ||||||
|                 case 0: |             if (i == 0) { | ||||||
|                     NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(infoItem), false); |                 NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(infoItem), false); | ||||||
|                     break; |  | ||||||
|                 case 1: |             } else if (i == (isAudioStream ? -1 : 1)) { // disabled with audio streams | ||||||
|                     NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(infoItem), false); |                 NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(infoItem), false); | ||||||
|                     break; |  | ||||||
|                 case 2: |             } else if (i == (isAudioStream ?  1 : 2)) { | ||||||
|                     NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index), true); |                 NavigationHelper.playOnBackgroundPlayer(context, new SinglePlayQueue(infoItem), true); | ||||||
|                     break; |  | ||||||
|                 case 3: |             } else if (i == (isAudioStream ? -1 : 3)) { // disabled with audio streams | ||||||
|                     NavigationHelper.playOnPopupPlayer(context, getPlayQueue(index), true); |                 NavigationHelper.playOnPopupPlayer(context, new SinglePlayQueue(infoItem), true); | ||||||
|                     break; |  | ||||||
|                 case 4: |             } else if (i == (isAudioStream ?  2 : 4)) { | ||||||
|                     deleteEntry(index); |                 deleteEntry(index); | ||||||
|                     break; |  | ||||||
|                 case 5: |             } else if (i == (isAudioStream ?  3 : 5)) { | ||||||
|                     if (getFragmentManager() != null) { |                 if (getFragmentManager() != null) { | ||||||
|                         PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(infoItem)) |                     PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(infoItem)) | ||||||
|                                 .show(getFragmentManager(), TAG); |                             .show(getFragmentManager(), TAG); | ||||||
|                     } |                 } | ||||||
|                     break; |  | ||||||
|                 case 6: |             } else if (i == (isAudioStream ?  4 : 6)) { | ||||||
|                     ShareUtils.shareUrl(context, infoItem.getName(), infoItem.getUrl()); |                 ShareUtils.shareUrl(context, infoItem.getName(), infoItem.getUrl()); | ||||||
|                     break; |  | ||||||
|                 default: |  | ||||||
|                     break; |  | ||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ import org.schabi.newpipe.R; | |||||||
| import org.schabi.newpipe.database.LocalItem; | import org.schabi.newpipe.database.LocalItem; | ||||||
| import org.schabi.newpipe.database.playlist.PlaylistStreamEntry; | import org.schabi.newpipe.database.playlist.PlaylistStreamEntry; | ||||||
| import org.schabi.newpipe.extractor.stream.StreamInfoItem; | import org.schabi.newpipe.extractor.stream.StreamInfoItem; | ||||||
|  | import org.schabi.newpipe.extractor.stream.StreamType; | ||||||
| import org.schabi.newpipe.local.BaseLocalListFragment; | import org.schabi.newpipe.local.BaseLocalListFragment; | ||||||
| import org.schabi.newpipe.info_list.InfoItemDialog; | import org.schabi.newpipe.info_list.InfoItemDialog; | ||||||
| import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; | import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; | ||||||
| @@ -518,50 +519,62 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | |||||||
|         if (context == null || context.getResources() == null || activity == null) return; |         if (context == null || context.getResources() == null || activity == null) return; | ||||||
|  |  | ||||||
|         final StreamInfoItem infoItem = item.toStreamInfoItem(); |         final StreamInfoItem infoItem = item.toStreamInfoItem(); | ||||||
|  |         boolean isAudioStream = (infoItem.getStreamType() == StreamType.AUDIO_STREAM); | ||||||
|  |  | ||||||
|  |         final String[] commands; | ||||||
|  |         if (isAudioStream) { | ||||||
|  |             commands = new String[]{ | ||||||
|  |                     context.getResources().getString(R.string.enqueue_on_background), | ||||||
|  |                     context.getResources().getString(R.string.start_here_on_background), | ||||||
|  |                     context.getResources().getString(R.string.set_as_playlist_thumbnail), | ||||||
|  |                     context.getResources().getString(R.string.delete), | ||||||
|  |                     context.getResources().getString(R.string.append_playlist), | ||||||
|  |                     context.getResources().getString(R.string.share), | ||||||
|  |             }; | ||||||
|  |         } else { | ||||||
|  |             commands = new String[]{ | ||||||
|  |                     context.getResources().getString(R.string.enqueue_on_background), | ||||||
|  |                     context.getResources().getString(R.string.enqueue_on_popup), | ||||||
|  |                     context.getResources().getString(R.string.start_here_on_background), | ||||||
|  |                     context.getResources().getString(R.string.start_here_on_popup), | ||||||
|  |                     context.getResources().getString(R.string.set_as_playlist_thumbnail), | ||||||
|  |                     context.getResources().getString(R.string.delete), | ||||||
|  |                     context.getResources().getString(R.string.append_playlist), | ||||||
|  |                     context.getResources().getString(R.string.share), | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         final String[] commands = new String[]{ |  | ||||||
|                 context.getResources().getString(R.string.enqueue_on_background), |  | ||||||
|                 context.getResources().getString(R.string.enqueue_on_popup), |  | ||||||
|                 context.getResources().getString(R.string.start_here_on_background), |  | ||||||
|                 context.getResources().getString(R.string.start_here_on_popup), |  | ||||||
|                 context.getResources().getString(R.string.set_as_playlist_thumbnail), |  | ||||||
|                 context.getResources().getString(R.string.delete), |  | ||||||
|                 context.getResources().getString(R.string.append_playlist), |  | ||||||
|                 context.getResources().getString(R.string.share), |  | ||||||
|         }; |  | ||||||
|  |  | ||||||
|         final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { |         final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { | ||||||
|             final int index = Math.max(itemListAdapter.getItemsList().indexOf(item), 0); |             final int index = Math.max(itemListAdapter.getItemsList().indexOf(item), 0); | ||||||
|             switch (i) { |  | ||||||
|                 case 0: |             if (i == 0) { | ||||||
|                     NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(infoItem), false); |                 NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(infoItem), false); | ||||||
|                     break; |  | ||||||
|                 case 1: |             } else if (i == (isAudioStream ? -1 : 1)) { // disabled with audio streams | ||||||
|                     NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(infoItem), false); |                 NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(infoItem), false); | ||||||
|                     break; |  | ||||||
|                 case 2: |             } else if (i == (isAudioStream ?  1 : 2)) { | ||||||
|                     NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index), true); |                 NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index), true); | ||||||
|                     break; |  | ||||||
|                 case 3: |             } else if (i == (isAudioStream ? -1 : 3)) { // disabled with audio streams | ||||||
|                     NavigationHelper.playOnPopupPlayer(context, getPlayQueue(index), true); |                 NavigationHelper.playOnPopupPlayer(context, getPlayQueue(index), true); | ||||||
|                     break; |  | ||||||
|                 case 4: |             } else if (i == (isAudioStream ?  2 : 4)) { | ||||||
|                     changeThumbnailUrl(item.thumbnailUrl); |                 changeThumbnailUrl(item.thumbnailUrl); | ||||||
|                     break; |  | ||||||
|                 case 5: |             } else if (i == (isAudioStream ?  3 : 5)) { | ||||||
|                     deleteItem(item); |                 deleteItem(item); | ||||||
|                     break; |  | ||||||
|                 case 6: |             } else if (i == (isAudioStream ?  4 : 6)) { | ||||||
|                     if (getFragmentManager() != null) { |                 if (getFragmentManager() != null) { | ||||||
|                         PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(infoItem)) |                     PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(infoItem)) | ||||||
|                                 .show(getFragmentManager(), TAG); |                             .show(getFragmentManager(), TAG); | ||||||
|                     } |                 } | ||||||
|                     break; |  | ||||||
|                 case 7: |             } else if (i == (isAudioStream ?  5 : 7)) { | ||||||
|                     ShareUtils.shareUrl(context, infoItem.getName(), infoItem.getUrl()); |                 ShareUtils.shareUrl(context, infoItem.getName(), infoItem.getUrl()); | ||||||
|                     break; |  | ||||||
|                 default: |  | ||||||
|                     break; |  | ||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stypox
					Stypox