mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-25 12:32:31 +01:00
Show popup menu when long pressing in play queue (Full screen player)
This commit is contained in:
parent
a6d6ed6474
commit
acdfee5c25
@ -214,6 +214,10 @@ dependencies {
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation "androidx.room:room-runtime:${androidxRoomVersion}"
|
||||
implementation "androidx.room:room-rxjava3:${androidxRoomVersion}"
|
||||
|
||||
// Apple Sillicon Mac workaround (https://issuetracker.google.com/issues/174695268#comment9)
|
||||
kapt "org.xerial:sqlite-jdbc:3.34.0"
|
||||
|
||||
kapt "androidx.room:room-compiler:${androidxRoomVersion}"
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
implementation 'androidx.webkit:webkit:1.4.0'
|
||||
|
@ -281,42 +281,29 @@ public final class PlayQueueActivity extends AppCompatActivity
|
||||
|
||||
private void buildItemPopupMenu(final PlayQueueItem item, final View view) {
|
||||
final PopupMenu popupMenu = new PopupMenu(this, view);
|
||||
final MenuItem remove = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 0,
|
||||
Menu.NONE, R.string.play_queue_remove);
|
||||
remove.setOnMenuItemClickListener(menuItem -> {
|
||||
if (player == null) {
|
||||
return false;
|
||||
popupMenu.inflate(R.menu.menu_play_queue_item);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.menu_item_remove:
|
||||
final int index = player.getPlayQueue().indexOf(item);
|
||||
player.getPlayQueue().remove(index);
|
||||
return true;
|
||||
case R.id.menu_item_details:
|
||||
// playQueue is null since we don't want any queue change
|
||||
NavigationHelper.openVideoDetail(this, item.getServiceId(),
|
||||
item.getUrl(), item.getTitle(), null,
|
||||
false);
|
||||
return true;
|
||||
case R.id.menu_item_append_playlist:
|
||||
openPlaylistAppendDialog(Collections.singletonList(item));
|
||||
return true;
|
||||
case R.id.menu_item_share:
|
||||
shareText(this, item.getTitle(), item.getUrl(),
|
||||
item.getThumbnailUrl());
|
||||
return true;
|
||||
}
|
||||
|
||||
final int index = player.getPlayQueue().indexOf(item);
|
||||
if (index != -1) {
|
||||
player.getPlayQueue().remove(index);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
final MenuItem detail = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1,
|
||||
Menu.NONE, R.string.play_queue_stream_detail);
|
||||
detail.setOnMenuItemClickListener(menuItem -> {
|
||||
// playQueue is null since we don't want any queue change
|
||||
NavigationHelper.openVideoDetail(this, item.getServiceId(), item.getUrl(),
|
||||
item.getTitle(), null, false);
|
||||
return true;
|
||||
});
|
||||
|
||||
final MenuItem append = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 2,
|
||||
Menu.NONE, R.string.append_playlist);
|
||||
append.setOnMenuItemClickListener(menuItem -> {
|
||||
openPlaylistAppendDialog(Collections.singletonList(item));
|
||||
return true;
|
||||
});
|
||||
|
||||
final MenuItem share = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 3,
|
||||
Menu.NONE, R.string.share);
|
||||
share.setOnMenuItemClickListener(menuItem -> {
|
||||
shareText(getApplicationContext(), item.getTitle(), item.getUrl(),
|
||||
item.getThumbnailUrl());
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
popupMenu.show();
|
||||
|
@ -100,6 +100,8 @@ import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
|
||||
import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
|
||||
import org.schabi.newpipe.info_list.StreamSegmentAdapter;
|
||||
import org.schabi.newpipe.ktx.AnimationType;
|
||||
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
||||
import org.schabi.newpipe.local.dialog.PlaylistCreationDialog;
|
||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||
import org.schabi.newpipe.player.MainPlayer.PlayerType;
|
||||
import org.schabi.newpipe.player.event.PlayerEventListener;
|
||||
@ -138,6 +140,7 @@ import org.schabi.newpipe.views.ExpandableSurfaceView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -193,6 +196,7 @@ import static org.schabi.newpipe.util.ListHelper.getPopupResolutionIndex;
|
||||
import static org.schabi.newpipe.util.ListHelper.getResolutionIndex;
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
import static org.schabi.newpipe.util.Localization.containsCaseInsensitive;
|
||||
import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText;
|
||||
|
||||
public final class Player implements
|
||||
EventListener,
|
||||
@ -3032,6 +3036,45 @@ public final class Player implements
|
||||
playQueue.setIndex(index);
|
||||
}
|
||||
|
||||
private void heldQueueItem(final PlayQueueItem item, final View view) {
|
||||
final Context themeWrapper =
|
||||
new ContextThemeWrapper(context, R.style.DarkPopupMenu);
|
||||
|
||||
final PopupMenu popupMenu = new PopupMenu(themeWrapper, view);
|
||||
popupMenu.inflate(R.menu.menu_play_queue_item);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.menu_item_remove:
|
||||
final int index = playQueue.indexOf(item);
|
||||
playQueue.remove(index);
|
||||
return true;
|
||||
case R.id.menu_item_details:
|
||||
// playQueue is null since we don't want any queue change
|
||||
NavigationHelper.openVideoDetail(context, item.getServiceId(),
|
||||
item.getUrl(), item.getTitle(), null,
|
||||
false);
|
||||
return true;
|
||||
case R.id.menu_item_append_playlist:
|
||||
final PlaylistAppendDialog d = PlaylistAppendDialog.fromPlayQueueItems(
|
||||
Collections.singletonList(item)
|
||||
);
|
||||
PlaylistAppendDialog.onPlaylistFound(context,
|
||||
() -> d.show(getParentActivity().getSupportFragmentManager(), TAG),
|
||||
() -> PlaylistCreationDialog.newInstance(d)
|
||||
.show(getParentActivity().getSupportFragmentManager(), TAG));
|
||||
return true;
|
||||
case R.id.menu_item_share:
|
||||
shareText(context, item.getTitle(), item.getUrl(),
|
||||
item.getThumbnailUrl());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
popupMenu.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayQueueEdited() {
|
||||
notifyPlaybackUpdateToListeners();
|
||||
@ -3198,9 +3241,8 @@ public final class Player implements
|
||||
|
||||
@Override
|
||||
public void held(final PlayQueueItem item, final View view) {
|
||||
final int index = playQueue.indexOf(item);
|
||||
if (index != -1) {
|
||||
playQueue.remove(index);
|
||||
if (playQueue.indexOf(item) != -1) {
|
||||
heldQueueItem(item, view);
|
||||
}
|
||||
}
|
||||
|
||||
|
16
app/src/main/res/menu/menu_play_queue_item.xml
Normal file
16
app/src/main/res/menu/menu_play_queue_item.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_item_remove"
|
||||
android:title="@string/play_queue_remove" />
|
||||
<item
|
||||
android:id="@+id/menu_item_details"
|
||||
android:title="@string/play_queue_stream_detail" />
|
||||
<item
|
||||
android:id="@+id/menu_item_append_playlist"
|
||||
android:title="@string/append_playlist" />
|
||||
<item
|
||||
android:id="@+id/menu_item_share"
|
||||
android:title="@string/share" />
|
||||
</menu>
|
Loading…
Reference in New Issue
Block a user