Archived
1
0

Development 666(?)

This commit is contained in:
Michael Gordeev
2018-08-29 23:07:02 +03:00
parent 94d59f1dba
commit 866b4ef373
19 changed files with 296 additions and 224 deletions
+2
View File
@@ -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;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 31 KiB

+3 -3
View File
@@ -17,7 +17,7 @@
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Image Name="cover" Source="/Assets/videoThumbSample.png" Stretch="UniformToFill" VerticalAlignment="Center"/>
<Image Name="cover" Source="/Assets/ChannelCoverTemplate.png" Stretch="UniformToFill" VerticalAlignment="Center"/>
<StackPanel Name="liveTag" Margin="5" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" FontWeight="Black"/>
<TextBlock Text="LIVE" VerticalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/>
@@ -45,8 +45,8 @@
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="50" Margin="10" TextAlignment="Center" Padding="0,16,0,0" Foreground="Gray">
<Hyperlink Click="Hyperlink_Click">Log in</Hyperlink> to manage your subscriptions
</TextBlock>
<Grid Visibility="Collapsed" Grid.Row="1" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="Red">
<ToggleButton Click="subscribe_Click" Name="subscribe" HorizontalAlignment="Stretch" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe" Margin="0,0,0,0"/>
<Grid Visibility="Collapsed" Grid.Row="1" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}">
<Button Click="subscribe_Click" Name="subscribe" HorizontalAlignment="Stretch" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe" Margin="0,0,0,0"/>
<ToggleButton Name="notify" Height="50" Width="50" Visibility="Collapsed" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="&#xE7ED;" Foreground="White" Background="Red" HorizontalAlignment="Right"/>
</Grid>
</Grid>
+18 -9
View File
@@ -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";
}
}
}
}
+3 -3
View File
@@ -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)
+2 -2
View File
@@ -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 @@
</StackPanel>
</Grid>
<Grid Grid.Row="1" Name="playPauseArea" Tapped="playPauseArea_Tapped"/>
<Grid Grid.Row="1" Name="playPauseArea" Tapped="playPauseArea_Tapped" DoubleTapped="playPauseArea_DoubleTapped" Background="Black" Opacity=".0001"/>
<Grid Name="touchCentral" Background="#7F000000" Visibility="Collapsed" Grid.Row="1">
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
+4 -3
View File
@@ -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);
}
}
}
+6 -4
View File
@@ -1,4 +1,5 @@
<Page
NavigationCacheMode="Disabled"
x:Class="FoxTube.Pages.ChannelPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -26,8 +27,9 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<PersonPicture Name="avatar" Grid.Column="0" HorizontalAlignment="Left" Margin="10,-40,0,0" ProfilePicture="/Assets/LogoAvatar.png"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="10,0,0,0">
<Ellipse HorizontalAlignment="Left" Margin="10,-40,0,0" Fill="Black" Width="100" Height="100"/>
<PersonPicture Name="avatar" HorizontalAlignment="Left" Margin="10,-40,0,0"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="10,0,0,5">
<TextBlock Name="title" FontWeight="SemiBold" FontSize="22" Text="Channel name"/>
<TextBlock Name="subscribers" Foreground="Gray" Text="1,000,000 subscribers"/>
<TextBlock Name="videosCount" Foreground="Gray" Text="563,000 videos"/>
@@ -36,8 +38,8 @@
<Hyperlink Click="Hyperlink_Click">Log in</Hyperlink> to manage your subscriptions
</TextBlock>
<Grid Visibility="Visible" Grid.Column="2" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="Red">
<ToggleButton Click="subscribe_Click" Name="subscribe" Width="250" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
<Grid Visibility="Visible" Grid.Column="2" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Click="subscribe_Click" Name="subscribe" Width="250" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
</Grid>
</Grid>
<pages:VideoGrid/>
+29 -12
View File
@@ -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";
}
}
}
+1
View File
@@ -1,4 +1,5 @@
<Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Pages.History"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+31 -4
View File
@@ -1,4 +1,5 @@
<Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Home"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -14,11 +15,37 @@
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged"/>
<Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged" SelectedIndex="1">
<PivotItem Header="Recommended" Name="recommended">
<ScrollViewer>
<StackPanel>
<pages:VideoGrid/>
<controls:ShowMore Clicked="RecMore_Clicked"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem Header="Trending" Name="trending">
<ScrollViewer>
<StackPanel>
<pages:VideoGrid/>
<controls:ShowMore Clicked="TrendMore_Clicked"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem Header="Subscriptions" Name="subscriptions">
<ScrollViewer>
<StackPanel>
<pages:VideoGrid/>
<controls:ShowMore Clicked="SubsMore_Clicked"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
</Pivot>
<CommandBar Grid.Row="1">
<AppBarButton Icon="Refresh" Label="Refresh page" Name="refresh" Click="refresh_Click"/>
<AppBarButton Icon="Refresh" Label="Refresh page" Name="refresh" Click="refreshPage"/>
</CommandBar>
<local:LoadingPage Grid.RowSpan="2" Margin="0,50,0,0" Visibility="Visible" RefreshPage="refreshPage"/>
</Grid>
</Page>
+116 -132
View File
@@ -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<string, string> subsTokens = new Dictionary<string, string>();
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<SearchResult> items = new List<SearchResult>();
Dictionary<string, string> pairs = new Dictionary<string, string>();
SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
request.Type = "video";
request.MaxResults = 10;
request.Order = SearchResource.ListRequest.OrderEnum.Date;
foreach (KeyValuePair<string, string> 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<SearchResult> items = new List<SearchResult>();
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);
}
}
}
+1 -3
View File
@@ -107,9 +107,7 @@
<Grid>
<Frame Name="content" Navigated="content_Navigated"/>
<controls:DropShadowPanel Color="Black" BlurRadius="0" ShadowOpacity=".7" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Frame Name="videoPlaceholder"/>
</controls:DropShadowPanel>
<Frame Name="videoPlaceholder"/>
</Grid>
</NavigationView>
+30 -27
View File
@@ -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<string> suggestions = new List<string>();
@@ -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();
+1
View File
@@ -1,4 +1,5 @@
<Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Pages.PlaylistPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+1
View File
@@ -1,4 +1,5 @@
<Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Search"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+6 -8
View File
@@ -67,11 +67,8 @@ namespace FoxTube
break;
case "youtube#channel":
if(channelId != null)
{
ChannelCard cCard = new ChannelCard(result.Id.ChannelId/*, result.Snippet.LiveBroadcastContent*/);
list.Add(cCard);
}
if(channelId == null)
list.Add(new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent));
break;
case "youtube#playlist":
@@ -112,11 +109,12 @@ namespace FoxTube
try
{
Term = term;
request = SecretsVault.Service.Search.List("id");
request = SecretsVault.Service.Search.List("id,snippet");
if (!string.IsNullOrWhiteSpace(channel))
{
channelId = channel;
request.ChannelId = channel;
(type.Items[2] as ComboBoxItem).Visibility = Visibility.Collapsed;
(grid.Children[1] as CommandBar).Visibility = Visibility.Collapsed;
}
request.Q = term;
@@ -172,9 +170,9 @@ namespace FoxTube
{
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);
}
}
+1 -1
View File
@@ -47,7 +47,7 @@
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="5" VerticalAlignment="Center">
<TextBlock Name="channelName" Text="[Channel name]" FontSize="18"/>
<TextBlock Name="subscribers" Text="[subscribers]" Foreground="Gray" Margin="0,0,0,5"/>
<ToggleButton Grid.Column="2" Height="30" Width="200" Background="Red" Foreground="White" FontSize="14" FontWeight="SemiBold" Content="Subscirbe" Name="subscribe"/>
<Button Click="subscribe_Click" Grid.Column="2" Height="30" Width="200" Background="Red" Foreground="White" FontSize="14" FontWeight="SemiBold" Content="Subscirbe" Name="subscribe"/>
</StackPanel>
</StackPanel>
</Button>
+41 -13
View File
@@ -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";
}
}
}
}
}