use of org.gateshipone.malp.application.fragments.serverfragments.ChoosePlaylistDialog in project malp by gateship-one.
the class MainActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (info == null) {
return super.onContextItemSelected(item);
}
CurrentPlaylistView currentPlaylistView = findViewById(R.id.now_playing_playlist);
if (currentPlaylistView != null && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) {
MPDTrack track = (MPDTrack) currentPlaylistView.getItem(info.position);
switch(item.getItemId()) {
case R.id.action_song_play_next:
MPDQueryHandler.playIndexAsNext(info.position);
return true;
case R.id.action_add_to_saved_playlist:
// open dialog in order to save the current playlist as a playlist in the mediastore
ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
Bundle args = new Bundle();
args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
choosePlaylistDialog.setCallback(new AddPathToPlaylist(track, this));
choosePlaylistDialog.setArguments(args);
choosePlaylistDialog.show(getSupportFragmentManager(), "ChoosePlaylistDialog");
return true;
case R.id.action_remove_song:
MPDQueryHandler.removeSongFromCurrentPlaylist(info.position);
return true;
case R.id.action_remove_album:
currentPlaylistView.removeAlbumFrom(info.position);
return true;
case R.id.action_show_artist:
if (mUseArtistSort) {
onArtistSelected(new MPDArtist(track.getTrackArtistSort()), null);
} else {
onArtistSelected(new MPDArtist(track.getTrackArtist()), null);
}
return true;
case R.id.action_show_album:
MPDAlbum tmpAlbum = new MPDAlbum(track.getTrackAlbum());
// Set album artist
if (!track.getTrackAlbumArtist().isEmpty()) {
tmpAlbum.setArtistName(track.getTrackAlbumArtist());
} else {
tmpAlbum.setArtistName(track.getTrackArtist());
}
// Set albumartistsort
if (!track.getTrackAlbumArtistSort().isEmpty()) {
tmpAlbum.setArtistSortName(track.getTrackAlbumArtistSort());
} else {
tmpAlbum.setArtistSortName(track.getTrackArtistSort());
}
tmpAlbum.setMBID(track.getTrackAlbumMBID());
onAlbumSelected(tmpAlbum, null);
return true;
case R.id.action_show_details:
// Open song details dialog
SongDetailsDialog songDetailsDialog = new SongDetailsDialog();
Bundle songArgs = new Bundle();
songArgs.putParcelable(SongDetailsDialog.EXTRA_FILE, track);
songDetailsDialog.setArguments(songArgs);
songDetailsDialog.show(getSupportFragmentManager(), "SongDetails");
return true;
}
}
return false;
}
use of org.gateshipone.malp.application.fragments.serverfragments.ChoosePlaylistDialog in project malp by gateship-one.
the class NowPlayingView method onMenuItemClick.
/**
* Menu click listener. This method gets called when the user selects an item of the popup menu (right top corner).
*
* @param item MenuItem that was clicked.
* @return Returns true if the item was handled by this method. False otherwise.
*/
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_clear_playlist:
final AlertDialog.Builder removeListBuilder = new AlertDialog.Builder(getContext());
removeListBuilder.setTitle(getContext().getString(R.string.action_delete_playlist));
removeListBuilder.setMessage(getContext().getString(R.string.dialog_message_delete_current_playlist));
removeListBuilder.setPositiveButton(R.string.dialog_action_yes, (dialog, which) -> MPDQueryHandler.clearPlaylist());
removeListBuilder.setNegativeButton(R.string.dialog_action_no, (dialog, which) -> {
});
removeListBuilder.create().show();
break;
case R.id.action_shuffle_playlist:
{
final AlertDialog.Builder shuffleListBuilder = new AlertDialog.Builder(getContext());
shuffleListBuilder.setTitle(getContext().getString(R.string.action_shuffle_playlist));
shuffleListBuilder.setMessage(getContext().getString(R.string.dialog_message_shuffle_current_playlist));
shuffleListBuilder.setPositiveButton(R.string.dialog_action_yes, (dialog, which) -> MPDQueryHandler.shufflePlaylist());
shuffleListBuilder.setNegativeButton(R.string.dialog_action_no, (dialog, which) -> {
});
shuffleListBuilder.create().show();
}
break;
case R.id.action_save_playlist:
OnSaveDialogListener plDialogCallback = new OnSaveDialogListener() {
@Override
public void onSaveObject(final String title) {
AlertDialog.Builder overWriteBuilder = new AlertDialog.Builder(getContext());
overWriteBuilder.setTitle(getContext().getString(R.string.action_overwrite_playlist));
overWriteBuilder.setMessage(getContext().getString(R.string.dialog_message_overwrite_playlist) + ' ' + title + '?');
overWriteBuilder.setPositiveButton(R.string.dialog_action_yes, (dialog, which) -> {
MPDQueryHandler.removePlaylist(title);
MPDQueryHandler.savePlaylist(title);
});
overWriteBuilder.setNegativeButton(R.string.dialog_action_no, (dialog, which) -> {
});
overWriteBuilder.create().show();
}
@Override
public void onCreateNewObject() {
// open dialog in order to save the current playlist as a playlist in the mediastore
TextDialog textDialog = new TextDialog();
Bundle args = new Bundle();
args.putString(TextDialog.EXTRA_DIALOG_TITLE, getResources().getString(R.string.dialog_save_playlist));
args.putString(TextDialog.EXTRA_DIALOG_TEXT, getResources().getString(R.string.default_playlist_title));
textDialog.setCallback(MPDQueryHandler::savePlaylist);
textDialog.setArguments(args);
textDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "SavePLTextDialog");
}
};
// open dialog in order to save the current playlist as a playlist in the mediastore
ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
Bundle args = new Bundle();
args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
choosePlaylistDialog.setCallback(plDialogCallback);
choosePlaylistDialog.setArguments(args);
choosePlaylistDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "ChoosePlaylistDialog");
break;
case R.id.action_add_url:
TextDialog addURLDialog = new TextDialog();
addURLDialog.setCallback(MPDQueryHandler::addPath);
Bundle textDialogArgs = new Bundle();
textDialogArgs.putString(TextDialog.EXTRA_DIALOG_TEXT, "http://...");
textDialogArgs.putString(TextDialog.EXTRA_DIALOG_TITLE, getResources().getString(R.string.action_add_url));
addURLDialog.setArguments(textDialogArgs);
addURLDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "AddURLDialog");
break;
case R.id.action_jump_to_current:
mPlaylistView.jumpToCurrentSong();
break;
case R.id.action_toggle_single_mode:
if (null != mLastStatus) {
if (mLastStatus.getSinglePlayback() == 0) {
MPDCommandHandler.setSingle(true);
} else {
MPDCommandHandler.setSingle(false);
}
}
break;
case R.id.action_toggle_consume_mode:
if (null != mLastStatus) {
if (mLastStatus.getConsume() == 0) {
MPDCommandHandler.setConsume(true);
} else {
MPDCommandHandler.setConsume(false);
}
}
break;
case R.id.action_open_fanart:
Intent intent = new Intent(getContext(), FanartActivity.class);
getContext().startActivity(intent);
return true;
case R.id.action_wikipedia_album:
Intent albumIntent = new Intent(Intent.ACTION_VIEW);
// albumIntent.setData(Uri.parse("https://" + Locale.getDefault().getLanguage() + ".wikipedia.org/wiki/index.php?search=" + mLastTrack.getTrackAlbum() + "&title=Special:Search&go=Go"));
if (mUseEnglishWikipedia) {
albumIntent.setData(Uri.parse("https://en.wikipedia.org/wiki/" + mLastTrack.getTrackAlbum()));
} else {
albumIntent.setData(Uri.parse("https://" + Locale.getDefault().getLanguage() + ".wikipedia.org/wiki/" + mLastTrack.getTrackAlbum()));
}
getContext().startActivity(albumIntent);
return true;
case R.id.action_wikipedia_artist:
Intent artistIntent = new Intent(Intent.ACTION_VIEW);
// artistIntent.setData(Uri.parse("https://" + Locale.getDefault().getLanguage() + ".wikipedia.org/wiki/index.php?search=" + mLastTrack.getTrackAlbumArtist() + "&title=Special:Search&go=Go"));
if (mUseEnglishWikipedia) {
artistIntent.setData(Uri.parse("https://en.wikipedia.org/wiki/" + mLastTrack.getTrackArtist()));
} else {
artistIntent.setData(Uri.parse("https://" + Locale.getDefault().getLanguage() + ".wikipedia.org/wiki/" + mLastTrack.getTrackArtist()));
}
getContext().startActivity(artistIntent);
return true;
case R.id.action_start_streaming:
{
if (mStreamingStatus == BackgroundService.STREAMING_STATUS.PLAYING || mStreamingStatus == BackgroundService.STREAMING_STATUS.BUFFERING) {
try {
mBackgroundServiceConnection.getService().stopStreamingPlayback();
} catch (RemoteException e) {
}
} else {
try {
mBackgroundServiceConnection.getService().startStreamingPlayback();
} catch (RemoteException e) {
}
}
return true;
}
case R.id.action_share_current_song:
{
shareCurrentTrack();
return true;
}
default:
return false;
}
return false;
}
Aggregations