mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-05 22:16:17 +00:00
Reworking more menu management.
This commit is contained in:
@@ -23,12 +23,15 @@ using Android.Views;
|
||||
using Android.Widget;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Opus.Adapter;
|
||||
using Opus.Api;
|
||||
using Opus.Api.Services;
|
||||
using Opus.DataStructure;
|
||||
using Opus.Fragments;
|
||||
using Opus.Others;
|
||||
using Square.Picasso;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
@@ -40,6 +43,7 @@ using Playlist = Opus.Fragments.Playlist;
|
||||
using SearchView = Android.Support.V7.Widget.SearchView;
|
||||
using Toolbar = Android.Support.V7.Widget.Toolbar;
|
||||
using TransportType = Android.Net.TransportType;
|
||||
using Uri = Android.Net.Uri;
|
||||
|
||||
namespace Opus
|
||||
{
|
||||
@@ -582,6 +586,119 @@ namespace Opus
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region More Menues
|
||||
public async void More(Song item, Action overridedPlayAction = null, BottomSheetAction endAction = null)
|
||||
{
|
||||
if (!item.IsYt)
|
||||
item = LocalManager.CompleteItem(item);
|
||||
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(this);
|
||||
View bottomView = LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
if (item.AlbumArt == -1 || item.IsYt)
|
||||
{
|
||||
Picasso.With(this).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
else
|
||||
{
|
||||
var songCover = Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);
|
||||
|
||||
Picasso.With(this).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, Resources.GetString(Resource.String.play), (sender, eventArg) =>
|
||||
{
|
||||
if(overridedPlayAction == null)
|
||||
SongManager.Play(item);
|
||||
else
|
||||
overridedPlayAction.Invoke();
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistPlay, Resources.GetString(Resource.String.play_next), (sender, eventArg) =>
|
||||
{
|
||||
SongManager.PlayNext(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Queue, Resources.GetString(Resource.String.play_last), (sender, eventArg) =>
|
||||
{
|
||||
SongManager.PlayLast(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) =>
|
||||
{
|
||||
PlaylistManager.AddSongToPlaylistDialog(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
};
|
||||
|
||||
if (await SongManager.IsFavorite(item))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(item); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(item); bottomSheet.Dismiss(); }));
|
||||
|
||||
if (!item.IsYt)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Edit, Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) =>
|
||||
{
|
||||
LocalManager.EditMetadata(item);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.ChannelID != null)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.account, Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
|
||||
{
|
||||
if(YoutubeSearch.instances != null)
|
||||
{
|
||||
menu.FindItem(Resource.Id.search).ActionView.Focusable = false;
|
||||
menu.FindItem(Resource.Id.search).CollapseActionView();
|
||||
menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
|
||||
FindViewById<TabLayout>(Resource.Id.tabs).Visibility = ViewStates.Gone;
|
||||
}
|
||||
ChannelManager.OpenChannelTab(item.ChannelID);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
|
||||
actions.AddRange(new BottomSheetAction[]
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.PlayCircle, Resources.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.CreateMixFromSong(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Download, Resources.GetString(Resource.String.download), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.Download(new[] { item });
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if (endAction != null)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(endAction)
|
||||
{
|
||||
action = (sender, eventArg) =>
|
||||
{
|
||||
endAction.action.Invoke(sender, eventArg);
|
||||
bottomSheet.Dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(this, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Snackbars
|
||||
//public void YoutubeEndPointChanged()
|
||||
//{
|
||||
|
||||
@@ -23,6 +23,13 @@ namespace Opus.Adapter
|
||||
this.name = name;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public BottomSheetAction(BottomSheetAction baseAction)
|
||||
{
|
||||
Ressource = baseAction.Ressource;
|
||||
name = baseAction.name;
|
||||
action = baseAction.action;
|
||||
}
|
||||
}
|
||||
|
||||
public class BottomSheetAdapter : ArrayAdapter
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Opus.Adapter
|
||||
{
|
||||
holder.more.Click += (sender, e) =>
|
||||
{
|
||||
Browse.instance?.More(GetItem(holder.AdapterPosition));
|
||||
MainActivity.instance.More(GetItem(holder.AdapterPosition));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Opus.Adapter
|
||||
SongManager.Play(songs[position]);
|
||||
}
|
||||
|
||||
async void OnLongClick(int position)
|
||||
void OnLongClick(int position)
|
||||
{
|
||||
if (type == ListType.Favs)
|
||||
position--;
|
||||
@@ -223,157 +223,15 @@ namespace Opus.Adapter
|
||||
|
||||
if (type == ListType.Queue)
|
||||
{
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
if (item.AlbumArt == -1 || item.IsYt)
|
||||
BottomSheetAction endAction = new BottomSheetAction(Resource.Drawable.Close, MainActivity.instance.GetString(Resource.String.remove_from_queue), (sender, eventArg) =>
|
||||
{
|
||||
Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
else
|
||||
{
|
||||
var songCover = Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);
|
||||
MusicPlayer.RemoveFromQueue(position);
|
||||
});
|
||||
|
||||
Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, MainActivity.instance.Resources.GetString(Resource.String.play), (sender, eventArg) => { OnClick(position); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.Close, MainActivity.instance.Resources.GetString(Resource.String.remove_from_queue), (sender, eventArg) => { MusicPlayer.RemoveFromQueue(position); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, MainActivity.instance.Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) => { PlaylistManager.AddSongToPlaylistDialog(item); bottomSheet.Dismiss(); })
|
||||
};
|
||||
|
||||
if (item.IsYt)
|
||||
{
|
||||
actions.AddRange(new BottomSheetAction[]
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.PlayCircle, MainActivity.instance.Resources.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.CreateMixFromSong(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Download, MainActivity.instance.Resources.GetString(Resource.String.download), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.Download(new[] { item });
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
});
|
||||
|
||||
if(item.ChannelID != null)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.account, MainActivity.instance.Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
|
||||
{
|
||||
ChannelManager.OpenChannelTab(item.ChannelID);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Edit, MainActivity.instance.Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) =>
|
||||
{
|
||||
LocalManager.EditMetadata(item);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
|
||||
if (await SongManager.IsFavorite(item))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, MainActivity.instance.Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(item); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, MainActivity.instance.Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(item); bottomSheet.Dismiss(); }));
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
MainActivity.instance.More(item, () => { OnClick(position); }, endAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
if (item.AlbumArt == -1 || item.IsYt)
|
||||
{
|
||||
Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
else
|
||||
{
|
||||
var songCover = Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);
|
||||
|
||||
Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, MainActivity.instance.Resources.GetString(Resource.String.play), (sender, eventArg) =>
|
||||
{
|
||||
SongManager.Play(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistPlay, MainActivity.instance.Resources.GetString(Resource.String.play_next), (sender, eventArg) =>
|
||||
{
|
||||
SongManager.PlayNext(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Queue, MainActivity.instance.Resources.GetString(Resource.String.play_last), (sender, eventArg) =>
|
||||
{
|
||||
SongManager.PlayLast(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, MainActivity.instance.Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) =>
|
||||
{
|
||||
PlaylistManager.AddSongToPlaylistDialog(item);
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
};
|
||||
|
||||
if (!item.IsYt)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Edit, MainActivity.instance.Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) =>
|
||||
{
|
||||
LocalManager.EditMetadata(item);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
actions.AddRange(new BottomSheetAction[]
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.PlayCircle, MainActivity.instance.Resources.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.CreateMixFromSong(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Download, MainActivity.instance.Resources.GetString(Resource.String.download), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.Download(new[] { item });
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
});
|
||||
|
||||
if (item.ChannelID != null)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.account, MainActivity.instance.Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
|
||||
{
|
||||
ChannelManager.OpenChannelTab(item.ChannelID);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
if (await SongManager.IsFavorite(item))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, MainActivity.instance.Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(item); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, MainActivity.instance.Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(item); bottomSheet.Dismiss(); }));
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
}
|
||||
MainActivity.instance.More(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace Opus.Adapter
|
||||
holder.more.Click += (sender, e) =>
|
||||
{
|
||||
int tagPosition = (int)((ImageView)sender).Tag;
|
||||
YoutubeSearch.instances[0].More(items[tagPosition].song);
|
||||
MainActivity.instance.More(items[tagPosition].song);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Opus.Fragments
|
||||
SongManager.Play(song);
|
||||
}, (song, position) =>
|
||||
{
|
||||
More(song);
|
||||
MainActivity.instance.More(song);
|
||||
}, (position) =>
|
||||
{
|
||||
LocalManager.ShuffleAll();
|
||||
@@ -150,45 +150,6 @@ namespace Opus.Fragments
|
||||
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
||||
}
|
||||
|
||||
public async void More(Song item)
|
||||
{
|
||||
item = LocalManager.CompleteItem(item);
|
||||
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
if(item.AlbumArt == -1 || item.IsYt)
|
||||
{
|
||||
Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
else
|
||||
{
|
||||
var songCover = Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);
|
||||
|
||||
Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, MainActivity.instance.Resources.GetString(Resource.String.play), (sender, eventArg) => { SongManager.Play(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistPlay, MainActivity.instance.Resources.GetString(Resource.String.play_next), (sender, eventArg) => { SongManager.PlayNext(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.Queue, MainActivity.instance.Resources.GetString(Resource.String.play_last), (sender, eventArg) => { SongManager.PlayLast(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, MainActivity.instance.Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) => { PlaylistManager.AddSongToPlaylistDialog(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.Edit, MainActivity.instance.Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) => { LocalManager.EditMetadata(item); bottomSheet.Dismiss(); })
|
||||
};
|
||||
|
||||
if (await SongManager.IsFavorite(item))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, MainActivity.instance.Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(item); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, MainActivity.instance.Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(item); bottomSheet.Dismiss(); }));
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
}
|
||||
|
||||
public override void OnViewStateRestored(Bundle savedInstanceState)
|
||||
{
|
||||
base.OnViewStateRestored(savedInstanceState);
|
||||
|
||||
@@ -137,45 +137,9 @@ namespace Opus.Fragments
|
||||
LoaderManager.GetInstance(this).RestartLoader(0, null, this);
|
||||
}
|
||||
|
||||
public async void More(Song item, int position)
|
||||
public void More(Song item, int position)
|
||||
{
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
if (item.AlbumArt == -1 || item.IsYt)
|
||||
{
|
||||
Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
else
|
||||
{
|
||||
var songCover = Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);
|
||||
|
||||
Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, Resources.GetString(Resource.String.play), (sender, eventArg) =>
|
||||
{
|
||||
LocalManager.PlayInOrder(path, position);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistPlay, Resources.GetString(Resource.String.play_next), (sender, eventArg) => { SongManager.PlayNext(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.Queue, Resources.GetString(Resource.String.play_last), (sender, eventArg) => { SongManager.PlayLast(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) => { PlaylistManager.AddSongToPlaylistDialog(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.Edit, Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) => { LocalManager.EditMetadata(item); bottomSheet.Dismiss(); })
|
||||
};
|
||||
|
||||
if (await SongManager.IsFavorite(item))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, MainActivity.instance.Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(item); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, MainActivity.instance.Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(item); bottomSheet.Dismiss(); }));
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
MainActivity.instance.More(item, () => { LocalManager.PlayInOrder(path, position); });
|
||||
}
|
||||
|
||||
public override void OnResume()
|
||||
|
||||
@@ -458,102 +458,17 @@ namespace Opus.Fragments
|
||||
}
|
||||
}
|
||||
|
||||
public async void More(Song song, int position)
|
||||
public void More(Song song, int position)
|
||||
{
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = song.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = song.Artist;
|
||||
if (song.AlbumArt == -1 || song.IsYt)
|
||||
BottomSheetAction endAction = new BottomSheetAction(Resource.Drawable.Close, Resources.GetString(Resource.String.remove_track_from_playlist), (sender, eventArg) =>
|
||||
{
|
||||
Picasso.With(MainActivity.instance).Load(song.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
RemoveFromPlaylist(song, position);
|
||||
});
|
||||
|
||||
if (useHeader)
|
||||
MainActivity.instance.More(song, () => { PlaylistManager.PlayInOrder(item, position); }, endAction);
|
||||
else
|
||||
{
|
||||
var songCover = Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, song.AlbumArt);
|
||||
|
||||
Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, Resources.GetString(Resource.String.play), (sender, eventArg) =>
|
||||
{
|
||||
if(useHeader)
|
||||
PlaylistManager.PlayInOrder(item, position);
|
||||
else
|
||||
SongManager.Play(song);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistPlay, Resources.GetString(Resource.String.play_next), (sender, eventArg) =>
|
||||
{
|
||||
SongManager.PlayNext(song);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Queue, Resources.GetString(Resource.String.play_last), (sender, eventArg) =>
|
||||
{
|
||||
SongManager.PlayLast(song);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) =>
|
||||
{
|
||||
PlaylistManager.AddSongToPlaylistDialog(song);
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
};
|
||||
|
||||
if (item.HasWritePermission)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Close, Resources.GetString(Resource.String.remove_track_from_playlist), (sender, eventArg) =>
|
||||
{
|
||||
RemoveFromPlaylist(song, position);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
|
||||
if (!song.IsYt)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Edit, Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) =>
|
||||
{
|
||||
LocalManager.EditMetadata(song);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
actions.AddRange(new BottomSheetAction[]
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.PlayCircle, Resources.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.CreateMixFromSong(song);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Download, Resources.GetString(Resource.String.download), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.Download(new[] { song });
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
});
|
||||
|
||||
if (song.ChannelID != null)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.account, Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
|
||||
{
|
||||
ChannelManager.OpenChannelTab(song.ChannelID);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
if (await SongManager.IsFavorite(song))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, MainActivity.instance.Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(song); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, MainActivity.instance.Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(song); bottomSheet.Dismiss(); }));
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
MainActivity.instance.More(song, null, endAction);
|
||||
}
|
||||
|
||||
public void RemoveFromPlaylist(Song item, int position)
|
||||
|
||||
@@ -168,75 +168,14 @@ public class Queue : Fragment, RecyclerView.IOnItemTouchListener, PopupMenu.IOnM
|
||||
More(position);
|
||||
}
|
||||
|
||||
public async void More(int position)
|
||||
public void More(int position)
|
||||
{
|
||||
Song item = MusicPlayer.queue[position];
|
||||
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
if (item.AlbumArt == -1 || item.IsYt)
|
||||
BottomSheetAction endAction = new BottomSheetAction(Resource.Drawable.Close, MainActivity.instance.GetString(Resource.String.remove_from_queue), (sender, eventArg) =>
|
||||
{
|
||||
Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
else
|
||||
{
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);
|
||||
|
||||
Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
}
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, MainActivity.instance.GetString(Resource.String.play), (sender, eventArg) => { ListView_ItemClick(null, position); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.Close, MainActivity.instance.GetString(Resource.String.remove_from_queue), (sender, eventArg) => { MusicPlayer.RemoveFromQueue(position); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, MainActivity.instance.GetString(Resource.String.add_to_playlist), (sender, eventArg) => { PlaylistManager.AddSongToPlaylistDialog(item); bottomSheet.Dismiss(); })
|
||||
};
|
||||
|
||||
if (item.IsYt)
|
||||
{
|
||||
actions.AddRange(new BottomSheetAction[]
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.PlayCircle, MainActivity.instance.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.CreateMixFromSong(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Download, MainActivity.instance.GetString(Resource.String.download), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.Download(new[] { item });
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
});
|
||||
|
||||
if (item.ChannelID != null)
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.account, Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
|
||||
{
|
||||
ChannelManager.OpenChannelTab(item.ChannelID);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Edit, MainActivity.instance.GetString(Resource.String.edit_metadata), (sender, eventArg) =>
|
||||
{
|
||||
LocalManager.EditMetadata(item);
|
||||
bottomSheet.Dismiss();
|
||||
}));
|
||||
}
|
||||
|
||||
if (await SongManager.IsFavorite(item))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, MainActivity.instance.Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(item); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, MainActivity.instance.Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(item); bottomSheet.Dismiss(); }));
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
MusicPlayer.RemoveFromQueue(position);
|
||||
});
|
||||
MainActivity.instance.More(item, () => { ListView_ItemClick(null, position); }, endAction);
|
||||
}
|
||||
|
||||
void HeaderClick()
|
||||
|
||||
@@ -361,7 +361,7 @@ namespace Opus.Fragments
|
||||
if(result[position].Kind == YtKind.Video)
|
||||
{
|
||||
Song item = result[position].song;
|
||||
More(item);
|
||||
MainActivity.instance.More(item);
|
||||
}
|
||||
else if(result[position].Kind == YtKind.Playlist)
|
||||
{
|
||||
@@ -370,63 +370,6 @@ namespace Opus.Fragments
|
||||
}
|
||||
}
|
||||
|
||||
public async void More(Song item)
|
||||
{
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsTitle).Text = item.Title;
|
||||
bottomView.FindViewById<TextView>(Resource.Id.bsArtist).Text = item.Artist;
|
||||
Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById<ImageView>(Resource.Id.bsArt));
|
||||
bottomSheet.SetContentView(bottomView);
|
||||
|
||||
List<BottomSheetAction> actions = new List<BottomSheetAction>
|
||||
{
|
||||
new BottomSheetAction(Resource.Drawable.Play, MainActivity.instance.Resources.GetString(Resource.String.play), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.Play(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistPlay, MainActivity.instance.Resources.GetString(Resource.String.play_next), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.PlayNext(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.Queue, MainActivity.instance.Resources.GetString(Resource.String.play_last), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.PlayLast(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlayCircle, MainActivity.instance.Resources.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.CreateMixFromSong(item);
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.PlaylistAdd, MainActivity.instance.Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) => { PlaylistManager.AddSongToPlaylistDialog(item); bottomSheet.Dismiss(); }),
|
||||
new BottomSheetAction(Resource.Drawable.Download, MainActivity.instance.Resources.GetString(Resource.String.download), (sender, eventArg) =>
|
||||
{
|
||||
YoutubeManager.Download(new[] { item });
|
||||
bottomSheet.Dismiss();
|
||||
}),
|
||||
new BottomSheetAction(Resource.Drawable.account, MainActivity.instance.Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
|
||||
{
|
||||
MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = false;
|
||||
MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
|
||||
MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
|
||||
MainActivity.instance.FindViewById<TabLayout>(Resource.Id.tabs).Visibility = ViewStates.Gone;
|
||||
ChannelManager.OpenChannelTab(item.ChannelID);
|
||||
bottomSheet.Dismiss();
|
||||
})
|
||||
};
|
||||
|
||||
if (await SongManager.IsFavorite(item))
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Fav, MainActivity.instance.Resources.GetString(Resource.String.unfav), (sender, eventArg) => { SongManager.UnFav(item); bottomSheet.Dismiss(); }));
|
||||
else
|
||||
actions.Add(new BottomSheetAction(Resource.Drawable.Unfav, MainActivity.instance.Resources.GetString(Resource.String.fav), (sender, eventArg) => { SongManager.Fav(item); bottomSheet.Dismiss(); }));
|
||||
|
||||
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
|
||||
bottomSheet.Show();
|
||||
}
|
||||
|
||||
public async void PlaylistMore(PlaylistItem item)
|
||||
{
|
||||
BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
|
||||
|
||||
Reference in New Issue
Block a user