From 41c5420b9f6123f6b0b3c31289c41f6d5344448e Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Thu, 7 Jun 2018 10:29:00 +0300 Subject: [PATCH] A ton of improvements --- FoxTube/About.xaml | 62 ------------- FoxTube/About.xaml.cs | 33 ------- FoxTube/Channel.xaml | 25 ++--- FoxTube/Channel.xaml.cs | 89 +++++++++++------- FoxTube/Feedback.xaml | 13 ++- FoxTube/Feedback.xaml.cs | 24 ++++- FoxTube/FoxTube.csproj | 21 +++-- FoxTube/Home.xaml | 15 ++- FoxTube/LoadingPage.xaml | 38 ++++++++ FoxTube/LoadingPage.xaml.cs | 69 ++++++++++++++ FoxTube/MainPage.xaml | 18 ++-- FoxTube/MainPage.xaml.cs | 30 +++--- FoxTube/Package.appxmanifest | 2 +- FoxTube/SecretsVault.cs | 60 ++++++++++++ FoxTube/Settings.xaml | 167 ++++++++++++++++++++++++++-------- FoxTube/Settings.xaml.cs | 96 +++++++++++++++---- FoxTube/Translate.xaml | 51 ++++++++--- FoxTube/Translate.xaml.cs | 96 ++++++++++++++++++- FoxTube/VideoCard.xaml | 14 +-- FoxTube/VideoCard.xaml.cs | 42 ++++++++- FoxTube/VideoCardWide.xaml.cs | 13 ++- FoxTube/VideoGrid.xaml | 28 ------ FoxTube/VideoGrid.xaml.cs | 65 ++----------- FoxTube/VideoPlayer.xaml | 12 ++- 24 files changed, 727 insertions(+), 356 deletions(-) delete mode 100644 FoxTube/About.xaml delete mode 100644 FoxTube/About.xaml.cs create mode 100644 FoxTube/LoadingPage.xaml create mode 100644 FoxTube/LoadingPage.xaml.cs create mode 100644 FoxTube/SecretsVault.cs diff --git a/FoxTube/About.xaml b/FoxTube/About.xaml deleted file mode 100644 index 027b245..0000000 --- a/FoxTube/About.xaml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FoxTube/About.xaml.cs b/FoxTube/About.xaml.cs deleted file mode 100644 index 7916765..0000000 --- a/FoxTube/About.xaml.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.ApplicationModel; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 - -namespace FoxTube -{ - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class About : Page - { - PackageVersion ver = Package.Current.Id.Version; - public About() - { - this.InitializeComponent(); - version.Text = string.Format("{0}.{1}.{2}" , ver.Major, ver.Minor, ver.Build); - } - } -} diff --git a/FoxTube/Channel.xaml b/FoxTube/Channel.xaml index 8f2aab1..e70757d 100644 --- a/FoxTube/Channel.xaml +++ b/FoxTube/Channel.xaml @@ -31,17 +31,12 @@ FontFamily="Segoe MDL2 Assets" Content="" FontSize="20" FocusVisualSecondaryBrush="#66FFFFFF" FocusVisualPrimaryBrush="White" Foreground="White"/> - - + + - - - - - - - - + + + @@ -58,10 +53,7 @@ - - - - + @@ -141,8 +133,9 @@ - - + + + diff --git a/FoxTube/Channel.xaml.cs b/FoxTube/Channel.xaml.cs index 4f170f1..09f6785 100644 --- a/FoxTube/Channel.xaml.cs +++ b/FoxTube/Channel.xaml.cs @@ -17,6 +17,7 @@ using Google.Apis.Services; using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3.Data; using Windows.UI.Xaml.Media.Imaging; +using Windows.UI.Text; // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 @@ -29,6 +30,7 @@ namespace FoxTube { public string channelId; public Google.Apis.YouTube.v3.Data.Channel item; + VideoGrid videoGrid = new VideoGrid(); public Channel() { this.InitializeComponent(); @@ -43,11 +45,7 @@ namespace FoxTube { channelId = id; - YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer() - { - ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0", - ApplicationName = this.GetType().ToString() - }); + YouTubeService ytService = SecretsVault.YoutubeService; ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics,brandingSettings"); request.Id = id; @@ -67,6 +65,22 @@ namespace FoxTube registration.Text = item.Snippet.PublishedAt.ToString(); searchChannel.Text = item.Snippet.Title; + + SearchResource.ListRequest request2 = ytService.Search.List("snippet"); + request2.ChannelId = id; + request2.Type = "video"; + request2.Order = SearchResource.ListRequest.OrderEnum.Date; + request2.MaxResults = 48; + + SearchListResponse response2 = await request2.ExecuteAsync(); + + videos.Children.Add(videoGrid); + + foreach(Google.Apis.YouTube.v3.Data.SearchResult vid in response2.Items) + { + VideoCard vCard = new VideoCard(vid.Id.VideoId); + videoGrid.AddCards(vCard); + } } private void toVideos_Click(object sender, RoutedEventArgs e) @@ -74,43 +88,16 @@ namespace FoxTube content.SelectedIndex = 0; } - private async void toPlaylists_Click(object sender, RoutedEventArgs e) + private void toPlaylists_Click(object sender, RoutedEventArgs e) { content.SelectedIndex = 1; - - if(playlists.Children.Count == 0) - { - YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer() - { - ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0", - ApplicationName = this.GetType().ToString() - }); - - PlaylistsResource.ListRequest request = ytService.Playlists.List("snippet,contentDetails"); - request.MaxResults = 25; - request.ChannelId = channelId; - PlaylistListResponse response = await request.ExecuteAsync(); - - foreach (Playlist playlist in response.Items) - { - PlaylistCardWide playlistCard = new PlaylistCardWide(playlist.Id, true); - playlists.Children.Add(playlistCard); - } - - playlistRing.IsActive = false; - playlistPane.Visibility = Visibility.Visible; - } } private async void searchButton_Click(object sender, RoutedEventArgs e) { content.SelectedIndex = 3; - YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer() - { - ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0", - ApplicationName = this.GetType().ToString() - }); + YouTubeService ytService = SecretsVault.YoutubeService; var searchListRequest = ytService.Search.List("snippet"); searchListRequest.Q = searchField.Text; @@ -147,5 +134,39 @@ namespace FoxTube break; } } + + private async void content_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + toVideos.FontWeight = FontWeights.Normal; + toPlaylists.FontWeight = FontWeights.Normal; + toAbout.FontWeight = FontWeights.Normal; + if (content.SelectedIndex == 0) + toVideos.FontWeight = FontWeights.Bold; + else if (content.SelectedIndex == 1) + { + toPlaylists.FontWeight = FontWeights.Bold; + + if (playlists.Children.Count == 0) + { + YouTubeService ytService = SecretsVault.YoutubeService; + + PlaylistsResource.ListRequest request = ytService.Playlists.List("snippet,contentDetails"); + request.MaxResults = 25; + request.ChannelId = channelId; + PlaylistListResponse response = await request.ExecuteAsync(); + + foreach (Playlist playlist in response.Items) + { + PlaylistCardWide playlistCard = new PlaylistCardWide(playlist.Id, true); + playlists.Children.Add(playlistCard); + } + + playlistRing.IsActive = false; + playlistPane.Visibility = Visibility.Visible; + } + } + else if (content.SelectedIndex == 2) + toAbout.FontWeight = FontWeights.Bold; + } } } diff --git a/FoxTube/Feedback.xaml b/FoxTube/Feedback.xaml index 2f115e4..d67317f 100644 --- a/FoxTube/Feedback.xaml +++ b/FoxTube/Feedback.xaml @@ -28,11 +28,20 @@ + + + + + + + + + - + @@ -43,7 +52,7 @@ - - - + @@ -102,8 +106,8 @@ - -