Adding open channels features where possible.

This commit is contained in:
Anonymus Raccoon
2019-06-30 15:11:00 +02:00
parent cae1885999
commit c31a16f0e8
9 changed files with 66 additions and 15 deletions

View File

@@ -358,7 +358,10 @@ namespace Opus.Api
{ {
if (ytItem.Snippet.Title != "[Deleted video]" && ytItem.Snippet.Title != "Private video" && ytItem.Snippet.Title != "Deleted video" && !MusicPlayer.queue.Exists(x => x.YoutubeID == ytItem.ContentDetails.VideoId)) if (ytItem.Snippet.Title != "[Deleted video]" && ytItem.Snippet.Title != "Private video" && ytItem.Snippet.Title != "Deleted video" && !MusicPlayer.queue.Exists(x => x.YoutubeID == ytItem.ContentDetails.VideoId))
{ {
Song song = new Song(System.Net.WebUtility.HtmlDecode(ytItem.Snippet.Title), ytItem.Snippet.ChannelTitle, ytItem.Snippet.Thumbnails.High.Url, ytItem.ContentDetails.VideoId, -1, -1, ytItem.ContentDetails.VideoId, true, false); Song song = new Song(WebUtility.HtmlDecode(ytItem.Snippet.Title), ytItem.Snippet.ChannelTitle, ytItem.Snippet.Thumbnails.High.Url, ytItem.ContentDetails.VideoId, -1, -1, ytItem.ContentDetails.VideoId, true, false)
{
ChannelID = ytItem.Snippet.ChannelId
};
tracks.Add(song); tracks.Add(song);
} }
} }
@@ -413,7 +416,10 @@ namespace Opus.Api
foreach (var video in searchReponse.Items) foreach (var video in searchReponse.Items)
{ {
Song song = new Song(WebUtility.HtmlDecode(video.Snippet.Title), video.Snippet.ChannelTitle, video.Snippet.Thumbnails.High.Url, video.Id.VideoId, -1, -1, null, true, false); Song song = new Song(WebUtility.HtmlDecode(video.Snippet.Title), video.Snippet.ChannelTitle, video.Snippet.Thumbnails.High.Url, video.Id.VideoId, -1, -1, null, true, false)
{
ChannelID = video.Snippet.ChannelId
};
songs.Add(song); songs.Add(song);
} }
} }

View File

@@ -27,11 +27,11 @@ namespace Opus.DataStructure
public string Path { get; set; } public string Path { get; set; }
public bool? IsParsed { get; set; } public bool? IsParsed { get; set; }
public bool IsYt { get; set; } public bool IsYt { get; set; }
public string ChannelID { get; set; }
public DateTimeOffset? ExpireDate { get; set;} public DateTimeOffset? ExpireDate { get; set;}
public int Duration { get; set; } public int Duration { get; set; }
public bool IsLiveStream = false; public bool IsLiveStream = false;
public string TrackID; public string TrackID;
public string channelID;
public Song() { } public Song() { }
@@ -60,9 +60,9 @@ namespace Opus.DataStructure
int albumID = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Album); int albumID = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Album);
int thisID = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id); int thisID = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id);
int pathID = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data); int pathID = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data);
int playOrderID = cursor.GetColumnIndex(MediaStore.Audio.Playlists.Members.PlayOrder); //int playOrderID = cursor.GetColumnIndex(MediaStore.Audio.Playlists.Members.PlayOrder);
string playOrder = PlaylistTracks.instance != null ? cursor.GetString(playOrderID) : null; //string playOrder = PlaylistTracks.instance != null ? cursor.GetString(playOrderID) : null;
string Artist = cursor.GetString(artistID); string Artist = cursor.GetString(artistID);
string Title = cursor.GetString(titleID); string Title = cursor.GetString(titleID);
string Album = cursor.GetString(albumID); string Album = cursor.GetString(albumID);
@@ -77,7 +77,7 @@ namespace Opus.DataStructure
if (Album == null) if (Album == null)
Album = "Unknow Album"; Album = "Unknow Album";
return new Song(Title, playOrder ?? Artist, Album, null, AlbumArt, id, path); return new Song(Title, /*playOrder ?? */Artist, Album, null, AlbumArt, id, path);
} }
public static explicit operator Song(YoutubeExplode.Models.Video video) public static explicit operator Song(YoutubeExplode.Models.Video video)

View File

@@ -210,6 +210,15 @@ namespace Opus.Adapter
bottomSheet.Dismiss(); 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 else
{ {
@@ -289,6 +298,15 @@ namespace Opus.Adapter
bottomSheet.Dismiss(); 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();
}));
}
} }
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions); bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);

View File

@@ -312,7 +312,8 @@ namespace Opus.Fragments
{ {
Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.High.Url, item.ContentDetails.VideoId, -1, -1, item.ContentDetails.VideoId, true, false) Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.High.Url, item.ContentDetails.VideoId, -1, -1, item.ContentDetails.VideoId, true, false)
{ {
TrackID = item.Id TrackID = item.Id,
ChannelID = item.Snippet.ChannelId
}; };
tracks.Add(song); tracks.Add(song);
} }
@@ -401,7 +402,8 @@ namespace Opus.Fragments
{ {
Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.Default__.Url, item.ContentDetails.VideoId, -1, -1, item.ContentDetails.VideoId, true, false) Song song = new Song(item.Snippet.Title, item.Snippet.ChannelTitle, item.Snippet.Thumbnails.Default__.Url, item.ContentDetails.VideoId, -1, -1, item.ContentDetails.VideoId, true, false)
{ {
TrackID = item.Id TrackID = item.Id,
ChannelID = item.Snippet.ChannelId
}; };
adapter.tracks.Add(song); adapter.tracks.Add(song);
} }
@@ -532,6 +534,15 @@ namespace Opus.Fragments
bottomSheet.Dismiss(); 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();
}));
}
} }
bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions); bottomSheet.FindViewById<ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);

View File

@@ -146,8 +146,6 @@ public class Queue : Fragment, RecyclerView.IOnItemTouchListener, PopupMenu.IOnM
private void ListView_ItemClick(object sender, int Position) private void ListView_ItemClick(object sender, int Position)
{ {
Song item = MusicPlayer.queue[Position];
if (Position == MusicPlayer.CurrentID()) if (Position == MusicPlayer.CurrentID())
{ {
Intent intent = new Intent(Activity, typeof(MusicPlayer)); Intent intent = new Intent(Activity, typeof(MusicPlayer));
@@ -213,6 +211,15 @@ public class Queue : Fragment, RecyclerView.IOnItemTouchListener, PopupMenu.IOnM
bottomSheet.Dismiss(); 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 else
{ {

View File

@@ -307,7 +307,7 @@ namespace Opus.Fragments
case "youtube#video": case "youtube#video":
Song videoInfo = new Song(System.Net.WebUtility.HtmlDecode(result.Snippet.Title), result.Snippet.ChannelTitle, result.Snippet.Thumbnails.High.Url, result.Id.VideoId, -1, -1, null, true, false) Song videoInfo = new Song(System.Net.WebUtility.HtmlDecode(result.Snippet.Title), result.Snippet.ChannelTitle, result.Snippet.Thumbnails.High.Url, result.Id.VideoId, -1, -1, null, true, false)
{ {
channelID = result.Snippet.ChannelId ChannelID = result.Snippet.ChannelId
}; };
if (result.Snippet.LiveBroadcastContent == "live") if (result.Snippet.LiveBroadcastContent == "live")
videoInfo.IsLiveStream = true; videoInfo.IsLiveStream = true;
@@ -413,7 +413,7 @@ namespace Opus.Fragments
MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView(); MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true; MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
MainActivity.instance.FindViewById<TabLayout>(Resource.Id.tabs).Visibility = ViewStates.Gone; MainActivity.instance.FindViewById<TabLayout>(Resource.Id.tabs).Visibility = ViewStates.Gone;
ChannelManager.OpenChannelTab(item.channelID); ChannelManager.OpenChannelTab(item.ChannelID);
bottomSheet.Dismiss(); bottomSheet.Dismiss();
}) })
}); });

View File

@@ -448,6 +448,15 @@ namespace Opus
bottomSheet.Dismiss(); 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 else
{ {

View File

@@ -319,8 +319,8 @@
<Reference Include="Xamarin.GooglePlayServices.Tasks, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Xamarin.GooglePlayServices.Tasks, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.GooglePlayServices.Tasks.70.1501.0-preview2\lib\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.dll</HintPath> <HintPath>..\packages\Xamarin.GooglePlayServices.Tasks.70.1501.0-preview2\lib\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.dll</HintPath>
</Reference> </Reference>
<Reference Include="YoutubeExplode, Version=4.7.3.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="YoutubeExplode, Version=4.7.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\YoutubeExplode.4.7.3\lib\netstandard2.0\YoutubeExplode.dll</HintPath> <HintPath>..\packages\YoutubeExplode.4.7.4\lib\netstandard2.0\YoutubeExplode.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -125,5 +125,5 @@
<package id="Xamarin.GooglePlayServices.Cast.Framework" version="70.1501.0-preview2" targetFramework="monoandroid81" /> <package id="Xamarin.GooglePlayServices.Cast.Framework" version="70.1501.0-preview2" targetFramework="monoandroid81" />
<package id="Xamarin.GooglePlayServices.Flags" version="70.1501.0-preview2" targetFramework="monoandroid81" /> <package id="Xamarin.GooglePlayServices.Flags" version="70.1501.0-preview2" targetFramework="monoandroid81" />
<package id="Xamarin.GooglePlayServices.Tasks" version="70.1501.0-preview2" targetFramework="monoandroid81" /> <package id="Xamarin.GooglePlayServices.Tasks" version="70.1501.0-preview2" targetFramework="monoandroid81" />
<package id="YoutubeExplode" version="4.7.3" targetFramework="monoandroid90" /> <package id="YoutubeExplode" version="4.7.4" targetFramework="monoandroid90" />
</packages> </packages>