use of org.gateshipone.malp.application.fragments.TextDialog in project malp by gateship-one.
the class AddPathToPlaylist method onCreateNewObject.
@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, mContext.getResources().getString(R.string.dialog_save_playlist));
args.putString(TextDialog.EXTRA_DIALOG_TEXT, mContext.getResources().getString(R.string.default_playlist_title));
textDialog.setCallback(text -> MPDQueryHandler.addURLToSavedPlaylist(text, mFile.getPath()));
textDialog.setArguments(args);
textDialog.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "SavePLTextDialog");
}
use of org.gateshipone.malp.application.fragments.TextDialog 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