From 550192d54037e4e38ea9124f6c6dc30832035d2b Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Sat, 2 Feb 2019 15:14:35 +0300 Subject: [PATCH] Fixes. Preparing for submission --- FoxTube.Background/BackgroundProcessor.cs | 14 +++- FoxTube.Background/FoxTube.Background.csproj | 3 + FoxTube.Background/ResourceCreators.cs | 1 - FoxTube/App.xaml.cs | 25 ++++++-- FoxTube/Assets/BadgeLogo.scale-100.png | Bin 0 -> 562 bytes FoxTube/Assets/BadgeLogo.scale-125.png | Bin 0 -> 667 bytes FoxTube/Assets/BadgeLogo.scale-150.png | Bin 0 -> 672 bytes FoxTube/Assets/BadgeLogo.scale-200.png | Bin 0 -> 804 bytes FoxTube/Assets/BadgeLogo.scale-400.png | Bin 0 -> 1360 bytes FoxTube/Classes/DownloadAgent.cs | 1 - FoxTube/Classes/DownloadItemContainer.cs | 1 - FoxTube/Classes/InboxItem.cs | 1 - FoxTube/Classes/Methods.cs | 39 +----------- FoxTube/Classes/SecretsVault.cs | 4 +- FoxTube/FoxTube.csproj | 51 +++++++-------- FoxTube/Package.appxmanifest | 9 +-- FoxTube/Pages/Browser.xaml | 27 ++++++++ FoxTube/Pages/Browser.xaml.cs | 60 ++++++++++++++++++ FoxTube/Pages/ChannelPage.xaml | 14 ++-- FoxTube/Pages/ChannelPage.xaml.cs | 35 ++++++---- FoxTube/Pages/Downloads.xaml | 2 - FoxTube/Pages/Downloads.xaml.cs | 15 +---- FoxTube/Pages/History.xaml | 1 - FoxTube/Pages/History.xaml.cs | 9 +-- FoxTube/Pages/Home.xaml.cs | 4 +- FoxTube/Pages/MainPage.xaml | 21 +++--- FoxTube/Pages/MainPage.xaml.cs | 32 ++++++---- FoxTube/Pages/PlaylistPage.xaml | 1 - FoxTube/Pages/PlaylistPage.xaml.cs | 14 +++- FoxTube/Pages/Search.xaml | 10 +-- FoxTube/Pages/Search.xaml.cs | 20 +++--- FoxTube/Pages/Settings.xaml | 9 +-- FoxTube/Pages/Settings.xaml.cs | 38 ++--------- FoxTube/Pages/SettingsPages/About.xaml | 1 - FoxTube/Pages/SettingsPages/About.xaml.cs | 15 +---- FoxTube/Pages/SettingsPages/General.xaml | 1 - FoxTube/Pages/SettingsPages/Inbox.xaml | 3 +- FoxTube/Pages/Subscriptions.xaml | 1 - FoxTube/Pages/Subscriptions.xaml.cs | 19 +----- FoxTube/Pages/VideoGrid.xaml | 1 - FoxTube/Pages/VideoGrid.xaml.cs | 4 +- FoxTube/Pages/VideoPage.xaml.cs | 9 ++- {FoxTube => Src}/Notifications/Comment.xml | 0 {FoxTube => Src}/Notifications/Download.xml | 0 .../Notifications/DownloadComplete.xml | 0 {FoxTube => Src}/Notifications/Internal.xml | 0 .../NotificationsHistorySample.xml | 0 {FoxTube => Src}/Notifications/Post.xml | 0 .../Notifications/ServerLogSamlpe.xml | 0 {FoxTube => Src}/Notifications/Video.xml | 0 .../Notifications/downloadHistorySample.xml | 0 51 files changed, 262 insertions(+), 253 deletions(-) create mode 100644 FoxTube/Assets/BadgeLogo.scale-100.png create mode 100644 FoxTube/Assets/BadgeLogo.scale-125.png create mode 100644 FoxTube/Assets/BadgeLogo.scale-150.png create mode 100644 FoxTube/Assets/BadgeLogo.scale-200.png create mode 100644 FoxTube/Assets/BadgeLogo.scale-400.png create mode 100644 FoxTube/Pages/Browser.xaml create mode 100644 FoxTube/Pages/Browser.xaml.cs rename {FoxTube => Src}/Notifications/Comment.xml (100%) rename {FoxTube => Src}/Notifications/Download.xml (100%) rename {FoxTube => Src}/Notifications/DownloadComplete.xml (100%) rename {FoxTube => Src}/Notifications/Internal.xml (100%) rename {FoxTube => Src}/Notifications/NotificationsHistorySample.xml (100%) rename {FoxTube => Src}/Notifications/Post.xml (100%) rename {FoxTube => Src}/Notifications/ServerLogSamlpe.xml (100%) rename {FoxTube => Src}/Notifications/Video.xml (100%) rename {FoxTube => Src}/Notifications/downloadHistorySample.xml (100%) diff --git a/FoxTube.Background/BackgroundProcessor.cs b/FoxTube.Background/BackgroundProcessor.cs index 97ca597..a05d2e3 100644 --- a/FoxTube.Background/BackgroundProcessor.cs +++ b/FoxTube.Background/BackgroundProcessor.cs @@ -1,6 +1,7 @@ using Google.Apis.Services; using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3.Data; +using Microsoft.AppCenter.Analytics; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -16,7 +17,7 @@ namespace FoxTube.Background public sealed class BackgroundProcessor : IBackgroundTask { private DateTime lastCheck = DateTime.Now; - private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; + private readonly ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; private YouTubeService Service => new YouTubeService(new BaseClientService.Initializer() { ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0", @@ -29,6 +30,7 @@ namespace FoxTube.Background try { def = taskInstance.GetDeferral(); + taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled); if (settings.Values["lastCheck"] == null) { @@ -45,7 +47,6 @@ namespace FoxTube.Background if (notificationsSettings[1]) await CheckAccount(); } - catch { } finally { settings.Values["lastCheck"] = DateTime.Now.ToString(); @@ -53,6 +54,15 @@ namespace FoxTube.Background } } + private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason) + { + Analytics.TrackEvent("Background task caneled", new Dictionary() + { + { "Reason", reason.ToString() } + }); + settings.Values["lastCheck"] = DateTime.Now.ToString(); + } + async Task CheckAccount() { try diff --git a/FoxTube.Background/FoxTube.Background.csproj b/FoxTube.Background/FoxTube.Background.csproj index a9896f1..11a5b78 100644 --- a/FoxTube.Background/FoxTube.Background.csproj +++ b/FoxTube.Background/FoxTube.Background.csproj @@ -127,6 +127,9 @@ 1.29.2.1006 + + 1.13.0 + 6.1.5 diff --git a/FoxTube.Background/ResourceCreators.cs b/FoxTube.Background/ResourceCreators.cs index 1102a64..3df0305 100644 --- a/FoxTube.Background/ResourceCreators.cs +++ b/FoxTube.Background/ResourceCreators.cs @@ -1,6 +1,5 @@ using Newtonsoft.Json; using System.Collections.Generic; -using Windows.ApplicationModel.Resources; using Windows.Data.Xml.Dom; using Windows.Storage; using Windows.UI.Notifications; diff --git a/FoxTube/App.xaml.cs b/FoxTube/App.xaml.cs index e4ee801..5198496 100644 --- a/FoxTube/App.xaml.cs +++ b/FoxTube/App.xaml.cs @@ -1,5 +1,8 @@ using Google.Apis.YouTube.v3.Data; +using Microsoft.AppCenter; +using Microsoft.AppCenter.Analytics; using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Windows.ApplicationModel; @@ -42,6 +45,9 @@ namespace FoxTube ApplicationLanguages.PrimaryLanguageOverride = SettingsStorage.Language; InitializeComponent(); Suspending += OnSuspending; + UnhandledException += UnhandledError; + AppCenter.Start("45774462-9ea7-438a-96fc-03982666f39e", typeof(Analytics)); + AppCenter.SetCountryCode(SettingsStorage.Region); } /// @@ -51,11 +57,9 @@ namespace FoxTube /// Details about the launch request and process. protected override void OnLaunched(LaunchActivatedEventArgs e) { - Frame rootFrame = Window.Current.Content as Frame; - // Do not repeat app initialization when the Window already has content, // just ensure that the window is active - if (rootFrame == null) + if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); @@ -180,13 +184,11 @@ namespace FoxTube { base.OnActivated(e); - Frame rootFrame = Window.Current.Content as Frame; - - if (rootFrame == null) + if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; - + Window.Current.Content = rootFrame; } @@ -248,5 +250,14 @@ namespace FoxTube DownloadAgent.QuitPrompt(); deferral.Complete(); } + private void UnhandledError(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) + { + Analytics.TrackEvent("The app crashed", new Dictionary() + { + { "Exception", e.Exception.GetType().ToString() }, + { "Class", e.ToString() }, + { "Details", e.Message } + }); + } } } diff --git a/FoxTube/Assets/BadgeLogo.scale-100.png b/FoxTube/Assets/BadgeLogo.scale-100.png new file mode 100644 index 0000000000000000000000000000000000000000..d7bd4fbd47b3bf60e9f29c95e2855704a92dd80f GIT binary patch literal 562 zcmV-20?qx2P)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ-xJg7oRCwC#l}&EjFc5_wDGIV2x$+Mr`3CKU3iJ{^L68C|yl4<1X)n-aE|E=g zj9#EB>Zm&}X2>D4aRbM-kwlSqeEb*oEgdgkeDS)2R z7`*zM#&L`+%P^bGFrUv+6a}&@8%0s{SwtFZ?XifYz2rb^jWkU$nN0q|#^dpLkt9ju zy+5(m9y#amPiF`rY_9L2gRHe-wOaYMZLgNg<=ah9(@R>7fiXr627?h1MSGLnQA|YN zi0E8vz0_KxF8~qIB@xvk(rT@-ZQd2&i0G1;zc}aqXsr=N(es+!Q^w5vm59zn(^b07*qoM6N<$g4$N@ AG5`Po literal 0 HcmV?d00001 diff --git a/FoxTube/Assets/BadgeLogo.scale-125.png b/FoxTube/Assets/BadgeLogo.scale-125.png new file mode 100644 index 0000000000000000000000000000000000000000..079bb98a5f90138db0d12fe4b8b031d1dc250aa8 GIT binary patch literal 667 zcmV;M0%ZM(P)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ;AxT6*RCwC#mQ9Y@KoEsrx7!#nLgvRbXP5(JlRIQFndA<@(oX_~@Xi*C1zIF6x|3Yqym z5iN?M7@uO`}L}uQ51VQlg(4I7p%ZiAmd7h7%d8U+t)*7emZ{~~$r_Q;Nh-ABzR zDFvm}FR(-4{r9xiFvg%L3dC`I82o>s|Lef_0{}|EXFd6yVQv5b002ovPDHLkV1oDo BBYFS; literal 0 HcmV?d00001 diff --git a/FoxTube/Assets/BadgeLogo.scale-150.png b/FoxTube/Assets/BadgeLogo.scale-150.png new file mode 100644 index 0000000000000000000000000000000000000000..1166617d96ebf87a38137a4de027d2b77cf7156d GIT binary patch literal 672 zcmV;R0$=@!P)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1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fb2$KAmh001 Credential != null; - private static UserCredential Credential { get; set; } + public static UserCredential Credential { get; set; } public static string AccountId => UserChannel?.Id; public static Channel UserChannel { get; private set; } @@ -61,7 +61,7 @@ namespace FoxTube { if (!IsAuthorized) return false; - + if(Subscriptions.Exists(x => x.Snippet.ResourceId.ChannelId == id)) { Subscription s = Subscriptions.Find(x => x.Snippet.ResourceId.ChannelId == id); diff --git a/FoxTube/FoxTube.csproj b/FoxTube/FoxTube.csproj index 4e452f8..f6e2692 100644 --- a/FoxTube/FoxTube.csproj +++ b/FoxTube/FoxTube.csproj @@ -17,12 +17,11 @@ 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true - - - E888C12EC9A02B902D03CDA4515BDBE9F5E71F1F + FoxTube_StoreKey.pfx + 50B93E6A246058D555BA65CD203D7A02064A7409 False - False - C:\Users\Michael Gordeev\Downloads\FoxTube dists\0.2.1901-1\ + True + D:\XFox\Documents\FoxTube builds\0.3\ Always x86|x64|arm 1 @@ -137,6 +136,9 @@ ShowMore.xaml + + Browser.xaml + ChannelPage.xaml @@ -201,6 +203,11 @@ + + + + + @@ -250,25 +257,8 @@ - - Designer - - - Designer - - - - - Designer - - - - Designer - - - - Designer - + + @@ -318,6 +308,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -411,7 +405,10 @@ 1.29.2.1006 - 10.1805.7001 + 10.1811.22001 + + + 1.13.0 6.1.9 @@ -420,13 +417,13 @@ 5.0.0 - 4.0.0 + 5.0.0 4.3.2 - 4.6.1 + 4.6.4 0.10.11 diff --git a/FoxTube/Package.appxmanifest b/FoxTube/Package.appxmanifest index dc0f77a..2444bee 100644 --- a/FoxTube/Package.appxmanifest +++ b/FoxTube/Package.appxmanifest @@ -1,10 +1,10 @@  - - + + FoxTube - Michael Gordeev + Michael "XFox" Gordeev Assets\StoreLogo.png @@ -15,7 +15,7 @@ - + @@ -24,6 +24,7 @@ + diff --git a/FoxTube/Pages/Browser.xaml b/FoxTube/Pages/Browser.xaml new file mode 100644 index 0000000..cb258d5 --- /dev/null +++ b/FoxTube/Pages/Browser.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + diff --git a/FoxTube/Pages/Browser.xaml.cs b/FoxTube/Pages/Browser.xaml.cs new file mode 100644 index 0000000..bee5906 --- /dev/null +++ b/FoxTube/Pages/Browser.xaml.cs @@ -0,0 +1,60 @@ +using Google.Apis.Http; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Runtime.InteropServices.WindowsRuntime; +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.Pages +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class Browser : Page + { + public Browser() + { + InitializeComponent(); + Initialize(); + } + + + public async void Initialize() + { + /*Debug.WriteLine(SecretsVault.Credential.Token.AccessToken); + WebClient client = new WebClient(); + client.Headers.Add(HttpRequestHeader.Cookie, "SID=9wYUCqAm2D7AmC_Vi8uNGjYZAf6Js2hasI1gCEhznMjJbYqnt0J6m1sthArcXG_pMMadnQ.; HSID=AhyajPo6nPBx7VB-0; SSID=AaaOvEW6jZVcc4Asp; APISID=tXeMRBKErzlt6KOo/Aapw7Rv4U_HG1A0CQ; SAPISID=FGp4Ff7MMF8Yq0X4/AOdNjGueWyCkkK7C5; LOGIN_INFO=AFmmF2swRAIgZln6SD5aFUlABb9pBEq9uAwLBISe7sYR1NWVXyaDTY4CIBLo_KAFcoo4wtlW0ZPmJnHaa-xVhsA7MzdGm7-vvgX-:QUQ3MjNmekJTZ3M2dXJNaFh3M3NfTFVDS0RIaUM3WlJNWlRJbk5sZUE1eHR3bHkwckhQeEppazkyekhDb0ljcXpacDdwQXlIanhSbnpSWkUyZVFpdWtiT243Rzhad0N4aGZwUXJDZ1Mxd0tFTS0wVDdudk9xaFJDdTNYUWtnQlE3VXhQdVl5MjB2MGdEdl9keElDaS1yX0tmQWowS041ZWF1VU9tV0c3bTRVbWNGSHFjWHRDVTIw;");*/ + HttpClient client = new HttpClient(); + client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "BQcUCusfz2zKN_ejHc3Xu15ahz8eEEaKouKJydqBAVKxWxcqfhht1zVux-G9bRf0KSTFBw"); + /*SecretsVault.Credential.ToString(); + string url = $"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=HL&hl=en"; + string response = client.DownloadString(url.ToUri()); + HttpClient c = new HttpClient();*/ + string response = await SecretsVault.Service.HttpClient.GetStringAsync("https://www.youtube.com/list_ajax?style=xml&action_get_list=1&list=HL"); + //HttpResponseMessage res = await c.GetAsync(""); + Debug.WriteLine(response); + + /*new Google.Apis.Oauth2.v2.Oauth2Service.Initializer(); + code.Text = response;*/ + } + + private void Adress_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) + { + Initialize(); + } + } +} diff --git a/FoxTube/Pages/ChannelPage.xaml b/FoxTube/Pages/ChannelPage.xaml index 78cf453..a3c4710 100644 --- a/FoxTube/Pages/ChannelPage.xaml +++ b/FoxTube/Pages/ChannelPage.xaml @@ -16,7 +16,7 @@ - + @@ -39,11 +39,11 @@ - public sealed partial class ChannelPage : Page { - ResourceLoader resources = ResourceLoader.GetForCurrentView("Cards"); + readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Cards"); public string channelId; public Channel item; - LoadingPage loading, playlistLoading; - VideoGrid videoList, playlistList; - ShowMore videoMore, playlistMore; + readonly LoadingPage loading, playlistLoading; + readonly VideoGrid videoList, playlistList; + readonly ShowMore videoMore, playlistMore; SearchResource.ListRequest videoRequest, playlistRequest; @@ -48,7 +50,7 @@ namespace FoxTube.Pages videoMore = videos.Children[3] as ShowMore; playlistMore = (playlists.Children[0] as StackPanel).Children[2] as ShowMore; - loading.RefreshPage += refresh_Click; + loading.RefreshPage += Refresh_Click; DataTransferManager.GetForCurrentView().DataRequested += new TypedEventHandler(Share); } @@ -71,7 +73,7 @@ namespace FoxTube.Pages { channelId = id; if (Methods.NeedToResponse) - Methods.MainPage.content_Navigated(this, null); + Methods.MainPage.Content_Navigated(this, null); ChannelsResource.ListRequest request = SecretsVault.Service.Channels.List("snippet,statistics,brandingSettings"); request.Id = id; @@ -138,6 +140,12 @@ namespace FoxTube.Pages catch (Exception e) { loading.Error(e.GetType().ToString(), e.Message); + Analytics.TrackEvent("Channel loading error", new Dictionary() + { + { "Exception", e.GetType().ToString() }, + { "Message", e.Message }, + { "Channel ID", channelId } + }); } } @@ -167,6 +175,7 @@ namespace FoxTube.Pages else playlistMore.Visibility = Visibility.Collapsed; + playlistLoaded = true; playlistLoading.Close(); } catch (System.Net.Http.HttpRequestException) @@ -179,13 +188,13 @@ namespace FoxTube.Pages } } - private void content_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void Content_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (content.SelectedIndex == 1 && !playlistLoaded) LoadPlaylist(); } - private async void showMorePlaylists_Click() + private async void ShowMorePlaylists_Click() { playlistRequest.PageToken = playlistToken; SearchListResponse response = await playlistRequest.ExecuteAsync(); @@ -205,7 +214,7 @@ namespace FoxTube.Pages playlistMore.Complete(true); } - private async void videoMore_Clicked() + private async void VideoMore_Clicked() { videoRequest.PageToken = videoToken; SearchListResponse response = await videoRequest.ExecuteAsync(); @@ -225,7 +234,7 @@ namespace FoxTube.Pages videoMore.Complete(true); } - private async void subscribe_Click(object sender, RoutedEventArgs e) + private async void Subscribe_Click(object sender, RoutedEventArgs e) { if(await SecretsVault.ChangeSubscriptionState(channelId)) { @@ -265,12 +274,12 @@ namespace FoxTube.Pages } } - private void refresh_Click(object sender, RoutedEventArgs e) + private void Refresh_Click(object sender, RoutedEventArgs e) { Methods.MainPage.GoToChannel(channelId); } - private async void inBrowser_Click(object sender, RoutedEventArgs e) + private async void InBrowser_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(item.Snippet.CustomUrl)) await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/user/{item.Snippet.CustomUrl}")); @@ -278,7 +287,7 @@ namespace FoxTube.Pages await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/channel/{item.Id}")); } - private void share_Click(object sender, RoutedEventArgs e) + private void Share_Click(object sender, RoutedEventArgs e) { DataTransferManager.ShowShareUI(); } diff --git a/FoxTube/Pages/Downloads.xaml b/FoxTube/Pages/Downloads.xaml index 6a50d3d..e51aca9 100644 --- a/FoxTube/Pages/Downloads.xaml +++ b/FoxTube/Pages/Downloads.xaml @@ -2,10 +2,8 @@ x:Class="FoxTube.Pages.Downloads" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:FoxTube.Pages" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:controls="using:FoxTube.Controls" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> diff --git a/FoxTube/Pages/Downloads.xaml.cs b/FoxTube/Pages/Downloads.xaml.cs index 589b7b6..286f415 100644 --- a/FoxTube/Pages/Downloads.xaml.cs +++ b/FoxTube/Pages/Downloads.xaml.cs @@ -1,24 +1,13 @@ -using FoxTube.Controls; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Storage; -using Windows.Storage.Pickers; +using System; using Windows.System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 - namespace FoxTube.Pages { /// - /// An empty page that can be used on its own or navigated to within a Frame. + /// Downloads page /// public sealed partial class Downloads : Page { diff --git a/FoxTube/Pages/History.xaml b/FoxTube/Pages/History.xaml index 5f274ca..b100b65 100644 --- a/FoxTube/Pages/History.xaml +++ b/FoxTube/Pages/History.xaml @@ -6,7 +6,6 @@ xmlns:local="using:FoxTube.Pages" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:controls="using:FoxTube.Controls" xmlns:foxtube="using:FoxTube" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> diff --git a/FoxTube/Pages/History.xaml.cs b/FoxTube/Pages/History.xaml.cs index 6211a17..0ffb030 100644 --- a/FoxTube/Pages/History.xaml.cs +++ b/FoxTube/Pages/History.xaml.cs @@ -1,16 +1,13 @@ -using FoxTube.Controls; -using System; +using System; using Windows.System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 - namespace FoxTube.Pages { /// - /// An empty page that can be used on its own or navigated to within a Frame. + /// YouTube history page /// public sealed partial class History : Page { @@ -34,7 +31,7 @@ namespace FoxTube.Pages public void Initialize() { loading.Refresh(); - + loading.Close(); } diff --git a/FoxTube/Pages/Home.xaml.cs b/FoxTube/Pages/Home.xaml.cs index 4da57d8..5151cb2 100644 --- a/FoxTube/Pages/Home.xaml.cs +++ b/FoxTube/Pages/Home.xaml.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Generic; -using System.Linq; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3.Data; -using Windows.Storage; using FoxTube.Controls; using FoxTube.Pages; -using System.Globalization; namespace FoxTube { @@ -17,6 +14,7 @@ namespace FoxTube /// public sealed partial class Home : Page { + // TODO: Refactor home page private bool trendLoaded = false; VideoGrid trendGrid; diff --git a/FoxTube/Pages/MainPage.xaml b/FoxTube/Pages/MainPage.xaml index e158186..bdab3c9 100644 --- a/FoxTube/Pages/MainPage.xaml +++ b/FoxTube/Pages/MainPage.xaml @@ -10,7 +10,7 @@ PreviewKeyUp="Page_PreviewKeyUp"> - + @@ -30,7 +30,8 @@ - + + @@ -42,7 +43,7 @@ - + @@ -50,13 +51,13 @@ - - + + - + @@ -64,9 +65,9 @@ - + - + @@ -74,11 +75,11 @@ - + - + diff --git a/FoxTube/Pages/MainPage.xaml.cs b/FoxTube/Pages/MainPage.xaml.cs index e9a59ed..03ce815 100644 --- a/FoxTube/Pages/MainPage.xaml.cs +++ b/FoxTube/Pages/MainPage.xaml.cs @@ -33,9 +33,10 @@ namespace FoxTube /// Main app's layout /// public sealed partial class MainPage : Page - { + { + // TODO: Refactor main page Sender s = Sender.None; - ResourceLoader resources = ResourceLoader.GetForCurrentView("Main"); + readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Main"); public MainPage() { InitializeComponent(); @@ -264,27 +265,27 @@ namespace FoxTube GoToVideo((videoPlaceholder.Content as VideoPage).videoId); } - private async void feedback_Click(object sender, TappedRoutedEventArgs e) + private async void Feedback_Click(object sender, TappedRoutedEventArgs e) { await Launcher.LaunchUriAsync(new Uri("feedback-hub:")); } - private async void createAccount_Click(object sender, RoutedEventArgs e) + private async void CreateAccount_Click(object sender, RoutedEventArgs e) { await Launcher.LaunchUriAsync(new Uri("https://accounts.google.com/signup/v2/webcreateaccount?ManageAccount&flowName=GlifWebSignIn&flowEntry=SignUp")); } - private void signIn_Click(object sender, RoutedEventArgs e) + private void SignIn_Click(object sender, RoutedEventArgs e) { SecretsVault.Authorize(); } - private void myChannel_Click(object sender, RoutedEventArgs e) + private void MyChannel_Click(object sender, RoutedEventArgs e) { GoToChannel(SecretsVault.AccountId); } - private void logout_Click(object sender, RoutedEventArgs e) + private void Logout_Click(object sender, RoutedEventArgs e) { SecretsVault.Deauthenticate(); } @@ -512,13 +513,13 @@ namespace FoxTube nav.IsBackEnabled = false; } - private void search_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) + private void Search_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if(!string.IsNullOrWhiteSpace(search.Text)) GoToSearch(new SearchParameters(search.Text)); } - private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) + private void Search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { if (search.Text.Length > 2 && args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { @@ -541,7 +542,7 @@ namespace FoxTube } } - private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) + private void Nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) { Debug.WriteLine("Menu selection changed"); try @@ -577,7 +578,7 @@ namespace FoxTube catch { } } - public void content_Navigated(object sender, NavigationEventArgs e) + public void Content_Navigated(object sender, NavigationEventArgs e) { Dictionary switchCase = new Dictionary() { @@ -735,7 +736,7 @@ namespace FoxTube MinimizeAsInitializer(); } - private void nav_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) + private void Nav_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) { if (videoPlaceholder.Content != null) { @@ -757,7 +758,7 @@ namespace FoxTube } } - private void openContext(object sender, TappedRoutedEventArgs e) + private void OpenContext(object sender, TappedRoutedEventArgs e) { ((NavigationViewItem)sender).ContextFlyout.ShowAt((NavigationViewItem)sender); } @@ -766,5 +767,10 @@ namespace FoxTube { SecretsVault.GetAdblock(); } + + private void Web_Tapped(object sender, TappedRoutedEventArgs e) + { + content.Navigate(typeof(Browser)); + } } } diff --git a/FoxTube/Pages/PlaylistPage.xaml b/FoxTube/Pages/PlaylistPage.xaml index 6d0f8ac..40c513e 100644 --- a/FoxTube/Pages/PlaylistPage.xaml +++ b/FoxTube/Pages/PlaylistPage.xaml @@ -7,7 +7,6 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:foxtube="using:FoxTube" - xmlns:ui="using:Microsoft.Advertising.WinRT.UI" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> diff --git a/FoxTube/Pages/PlaylistPage.xaml.cs b/FoxTube/Pages/PlaylistPage.xaml.cs index e967267..0bd0d5c 100644 --- a/FoxTube/Pages/PlaylistPage.xaml.cs +++ b/FoxTube/Pages/PlaylistPage.xaml.cs @@ -1,7 +1,9 @@ using FoxTube.Controls; using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3.Data; +using Microsoft.AppCenter.Analytics; using System; +using System.Collections.Generic; using Windows.ApplicationModel.DataTransfer; using Windows.ApplicationModel.Resources; using Windows.Foundation; @@ -50,7 +52,7 @@ namespace FoxTube.Pages { playlistId = id; if (Methods.NeedToResponse) - Methods.MainPage.content_Navigated(this, null); + Methods.MainPage.Content_Navigated(this, null); PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet,contentDetails"); request.Id = id; @@ -98,9 +100,15 @@ namespace FoxTube.Pages { loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); } - catch + catch (Exception e) { - loading.Error(); + loading.Error(e.GetType().ToString(), e.Message); + Analytics.TrackEvent("Playlist loading error", new Dictionary() + { + { "Exception", e.GetType().ToString() }, + { "Message", e.Message }, + { "Playlist ID", playlistId } + }); } } diff --git a/FoxTube/Pages/Search.xaml b/FoxTube/Pages/Search.xaml index 1ba8195..9533e50 100644 --- a/FoxTube/Pages/Search.xaml +++ b/FoxTube/Pages/Search.xaml @@ -19,7 +19,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -64,16 +64,16 @@ -