diff --git a/FoxTube/App.xaml.cs b/FoxTube/App.xaml.cs
index 9cb77e9..8188902 100644
--- a/FoxTube/App.xaml.cs
+++ b/FoxTube/App.xaml.cs
@@ -11,7 +11,9 @@ using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Globalization;
using Windows.Storage;
+using Windows.UI;
using Windows.UI.Core;
+using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
diff --git a/FoxTube/Assets/ChannelCoverTemplate.png b/FoxTube/Assets/ChannelCoverTemplate.png
index 6dead82..61d877a 100644
Binary files a/FoxTube/Assets/ChannelCoverTemplate.png and b/FoxTube/Assets/ChannelCoverTemplate.png differ
diff --git a/FoxTube/Controls/ChannelCard.xaml b/FoxTube/Controls/ChannelCard.xaml
index 4e0abec..7ad27ae 100644
--- a/FoxTube/Controls/ChannelCard.xaml
+++ b/FoxTube/Controls/ChannelCard.xaml
@@ -17,7 +17,7 @@
-
+
@@ -45,8 +45,8 @@
Log in to manage your subscriptions
-
-
+
+
diff --git a/FoxTube/Controls/ChannelCard.xaml.cs b/FoxTube/Controls/ChannelCard.xaml.cs
index 93e6da4..3da8933 100644
--- a/FoxTube/Controls/ChannelCard.xaml.cs
+++ b/FoxTube/Controls/ChannelCard.xaml.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
+using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
@@ -59,16 +60,20 @@ namespace FoxTube.Controls
{
if(s.Snippet.ResourceId.ChannelId == id)
{
- subscribe.IsChecked = true;
+ subscribe.Background = new SolidColorBrush(Colors.Transparent);
+ subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed";
}
}
subscriptionPane.Visibility = Visibility.Visible;
}
+ try { avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url)); }
+ catch { }
try
{
- avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
+ if (item.BrandingSettings.Image.BannerImageUrl.Contains("default"))
+ throw new Exception("Default channel cover detected");
cover.Source = new BitmapImage(new Uri(item.BrandingSettings.Image.BannerTvLowImageUrl));
}
catch { }
@@ -86,19 +91,23 @@ namespace FoxTube.Controls
private async void subscribe_Click(object sender, RoutedEventArgs e)
{
- if (subscribe.IsChecked.Value)
+ if (subscribe.Background == new SolidColorBrush(Colors.Red))
{
- if (!await SecretsVault.Subscribe(channelId))
- subscribe.IsChecked = false;
- else
+ if (await SecretsVault.Subscribe(channelId))
+ {
+ subscribe.Background = new SolidColorBrush(Colors.Transparent);
+ subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed";
+ }
}
else
{
- if (!await SecretsVault.Unsubscibe(channelId))
- subscribe.IsChecked = true;
- else
+ if (await SecretsVault.Unsubscibe(channelId))
+ {
+ subscribe.Background = new SolidColorBrush(Colors.Red);
+ subscribe.Foreground = new SolidColorBrush(Colors.White);
subscribe.Content = "Subscribe";
+ }
}
}
}
diff --git a/FoxTube/Controls/CommentCard.xaml.cs b/FoxTube/Controls/CommentCard.xaml.cs
index 00e8660..8affa9c 100644
--- a/FoxTube/Controls/CommentCard.xaml.cs
+++ b/FoxTube/Controls/CommentCard.xaml.cs
@@ -82,7 +82,7 @@ namespace FoxTube.Controls
else
more.Visibility = Visibility.Collapsed;
- foreach (Comment c in response.Items)
+ foreach (Comment c in response.Items.Reverse())
replies.Children.Add(new CommentCard(c));
}
}
@@ -111,7 +111,7 @@ namespace FoxTube.Controls
rating.Text = comment.Snippet.LikeCount.HasValue ? comment.Snippet.LikeCount.ToString() : "";
meta.Text = string.Format("{0} | {1} {2}", comment.Snippet.AuthorDisplayName, Methods.GetAgo(comment.Snippet.PublishedAt.Value), comment.Snippet.UpdatedAt.Value != comment.Snippet.PublishedAt.Value ? "(edited)" : "");
- text.Text = comment.Snippet.TextDisplay;
+ Methods.FormatText(ref text, comment.Snippet.TextDisplay);
try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.AuthorProfileImageUrl)); }
catch { }
@@ -147,7 +147,7 @@ namespace FoxTube.Controls
request.TextFormat = CommentsResource.ListRequest.TextFormatEnum.PlainText;
var response = await request.ExecuteAsync();
- foreach (Comment c in response.Items)
+ foreach (Comment c in response.Items.Reverse())
replies.Children.Add(new CommentCard(c));
if (response.NextPageToken != null)
diff --git a/FoxTube/Controls/VideoPlayer.xaml b/FoxTube/Controls/VideoPlayer.xaml
index d3dbe8e..0269e3d 100644
--- a/FoxTube/Controls/VideoPlayer.xaml
+++ b/FoxTube/Controls/VideoPlayer.xaml
@@ -9,7 +9,7 @@
mc:Ignorable="d"
d:DesignHeight="1080"
d:DesignWidth="1920"
- DoubleTapped="UserControl_DoubleTapped"
+ RequestedTheme="Dark"
PointerMoved="UserControl_PointerMoved"
PointerExited="UserControl_PointerExited"
PointerEntered="UserControl_PointerEntered">
@@ -41,7 +41,7 @@
-
+
diff --git a/FoxTube/Controls/VideoPlayer.xaml.cs b/FoxTube/Controls/VideoPlayer.xaml.cs
index 5201a8f..c9e7829 100644
--- a/FoxTube/Controls/VideoPlayer.xaml.cs
+++ b/FoxTube/Controls/VideoPlayer.xaml.cs
@@ -40,7 +40,7 @@ namespace FoxTube
{
public string videoId;
- private bool miniView = false;
+ public bool miniView = false;
private bool fullScreen = false;
public bool pointerCaptured = false;
@@ -783,7 +783,7 @@ namespace FoxTube
await connection.RequestStartCastingAsync(videoSource.GetAsCastingSource());
}
- private void UserControl_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
+ private void playPauseArea_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
if (miniView && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay)
miniView_Click(this, null);
@@ -797,7 +797,8 @@ namespace FoxTube
private void playPauseArea_Tapped(object sender, TappedRoutedEventArgs e)
{
- if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse) ;
+ if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse && !miniView)
+ play_Click(this, null);
}
}
}
diff --git a/FoxTube/Pages/ChannelPage.xaml b/FoxTube/Pages/ChannelPage.xaml
index 0736e93..69c3592 100644
--- a/FoxTube/Pages/ChannelPage.xaml
+++ b/FoxTube/Pages/ChannelPage.xaml
@@ -1,4 +1,5 @@
-
-
+
+
+
@@ -36,8 +38,8 @@
Log in to manage your subscriptions
-
-
+
+
diff --git a/FoxTube/Pages/ChannelPage.xaml.cs b/FoxTube/Pages/ChannelPage.xaml.cs
index f28cb81..20c240e 100644
--- a/FoxTube/Pages/ChannelPage.xaml.cs
+++ b/FoxTube/Pages/ChannelPage.xaml.cs
@@ -25,6 +25,8 @@ using Windows.ApplicationModel.DataTransfer;
using Windows.ApplicationModel;
using Windows.Storage.Streams;
using Windows.System;
+using Windows.UI;
+using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -97,10 +99,13 @@ namespace FoxTube.Pages
try
{
+ if (item.BrandingSettings.Image.BannerImageUrl.Contains("default"))
+ throw new Exception("Default channel cover detected");
channelCover.Source = new BitmapImage(new Uri(item.BrandingSettings.Image.BannerImageUrl));
- avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
}
catch { }
+ try { avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url)); }
+ catch { }
Methods.FormatText(ref description, item.Snippet.Description);
views.Text = $"{item.Statistics.ViewCount:0,0}";
@@ -128,14 +133,22 @@ namespace FoxTube.Pages
if (SecretsVault.IsAuthorized)
{
+ SecretsVault.Subscriptions.ForEach(x => Debug.WriteLine($"{x.Snippet.Title}: {x.Snippet.ResourceId.ChannelId}"));
+ Debug.WriteLine($"Current channel ID: {item.Id}");
+ bool b = false;
foreach (Subscription s in SecretsVault.Subscriptions)
{
- if (s.Snippet.ResourceId.ChannelId == id)
+ if (s.Snippet.ResourceId.ChannelId == item.Id)
{
- subscribe.IsChecked = true;
+ Debug.WriteLine($"{s.Snippet.ResourceId.ChannelId} ({item.Snippet.Title}: {item.Id})");
+ subscribe.Background = new SolidColorBrush(Colors.Transparent);
+ subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed";
+ b = true;
+ break;
}
}
+ Debug.WriteLine($"Channel was found: {b}");
subscriptionPane.Visibility = Visibility.Visible;
}
@@ -145,9 +158,9 @@ 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);
}
}
@@ -236,19 +249,23 @@ namespace FoxTube.Pages
private async void subscribe_Click(object sender, RoutedEventArgs e)
{
- if (subscribe.IsChecked.Value)
+ if (subscribe.Background == new SolidColorBrush(Colors.Red))
{
- if (!await SecretsVault.Subscribe(channelId))
- subscribe.IsChecked = false;
- else
+ if (await SecretsVault.Subscribe(channelId))
+ {
+ subscribe.Background = new SolidColorBrush(Colors.Transparent);
+ subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed";
+ }
}
else
{
- if (!await SecretsVault.Unsubscibe(channelId))
- subscribe.IsChecked = true;
- else
+ if (await SecretsVault.Unsubscibe(channelId))
+ {
+ subscribe.Background = new SolidColorBrush(Colors.Red);
+ subscribe.Foreground = new SolidColorBrush(Colors.White);
subscribe.Content = "Subscribe";
+ }
}
}
diff --git a/FoxTube/Pages/History.xaml b/FoxTube/Pages/History.xaml
index 4931d08..5adfa85 100644
--- a/FoxTube/Pages/History.xaml
+++ b/FoxTube/Pages/History.xaml
@@ -1,4 +1,5 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
diff --git a/FoxTube/Pages/Home.xaml.cs b/FoxTube/Pages/Home.xaml.cs
index 45bd264..64b99d5 100644
--- a/FoxTube/Pages/Home.xaml.cs
+++ b/FoxTube/Pages/Home.xaml.cs
@@ -20,6 +20,8 @@ using Windows.Storage;
using Windows.UI.Text;
using FoxTube.Controls;
using FoxTube.Pages;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -34,11 +36,12 @@ namespace FoxTube
private bool trendLoaded = false;
private bool subsLoaded = false;
- VideoGrid recGrid = new VideoGrid(), trendGrid = new VideoGrid(), subsGrid = new VideoGrid();
- ShowMore recMore = new ShowMore(), trendMore = new ShowMore(), subsMore = new ShowMore();
- LoadingPage recLoading = new LoadingPage(), trendLoading = new LoadingPage(), subsLoading = new LoadingPage();
+ VideoGrid recGrid, trendGrid, subsGrid;
+ ShowMore recMore, trendMore, subsMore;
+ LoadingPage loading;
- string trendToken, recToken, subsToken;
+ string trendToken, recToken;
+ Dictionary subsTokens = new Dictionary();
string reg;
public Home()
@@ -46,27 +49,29 @@ namespace FoxTube
this.InitializeComponent();
try
{
- reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper().Remove(0, 3);
+ reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToLower().Remove(0, 3);
}
catch (ArgumentOutOfRangeException)
{
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper();
}
- recMore.Clicked += RecMore_Clicked;
- trendMore.Clicked += TrendMore_Clicked;
- subsMore.Clicked += SubsMore_Clicked;
+ recGrid = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
+ trendGrid = ((trending.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
+ subsGrid = ((subscriptions.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
- recLoading.RefreshPage += refreshPage;
- subsLoading.RefreshPage += refreshPage;
- trendLoading.RefreshPage += refreshPage;
+ recMore = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
+ trendMore = ((trending.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore; ;
+ subsMore = ((subscriptions.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
+
+ loading = grid.Children[2] as LoadingPage;
Initialize();
}
private void refreshPage(object sender, RoutedEventArgs e)
{
- Initialize();
+ (Parent as Frame).Navigate(typeof(Home));
}
private void RecMore_Clicked()
@@ -76,137 +81,102 @@ namespace FoxTube
private async void TrendMore_Clicked()
{
- VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
- request.MaxResults = 48;
- request.PageToken = trendToken;
-
- request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
- request.RegionCode = reg;
- VideoListResponse response = await request.ExecuteAsync();
-
- if (!string.IsNullOrWhiteSpace(response.NextPageToken))
- trendToken = response.NextPageToken;
- else
- trendMore.Complete(true);
-
- foreach (Video vid in response.Items)
+ try
{
- VideoCard vCard = new VideoCard(vid.Id);
- recGrid.Add(vCard);
+ VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
+ request.MaxResults = 48;
+ request.PageToken = trendToken;
+
+ request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
+ request.RegionCode = reg;
+ VideoListResponse response = await request.ExecuteAsync();
+
+ if (!string.IsNullOrWhiteSpace(response.NextPageToken))
+ trendToken = response.NextPageToken;
+ else
+ trendMore.Complete(true);
+
+ foreach (Video vid in response.Items)
+ {
+ VideoCard vCard = new VideoCard(vid.Id);
+ recGrid.Add(vCard);
+ }
+ trendMore.Complete();
+ }
+ catch
+ {
+ trendMore.Complete(true);
}
- trendMore.Complete();
}
- private void SubsMore_Clicked()
+ private async void SubsMore_Clicked()
{
+ try
+ {
+ List items = new List();
+ Dictionary pairs = new Dictionary();
+ SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
+ request.Type = "video";
+ request.MaxResults = 10;
+ request.Order = SearchResource.ListRequest.OrderEnum.Date;
+ foreach (KeyValuePair i in subsTokens)
+ {
+ request.ChannelId = i.Key;
+ request.PageToken = i.Value;
+ SearchListResponse response = await request.ExecuteAsync();
+ foreach (SearchResult result in response.Items)
+ items.Add(result);
+ if (response.NextPageToken != null)
+ pairs.Add(i.Value, response.NextPageToken);
+ }
+ if (pairs.Count == 0)
+ subsMore.Complete(true);
+ else
+ subsTokens = pairs;
+
+ items = items.OrderByDescending(x => x.Snippet.PublishedAt).ToList();
+
+ foreach (SearchResult i in items)
+ subsGrid.Add(new VideoCard(i.Id.VideoId));
+
+ subsMore.Complete();
+ }
+ catch
+ {
+ subsMore.Complete(true);
+ }
}
public void Initialize()
{
- GC.Collect();
- pivot.Items.Clear();
-
if(SecretsVault.IsAuthorized)
- {
- //Initializing recommended tab
- StackPanel rs = new StackPanel();
- rs.Children.Add(recGrid);
- rs.Children.Add(recMore);
- Grid rg = new Grid();
- rg.Children.Add(new ScrollViewer() { Content = rs });
- rg.Children.Add(recLoading);
-
- pivot.Items.Add(new PivotItem()
- {
- Content = rg,
- Header = "Recommended"
- });
-
- //Initializing trending tab
- StackPanel ts = new StackPanel();
- ts.Children.Add(trendGrid);
- ts.Children.Add(trendMore);
- Grid tg = new Grid();
- tg.Children.Add(new ScrollViewer() { Content = ts });
- tg.Children.Add(trendLoading);
-
- pivot.Items.Add(new PivotItem()
- {
- Content = tg,
- Header = "Trending"
- });
-
- //Initializing subscriptions tab
- StackPanel s = new StackPanel();
- s.Children.Add(subsGrid);
- s.Children.Add(subsMore);
- Grid g = new Grid();
- g.Children.Add(new ScrollViewer() { Content = s });
- g.Children.Add(subsLoading);
-
- pivot.Items.Add(new PivotItem()
- {
- Content = g,
- Header = "Subscriptions"
- });
-
LoadRecommendations();
- }
else
{
- StackPanel ts = new StackPanel();
- ts.Children.Add(trendGrid);
- ts.Children.Add(trendMore);
- Grid tg = new Grid();
- tg.Children.Add(new ScrollViewer() { Content = ts });
- tg.Children.Add(trendLoading);
-
- pivot.Items.Add(new PivotItem()
- {
- Content = tg
- });
+ pivot.Items.Remove(recommended);
+ pivot.Items.Remove(subscriptions);
LoadTrending();
}
}
- private void refresh_Click(object sender, RoutedEventArgs e)
- {
- Initialize();
- }
-
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- switch(pivot.SelectedIndex)
- {
- case 2:
- if (!subsLoaded)
- LoadSubscriptions();
- break;
- case 1:
- if (!trendLoaded)
- LoadTrending();
- break;
- case 0:
- if (pivot.Items.Count > 1)
- {
- if (!recLoaded)
- LoadRecommendations();
- }
- else
- {
- if (!trendLoaded)
- LoadTrending();
- }
- break;
- }
+ loading.Close();
+ if (pivot.SelectedItem == recommended && !recLoaded)
+ LoadRecommendations();
+ else if (pivot.SelectedItem == trending && !trendLoaded)
+ LoadTrending();
+ else if (pivot.SelectedItem == subscriptions && !subsLoaded)
+ LoadSubscriptions();
}
async void LoadTrending()
{
try
{
+ loading.Refresh();
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
request.MaxResults = 48;
@@ -225,16 +195,18 @@ namespace FoxTube
trendGrid.Add(vCard);
}
- trendLoading.Close();
+ loading.Close();
trendLoaded = true;
}
catch (System.Net.Http.HttpRequestException)
{
- trendLoading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
+ trendLoaded = false;
+ loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
}
- catch
+ catch(Exception e)
{
- trendLoading.Error();
+ trendLoaded = false;
+ loading.Error(e.GetType().ToString(), e.Message);
}
}
@@ -242,17 +214,22 @@ namespace FoxTube
{
try
{
- recLoading.Close();
+ loading.Refresh();
+
+ throw new NotImplementedException();
+
+ loading.Close();
recLoaded = true;
- recLoading.Block();
}
catch (System.Net.Http.HttpRequestException)
{
- recLoading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
+ recLoaded = false;
+ loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
}
- catch
+ catch (Exception e)
{
- recLoading.Error();
+ recLoaded = false;
+ loading.Error(e.GetType().ToString(), e.Message);
}
}
@@ -260,10 +237,11 @@ namespace FoxTube
{
try
{
+ loading.Refresh();
List items = new List();
SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
request.Type = "video";
- request.MaxResults = 20;
+ request.MaxResults = 10;
request.Order = SearchResource.ListRequest.OrderEnum.Date;
foreach (Subscription i in SecretsVault.Subscriptions)
@@ -272,23 +250,29 @@ namespace FoxTube
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult result in response.Items)
items.Add(result);
+ if (response.NextPageToken != null)
+ subsTokens.Add(i.Snippet.ResourceId.ChannelId, response.NextPageToken);
}
- subsMore.Complete(true);
-
- items.OrderBy(x => x.Snippet.PublishedAt.Value);
+ if (subsTokens.Count == 0)
+ subsMore.Complete(true);
+
+ items = items.OrderByDescending(x => x.Snippet.PublishedAt).ToList();
foreach (SearchResult i in items)
subsGrid.Add(new VideoCard(i.Id.VideoId));
- subsLoading.Close();
+ loading.Close();
+ subsLoaded = true;
}
catch (System.Net.Http.HttpRequestException)
{
- subsLoading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
+ subsLoaded = false;
+ loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
}
catch (Exception e)
{
- subsLoading.Error(e.ToString(), e.Message);
+ subsLoaded = false;
+ loading.Error(e.GetType().ToString(), e.Message);
}
}
}
diff --git a/FoxTube/Pages/MainPage.xaml b/FoxTube/Pages/MainPage.xaml
index 8cf4eff..1cec469 100644
--- a/FoxTube/Pages/MainPage.xaml
+++ b/FoxTube/Pages/MainPage.xaml
@@ -107,9 +107,7 @@
-
-
-
+
diff --git a/FoxTube/Pages/MainPage.xaml.cs b/FoxTube/Pages/MainPage.xaml.cs
index e84c814..64eb096 100644
--- a/FoxTube/Pages/MainPage.xaml.cs
+++ b/FoxTube/Pages/MainPage.xaml.cs
@@ -133,6 +133,7 @@ namespace FoxTube
SecretsVault.AuthorizationStateChanged += Vault_AuthorizationStateChanged;
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
+ SetTitleBar();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
@@ -150,10 +151,21 @@ namespace FoxTube
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
- if (RequestedTheme == ElementTheme.Dark)
- titleBar.ButtonForegroundColor = Colors.White;
- else if(RequestedTheme == ElementTheme.Light)
- titleBar.ButtonForegroundColor = Colors.Black;
+ if((int)settings.Values["themeMode"] == 2)
+ {
+ Color uiTheme = new UISettings().GetColorValue(UIColorType.Background);
+ if (uiTheme == Colors.Black)
+ titleBar.ButtonForegroundColor = Colors.White;
+ else
+ titleBar.ButtonForegroundColor = Colors.Black;
+ }
+ else
+ {
+ if (RequestedTheme == ElementTheme.Dark)
+ titleBar.ButtonForegroundColor = Colors.White;
+ else if (RequestedTheme == ElementTheme.Light)
+ titleBar.ButtonForegroundColor = Colors.Black;
+ }
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
@@ -348,14 +360,11 @@ namespace FoxTube
public void MinimizeVideo()
{
- DropShadowPanel ph = videoPlaceholder.Parent as DropShadowPanel;
-
- ph.BlurRadius = 20;
- ph.Width = 432;
- ph.Height = 243;
- ph.VerticalAlignment = VerticalAlignment.Bottom;
- ph.HorizontalAlignment = HorizontalAlignment.Right;
- ph.Margin = new Thickness(0, 0, 25, 50);
+ videoPlaceholder.Width = 432;
+ videoPlaceholder.Height = 243;
+ videoPlaceholder.VerticalAlignment = VerticalAlignment.Bottom;
+ videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Right;
+ videoPlaceholder.Margin = new Thickness(0, 0, 25, 50);
if (content.CanGoBack)
nav.IsBackEnabled = true;
@@ -365,14 +374,11 @@ namespace FoxTube
public void MaximizeVideo()
{
- DropShadowPanel ph = videoPlaceholder.Parent as DropShadowPanel;
-
- ph.BlurRadius = 0;
- ph.Width = double.NaN;
- ph.Height = double.NaN;
- ph.VerticalAlignment = VerticalAlignment.Stretch;
- ph.HorizontalAlignment = HorizontalAlignment.Stretch;
- ph.Margin = new Thickness(0);
+ videoPlaceholder.Width = double.NaN;
+ videoPlaceholder.Height = double.NaN;
+ videoPlaceholder.VerticalAlignment = VerticalAlignment.Stretch;
+ videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch;
+ videoPlaceholder.Margin = new Thickness(0);
nav.IsBackEnabled = true;
}
@@ -383,7 +389,7 @@ namespace FoxTube
{
nav.OpenPaneLength = 0;
nav.CompactPaneLength = 0;
- if (nav.DisplayMode == NavigationViewDisplayMode.Minimal)
+ if ((videoPlaceholder.Content as VideoPage).player.miniView)
nav.Margin = new Thickness(0, -80, 0, 0);
else
nav.Margin = new Thickness(0, -91, 0, 0);
@@ -425,8 +431,7 @@ namespace FoxTube
try
{
XmlDocument doc = new XmlDocument();
- string reg = (settings.Values["region"] as string).Length > 2 ? (settings.Values["region"] as string).Remove(2) : (settings.Values["region"] as string);
- doc.Load($"http://suggestqueries.google.com/complete/search?ds=yt&output=toolbar&hl={reg}&q={WebUtility.UrlEncode(search.Text)}");
+ doc.Load($"http://suggestqueries.google.com/complete/search?ds=yt&client=toolbar&q={search.Text}");
List suggestions = new List();
@@ -611,7 +616,7 @@ namespace FoxTube
else
nav.ExpandedModeThresholdWidth = int.MaxValue;
- if (videoPlaceholder.Content != null && (videoPlaceholder.Parent as DropShadowPanel).HorizontalAlignment == HorizontalAlignment.Stretch)
+ if (videoPlaceholder.Content != null && videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer();
}
@@ -624,11 +629,9 @@ namespace FoxTube
{
if (videoPlaceholder.Content != null)
{
- DropShadowPanel panel = videoPlaceholder.Parent as DropShadowPanel;
-
if ((videoPlaceholder.Content as VideoPage).loading.State != LoadingState.Loaded)
CloseVideo();
- else if (panel.HorizontalAlignment == HorizontalAlignment.Stretch)
+ else if (videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer();
else
content.GoBack();
diff --git a/FoxTube/Pages/PlaylistPage.xaml b/FoxTube/Pages/PlaylistPage.xaml
index 22929f5..bfe14a4 100644
--- a/FoxTube/Pages/PlaylistPage.xaml
+++ b/FoxTube/Pages/PlaylistPage.xaml
@@ -1,4 +1,5 @@
-
+
diff --git a/FoxTube/Pages/VideoPage.xaml.cs b/FoxTube/Pages/VideoPage.xaml.cs
index ae91db1..80971e9 100644
--- a/FoxTube/Pages/VideoPage.xaml.cs
+++ b/FoxTube/Pages/VideoPage.xaml.cs
@@ -162,7 +162,7 @@ namespace FoxTube.Pages
foreach (PlaylistItem i in listResponse.Items)
{
- items.Add(new VideoPlaylistItem(i.Snippet.Thumbnails.Medium.Url, i.Snippet.Title, i.ContentDetails.VideoId));
+ items.Add(new VideoPlaylistItem(i.Snippet.Thumbnails.Medium.Url, i.Snippet.Title, i.Snippet.ResourceId.VideoId));
if (items.Last().Id == videoId)
selection = items.Last();
}
@@ -177,6 +177,7 @@ namespace FoxTube.Pages
playlistList.ItemsSource = items;
playlistList.SelectedItem = selection;
+ pivot.SelectedItem = playlist;
}
else
pivot.Items.Remove(playlist);
@@ -220,7 +221,8 @@ namespace FoxTube.Pages
{
if (s.Snippet.ResourceId.ChannelId == item.Snippet.ChannelId)
{
- subscribe.IsChecked = true;
+ subscribe.Background = new SolidColorBrush(Colors.Transparent);
+ subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed";
}
}
@@ -248,7 +250,7 @@ namespace FoxTube.Pages
}
catch (Exception e)
{
- loading.Error(e.HResult.ToString(), e.Message);
+ loading.Error(e.GetType().ToString(), e.Message);
}
}
@@ -444,10 +446,10 @@ namespace FoxTube.Pages
{
case Rating.Like:
like.Foreground = new SolidColorBrush(Colors.Gray);
- likes.Text = (Convert.ToInt32(likes.Text) - 1).ToString();
+ likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
dislike.Foreground = new SolidColorBrush(Colors.Red);
- dislikes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString();
+ dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
@@ -456,7 +458,7 @@ namespace FoxTube.Pages
case Rating.None:
dislike.Foreground = new SolidColorBrush(Colors.Red);
- dislikes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString();
+ dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
@@ -465,7 +467,7 @@ namespace FoxTube.Pages
case Rating.Dislike:
dislike.Foreground = new SolidColorBrush(Colors.Gray);
- dislikes.Text = (Convert.ToInt32(dislikes.Text) - 1).ToString();
+ dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
break;
@@ -479,10 +481,10 @@ namespace FoxTube.Pages
{
case Rating.Dislike:
dislike.Foreground = new SolidColorBrush(Colors.Gray);
- dislikes.Text = (Convert.ToInt32(dislikes.Text) - 1).ToString();
+ dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
like.Foreground = new SolidColorBrush(Colors.Green);
- likes.Text = (Convert.ToInt32(likes.Text) + 1).ToString();
+ likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync();
@@ -491,7 +493,7 @@ namespace FoxTube.Pages
case Rating.None:
like.Foreground = new SolidColorBrush(Colors.Green);
- likes.Text = (Convert.ToInt32(likes.Text) + 1).ToString();
+ likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync();
@@ -500,7 +502,7 @@ namespace FoxTube.Pages
case Rating.Like:
like.Foreground = new SolidColorBrush(Colors.Gray);
- likes.Text = (Convert.ToInt32(likes.Text) - 1).ToString();
+ likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
break;
@@ -509,8 +511,34 @@ namespace FoxTube.Pages
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- if ((e.AddedItems[0] as VideoPlaylistItem).Id != videoId)
- Methods.MainPage.GoToVideo((e.AddedItems[0] as VideoPlaylistItem).Id, playlistId);
+ try
+ {
+ if ((e.AddedItems[0] as VideoPlaylistItem).Id != videoId)
+ Methods.MainPage.GoToVideo((e.AddedItems[0] as VideoPlaylistItem).Id, playlistId);
+ }
+ catch { }
+ }
+
+ private async void subscribe_Click(object sender, RoutedEventArgs e)
+ {
+ if (subscribe.Background == new SolidColorBrush(Colors.Red))
+ {
+ if (await SecretsVault.Subscribe(item.Snippet.ChannelId))
+ {
+ subscribe.Background = new SolidColorBrush(Colors.Transparent);
+ subscribe.Foreground = new SolidColorBrush(Colors.Gray);
+ subscribe.Content = "Subscribed";
+ }
+ }
+ else
+ {
+ if (await SecretsVault.Unsubscibe(item.Snippet.ChannelId))
+ {
+ subscribe.Background = new SolidColorBrush(Colors.Red);
+ subscribe.Foreground = new SolidColorBrush(Colors.White);
+ subscribe.Content = "Subscribe";
+ }
+ }
}
}
}