mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
Make long-press menu consistent across views: fix #2354
Also made the code that creates the menus consistent across files.
This commit is contained in:
parent
5a59a3dd50
commit
8b584f3922
@ -256,9 +256,10 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
|||||||
if (context == null || context.getResources() == null || getActivity() == null) return;
|
if (context == null || context.getResources() == null || getActivity() == null) return;
|
||||||
|
|
||||||
final String[] commands = new String[]{
|
final String[] commands = new String[]{
|
||||||
context.getResources().getString(R.string.direct_on_background),
|
|
||||||
context.getResources().getString(R.string.enqueue_on_background),
|
context.getResources().getString(R.string.enqueue_on_background),
|
||||||
context.getResources().getString(R.string.enqueue_on_popup),
|
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.append_playlist),
|
||||||
context.getResources().getString(R.string.share)
|
context.getResources().getString(R.string.share)
|
||||||
};
|
};
|
||||||
@ -266,21 +267,24 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
|||||||
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
|
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
NavigationHelper.playOnBackgroundPlayer(context, new SinglePlayQueue(item));
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
|
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 1:
|
||||||
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
|
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
NavigationHelper.playOnBackgroundPlayer(context, new SinglePlayQueue(item));
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
NavigationHelper.playOnPopupPlayer(activity, new SinglePlayQueue(item));
|
||||||
|
break;
|
||||||
|
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;
|
break;
|
||||||
case 4:
|
case 5:
|
||||||
ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
|
ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -159,7 +159,6 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
|
|||||||
final String[] commands = new String[]{
|
final String[] commands = new String[]{
|
||||||
context.getResources().getString(R.string.enqueue_on_background),
|
context.getResources().getString(R.string.enqueue_on_background),
|
||||||
context.getResources().getString(R.string.enqueue_on_popup),
|
context.getResources().getString(R.string.enqueue_on_popup),
|
||||||
context.getResources().getString(R.string.start_here_on_main),
|
|
||||||
context.getResources().getString(R.string.start_here_on_background),
|
context.getResources().getString(R.string.start_here_on_background),
|
||||||
context.getResources().getString(R.string.start_here_on_popup),
|
context.getResources().getString(R.string.start_here_on_popup),
|
||||||
context.getResources().getString(R.string.append_playlist),
|
context.getResources().getString(R.string.append_playlist),
|
||||||
@ -176,21 +175,18 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
|
|||||||
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
|
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
NavigationHelper.playOnMainPlayer(context, getPlayQueue(index));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
case 5:
|
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;
|
break;
|
||||||
case 6:
|
case 5:
|
||||||
ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
|
ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -31,6 +31,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
|
|||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
||||||
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.playlist.RemotePlaylistManager;
|
import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
import org.schabi.newpipe.player.playqueue.PlaylistPlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlaylistPlayQueue;
|
||||||
@ -44,6 +45,7 @@ import org.schabi.newpipe.util.ShareUtils;
|
|||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@ -144,9 +146,9 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
|||||||
final String[] commands = new String[]{
|
final String[] commands = new String[]{
|
||||||
context.getResources().getString(R.string.enqueue_on_background),
|
context.getResources().getString(R.string.enqueue_on_background),
|
||||||
context.getResources().getString(R.string.enqueue_on_popup),
|
context.getResources().getString(R.string.enqueue_on_popup),
|
||||||
context.getResources().getString(R.string.start_here_on_main),
|
|
||||||
context.getResources().getString(R.string.start_here_on_background),
|
context.getResources().getString(R.string.start_here_on_background),
|
||||||
context.getResources().getString(R.string.start_here_on_popup),
|
context.getResources().getString(R.string.start_here_on_popup),
|
||||||
|
context.getResources().getString(R.string.append_playlist),
|
||||||
context.getResources().getString(R.string.share)
|
context.getResources().getString(R.string.share)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -160,14 +162,17 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
|||||||
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
|
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
NavigationHelper.playOnMainPlayer(context, getPlayQueue(index));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
if (getFragmentManager() != null) {
|
||||||
|
PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item))
|
||||||
|
.show(getFragmentManager(), TAG);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
|
ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
|
||||||
break;
|
break;
|
||||||
|
@ -27,6 +27,7 @@ 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.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.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
@ -366,10 +367,10 @@ public class StatisticsPlaylistFragment
|
|||||||
final String[] commands = new String[]{
|
final String[] commands = new String[]{
|
||||||
context.getResources().getString(R.string.enqueue_on_background),
|
context.getResources().getString(R.string.enqueue_on_background),
|
||||||
context.getResources().getString(R.string.enqueue_on_popup),
|
context.getResources().getString(R.string.enqueue_on_popup),
|
||||||
context.getResources().getString(R.string.start_here_on_main),
|
|
||||||
context.getResources().getString(R.string.start_here_on_background),
|
context.getResources().getString(R.string.start_here_on_background),
|
||||||
context.getResources().getString(R.string.start_here_on_popup),
|
context.getResources().getString(R.string.start_here_on_popup),
|
||||||
context.getResources().getString(R.string.delete),
|
context.getResources().getString(R.string.delete),
|
||||||
|
context.getResources().getString(R.string.append_playlist),
|
||||||
context.getResources().getString(R.string.share)
|
context.getResources().getString(R.string.share)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -383,19 +384,22 @@ public class StatisticsPlaylistFragment
|
|||||||
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(infoItem));
|
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(infoItem));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
NavigationHelper.playOnMainPlayer(context, getPlayQueue(index));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 4:
|
||||||
deleteEntry(index);
|
deleteEntry(index);
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
if (getFragmentManager() != null) {
|
||||||
|
PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(infoItem))
|
||||||
|
.show(getFragmentManager(), TAG);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
ShareUtils.shareUrl(this.getContext(), item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl());
|
ShareUtils.shareUrl(this.getContext(), infoItem.getName(), infoItem.getUrl());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -28,6 +28,7 @@ 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.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.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
@ -521,42 +522,43 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||||||
final String[] commands = new String[]{
|
final String[] commands = new String[]{
|
||||||
context.getResources().getString(R.string.enqueue_on_background),
|
context.getResources().getString(R.string.enqueue_on_background),
|
||||||
context.getResources().getString(R.string.enqueue_on_popup),
|
context.getResources().getString(R.string.enqueue_on_popup),
|
||||||
context.getResources().getString(R.string.start_here_on_main),
|
|
||||||
context.getResources().getString(R.string.start_here_on_background),
|
context.getResources().getString(R.string.start_here_on_background),
|
||||||
context.getResources().getString(R.string.start_here_on_popup),
|
context.getResources().getString(R.string.start_here_on_popup),
|
||||||
context.getResources().getString(R.string.set_as_playlist_thumbnail),
|
context.getResources().getString(R.string.set_as_playlist_thumbnail),
|
||||||
context.getResources().getString(R.string.delete),
|
context.getResources().getString(R.string.delete),
|
||||||
context.getResources().getString(R.string.share)
|
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) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
NavigationHelper.enqueueOnBackgroundPlayer(context,
|
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(infoItem));
|
||||||
new SinglePlayQueue(infoItem));
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
NavigationHelper.enqueueOnPopupPlayer(activity, new
|
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(infoItem));
|
||||||
SinglePlayQueue(infoItem));
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
NavigationHelper.playOnMainPlayer(context, getPlayQueue(index));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
NavigationHelper.playOnBackgroundPlayer(context, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 4:
|
||||||
changeThumbnailUrl(item.thumbnailUrl);
|
changeThumbnailUrl(item.thumbnailUrl);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 5:
|
||||||
deleteItem(item);
|
deleteItem(item);
|
||||||
break;
|
break;
|
||||||
|
case 6:
|
||||||
|
if (getFragmentManager() != null) {
|
||||||
|
PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(infoItem))
|
||||||
|
.show(getFragmentManager(), TAG);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
ShareUtils.shareUrl(this.getContext(), item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl());
|
ShareUtils.shareUrl(this.getContext(), infoItem.getName(), infoItem.getUrl());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user