From ba02a377601e3a176ade0b00129f7068afdbbe2d Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Wed, 1 Aug 2018 19:04:12 +0300 Subject: [PATCH] Settings rebuild --- FoxTube/Controls/DownloadItem.xaml.cs | 50 ++++++------ FoxTube/FoxTube.csproj | 28 ++++--- FoxTube/Pages/General.xaml | 41 ---------- FoxTube/Pages/General.xaml.cs | 79 ------------------ FoxTube/Pages/MainPage.xaml | 25 +++++- FoxTube/Pages/MainPage.xaml.cs | 80 +++++++------------ FoxTube/Pages/PlaylistPage.xaml | 1 + FoxTube/Pages/Settings.xaml | 80 ++----------------- FoxTube/Pages/Settings.xaml.cs | 79 ++++++++++-------- FoxTube/Pages/SettingsPages/About.xaml | 56 +++++++++++++ FoxTube/Pages/SettingsPages/About.xaml.cs | 33 ++++++++ .../Pages/{ => SettingsPages}/Feedback.xaml | 2 +- .../{ => SettingsPages}/Feedback.xaml.cs | 2 +- FoxTube/Pages/{ => SettingsPages}/Inbox.xaml | 2 +- .../Pages/{ => SettingsPages}/Inbox.xaml.cs | 4 +- .../Pages/{ => SettingsPages}/Translate.xaml | 2 +- .../{ => SettingsPages}/Translate.xaml.cs | 2 +- FoxTube/Pages/VideoGrid.xaml | 38 ++++++++- 18 files changed, 276 insertions(+), 328 deletions(-) delete mode 100644 FoxTube/Pages/General.xaml delete mode 100644 FoxTube/Pages/General.xaml.cs create mode 100644 FoxTube/Pages/SettingsPages/About.xaml create mode 100644 FoxTube/Pages/SettingsPages/About.xaml.cs rename FoxTube/Pages/{ => SettingsPages}/Feedback.xaml (98%) rename FoxTube/Pages/{ => SettingsPages}/Feedback.xaml.cs (99%) rename FoxTube/Pages/{ => SettingsPages}/Inbox.xaml (99%) rename FoxTube/Pages/{ => SettingsPages}/Inbox.xaml.cs (98%) rename FoxTube/Pages/{ => SettingsPages}/Translate.xaml (98%) rename FoxTube/Pages/{ => SettingsPages}/Translate.xaml.cs (99%) diff --git a/FoxTube/Controls/DownloadItem.xaml.cs b/FoxTube/Controls/DownloadItem.xaml.cs index 4a431bd..938d14c 100644 --- a/FoxTube/Controls/DownloadItem.xaml.cs +++ b/FoxTube/Controls/DownloadItem.xaml.cs @@ -43,44 +43,42 @@ namespace FoxTube.Controls client.DownloadFileCompleted += DownloadCompleted; client.DownloadProgressChanged += UpdateInfo; + } + async void Download(string id, YouTubeQuality q) + { try { - Download(id, q); + Id = id; + VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("snippet"); + request.Id = id; + var response = (await request.ExecuteAsync()).Items[0]; + + Uri url = (await YouTube.GetVideoUriAsync(id, q)).Uri; + + client.DownloadFileAsync(url, settings.Values["defaultDownload"] as string + $@"\{response.Snippet.Title} - {response.Snippet.ChannelTitle}.mp4"); + + thumbnail.Source = new BitmapImage(new Uri(response.Snippet.Thumbnails.Standard.Url)); + title.Text = response.Snippet.Title; + channel.Text = $"Author: {response.Snippet.ChannelTitle}"; + + quality.Text = $"Quality: {Methods.QualityToString(q)}"; TimeSpan ts = XmlConvert.ToTimeSpan(response.ContentDetails.Duration); + duration.Text = string.Format("Duration: {0}{1:00}:{2:00} | ", ts.Hours == 0 ? "" : ts.Hours + ":", ts.Minutes, ts.Seconds); + + uri = settings.Values["defaultDownload"] as string + $@"\{response.Snippet.Title} - {response.Snippet.ChannelTitle}.mp4"; + + status.Text = "Downloading..."; + perc.Text = "0%"; } catch { if (client.IsBusy) client.CancelAsync(); - new MessageDialog("We were unable to download video due to connection problems or internal YouTube server error. Please, try again later.", "Failed to download").ShowAsync(); + await new MessageDialog("We were unable to download video due to connection problems or internal YouTube server error. Please, try again later.", "Failed to download").ShowAsync(); throw new FileNotFoundException(); } } - async void Download(string id, YouTubeQuality q) - { - Id = id; - VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("snippet"); - request.Id = id; - var response = (await request.ExecuteAsync()).Items[0]; - - Uri url = (await YouTube.GetVideoUriAsync(id, q)).Uri; - - client.DownloadFileAsync(url, settings.Values["defaultDownload"] as string + $@"\{response.Snippet.Title} - {response.Snippet.ChannelTitle}.mp4"); - - thumbnail.Source = new BitmapImage(new Uri(response.Snippet.Thumbnails.Standard.Url)); - title.Text = response.Snippet.Title; - channel.Text = $"Author: {response.Snippet.ChannelTitle}"; - - quality.Text = $"Quality: {Methods.QualityToString(q)}"; TimeSpan ts = XmlConvert.ToTimeSpan(response.ContentDetails.Duration); - duration.Text = string.Format("Duration: {0}{1:00}:{2:00} | ", ts.Hours == 0 ? "" : ts.Hours + ":", ts.Minutes, ts.Seconds); - - uri = settings.Values["defaultDownload"] as string + $@"\{response.Snippet.Title} - {response.Snippet.ChannelTitle}.mp4"; - - status.Text = "Downloading..."; - perc.Text = "0%"; - } - private void UpdateInfo(object sender, DownloadProgressChangedEventArgs e) { progressBar.Value = e.ProgressPercentage; diff --git a/FoxTube/FoxTube.csproj b/FoxTube/FoxTube.csproj index f5fc5c3..082ee53 100644 --- a/FoxTube/FoxTube.csproj +++ b/FoxTube/FoxTube.csproj @@ -130,11 +130,11 @@ Downloads.xaml - - Feedback.xaml + + About.xaml - - General.xaml + + Feedback.xaml History.xaml @@ -142,7 +142,7 @@ Home.xaml - + Inbox.xaml @@ -171,7 +171,7 @@ SubLayer.xaml - + Translate.xaml @@ -318,11 +318,11 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -334,7 +334,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -370,7 +370,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -414,6 +414,9 @@ 1.29.2.1006 + + 10.1805.7001 + 6.1.5 @@ -442,6 +445,11 @@ FoxTube.Background + + + Microsoft Advertising SDK for XAML + + 14.0 diff --git a/FoxTube/Pages/General.xaml b/FoxTube/Pages/General.xaml deleted file mode 100644 index 0c05b62..0000000 --- a/FoxTube/Pages/General.xaml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FoxTube/Pages/General.xaml.cs b/FoxTube/Pages/General.xaml.cs deleted file mode 100644 index 7ec2d44..0000000 --- a/FoxTube/Pages/General.xaml.cs +++ /dev/null @@ -1,79 +0,0 @@ -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.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 General : Page - { - ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; - public General() - { - this.InitializeComponent(); - language.SelectedIndex = (int)settings.Values["language"]; - quality.SelectedIndex = (int)settings.Values["quality"]; - - notifications.IsOn = (bool)settings.Values["notifications"]; - newVideo.IsChecked = (bool)settings.Values["newVideoNotification"]; - messages.IsChecked = (bool)settings.Values["newmessagesNotification"]; - - mobileWarning.IsOn = (bool)settings.Values["moblieWarning"]; - autoplay.IsOn = (bool)settings.Values["videoAutoplay"]; - } - - private void language_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if((int)settings.Values["language"] != language.SelectedIndex) - { - settings.Values["language"] = language.SelectedIndex; - restartNote.Visibility = Visibility.Visible; - } - } - - private void quality_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if ((int)settings.Values["quality"] != quality.SelectedIndex) - settings.Values["quality"] = quality.SelectedIndex; - } - - private void notification_IsEnabledChanged(object sender, RoutedEventArgs e) - { - if (notifications.IsOn) - { - settings.Values["notificaitons"] = true; - - newVideo.IsEnabled = false; - messages.IsEnabled = false; - } - - if ((bool)settings.Values["newVideoNotification"] != newVideo.IsChecked) - settings.Values["newVideoNotification"] = newVideo.IsChecked; - - if ((bool)settings.Values["newmessagesNotification"] != messages.IsChecked) - settings.Values["newmessagesNotification"] = messages.IsChecked; - - if ((bool)settings.Values["moblieWarning"] != mobileWarning.IsOn) - settings.Values["moblieWarning"] = mobileWarning.IsOn; - - if ((bool)settings.Values["videoAutoplay"] != autoplay.IsOn) - settings.Values["videoAutoplay"] = autoplay.IsOn; - } - } -} diff --git a/FoxTube/Pages/MainPage.xaml b/FoxTube/Pages/MainPage.xaml index cae4469..a3a400c 100644 --- a/FoxTube/Pages/MainPage.xaml +++ b/FoxTube/Pages/MainPage.xaml @@ -5,10 +5,25 @@ xmlns:local="using:FoxTube" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:ads="using:Microsoft.Advertising.WinRT.UI" mc:Ignorable="d" SizeChanged="Page_SizeChanged"> + + + + + + + + + + + + + + @@ -24,7 +39,7 @@ - +