Archived
1
0

Development 7

This commit is contained in:
Michael Gordeev
2018-07-22 15:00:47 +03:00
parent 57c90f4037
commit 0338d8a626
24 changed files with 727 additions and 359 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ namespace FoxTube.Background
{ {
public static event NotificationHandler NotificationRecieved; public static event NotificationHandler NotificationRecieved;
public List<Notification> Notifications = new List<Notification>(); List<Notification> Notifications = new List<Notification>();
private DateTime lastCheck = DateTime.Now; private DateTime lastCheck = DateTime.Now;
private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
@@ -124,7 +124,7 @@ namespace FoxTube.Background
doc["posts"].FirstChild["content"].InnerText, doc["posts"].FirstChild["content"].InnerText,
XmlConvert.ToDateTime((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), XmlConvert.ToDateTime((doc["posts"].FirstChild as XmlElement).GetAttribute("time"),
XmlDateTimeSerializationMode.Unspecified), XmlDateTimeSerializationMode.Unspecified),
(doc["posts"].FirstChild as XmlElement).GetAttribute("image"))); (doc["posts"].FirstChild as XmlElement).GetAttribute("image"), null));
return doc.InnerXml; return doc.InnerXml;
} }
+5 -5
View File
@@ -18,25 +18,25 @@ namespace FoxTube.Background
Video, Comment, Post, Internal Video, Comment, Post, Internal
} }
public class Notification public sealed class Notification
{ {
public string Channel { get; set; } public string Channel { get; set; }
public string Content { get; set; } public string Content { get; set; }
public DateTime TimeStamp { get; set; } public DateTimeOffset TimeStamp { get; set; }
public NotificationType Type { get; set; } public NotificationType Type { get; set; }
public string Avatar { get; set; } public string Avatar { get; set; }
public string Thumbnail { get; set; } public string Thumbnail { get; set; }
public string Id { get; set; } public string Id { get; set; }
public Notification(string type, string id, public Notification(string type, string id,
string channelName, string content, DateTime date, string channelName, string content, DateTimeOffset date,
string thumbnailUrl, string avatarUrl = "ms-appx:///Assets/Icons/Profile.png") string thumbnailUrl, string avatarUrl)
{ {
Channel = channelName; Channel = channelName;
Content = content; Content = content;
TimeStamp = date; TimeStamp = date;
Type = TypeConversion(type); Type = TypeConversion(type);
Avatar = avatarUrl; Avatar = avatarUrl == null? "ms-appx:///Assets/Icons/Profile.png" : avatarUrl;
Thumbnail = thumbnailUrl; Thumbnail = thumbnailUrl;
} }
+10 -1
View File
@@ -38,11 +38,20 @@ namespace FoxTube
ApplicationName = "FoxTube" ApplicationName = "FoxTube"
}); });
public static YouTubeService Service => new YouTubeService(new BaseClientService.Initializer() public static YouTubeService Service
{
get
{
if (IsAuthorized)
return new YouTubeService(new BaseClientService.Initializer()
{ {
HttpClientInitializer = Vault.Credential, HttpClientInitializer = Vault.Credential,
ApplicationName = "FoxTube" ApplicationName = "FoxTube"
}); });
else
return NoAuthService;
}
}
#endregion #endregion
#region Object containers #region Object containers
+31 -22
View File
@@ -1,36 +1,45 @@
<UserControl <UserControl
x:Class="FoxTube.ChannelCard" x:Class="FoxTube.Controls.ChannelCard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Height="150"> VerticalAlignment="Top"
SizeChanged="UserControl_SizeChanged"
d:DesignHeight="290"
d:DesignWidth="384">
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2" VerticalAlignment="Stretch" Click="Button_Click"> <Button Padding="0" Background="Transparent" Click="Button_Click" VerticalContentAlignment="Stretch" VerticalAlignment="Stretch">
<Grid Background="WhiteSmoke" BorderBrush="LightGray" BorderThickness="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image Name="thumbnail" Source="/Assets/ChannelCoverTemplate.png" Stretch="Fill"/>
<StackPanel Name="liveTag" Margin="5" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3" Orientation="Horizontal" Visibility="Visible">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" FontWeight="Black"/>
<TextBlock Name="liveContent" Text="LIVE" VerticalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/>
</StackPanel>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="125"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<PersonPicture Name="avatar" Width="125"/> <Ellipse Grid.Column="0" Height="80" Width="80" Margin="0,-45,0,0" VerticalAlignment="Bottom" Fill="WhiteSmoke"/>
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center"> <PersonPicture Name="avatar" Grid.Column="0" Height="74" Margin="3,-45,3,3" VerticalAlignment="Bottom" BorderBrush="White" BorderThickness="10"/>
<StackPanel Orientation="Horizontal">
<TextBlock Name="channelName" Text="IGP" FontSize="18"/> <TextBlock Name="channelName" Grid.Column="1" Text="Markiplier"/>
<StackPanel Name="liveTag" Margin="5,0,0,0" BorderBrush="Red" BorderThickness="2" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed"> <TextBlock Grid.Column="1" Name="views" Text="[Views]" HorizontalAlignment="Right" Foreground="Gray" Margin="0,2,2,0" FontSize="12"/>
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/> </Grid>
<TextBlock Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontWeight="Bold"/> <TextBlock Grid.Row="1" Name="title" Text="[Title]" TextWrapping="WrapWholeWords" Margin="5" MaxLines="2" Foreground="Gray"/>
</StackPanel> </Grid>
</StackPanel>
<TextBlock Name="subscribers" Text="120,452 subscribers" Foreground="Gray"/>
<TextBlock Name="videoCount" Foreground="Gray" Text="563,000 videos"/>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" Name="subscriptionPane">
<ToggleButton Grid.Column="2" Height="40" Width="200" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
<ToggleButton Grid.Column="3" Height="40" Width="40" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
</StackPanel>
</StackPanel>
</Grid> </Grid>
</Button> </Button>
</UserControl> </UserControl>
+2 -40
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime; using System.Runtime.InteropServices.WindowsRuntime;
@@ -12,54 +11,17 @@ using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace FoxTube namespace FoxTube.Controls
{ {
public sealed partial class ChannelCard : UserControl public sealed partial class ChannelCard : UserControl
{ {
string channelId; public ChannelCard()
public ChannelCard(string id, string live)
{ {
this.InitializeComponent(); this.InitializeComponent();
Initialize(id, live);
}
public async void Initialize(string id, string live)
{
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
ApplicationName = this.GetType().ToString()
});
ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics");
request.Id = id;
ChannelListResponse response = await request.ExecuteAsync();
var item = response.Items[0];
channelId = id;
channelName.Text = item.Snippet.Title;
subscribers.Text = string.Format("{0} subscribers", item.Statistics.SubscriberCount);
videoCount.Text = string.Format("{0} videos", item.Statistics.VideoCount);
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
if (live == "live")
liveTag.Visibility = Visibility.Visible;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToChannel(channelId);
} }
} }
} }
+36
View File
@@ -0,0 +1,36 @@
<UserControl
x:Class="FoxTube.Controls.ChannelCardWide"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
HorizontalAlignment="Stretch"
Height="150">
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2" VerticalAlignment="Stretch" Click="Button_Click">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="125"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<PersonPicture Name="avatar" Width="125"/>
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<TextBlock Name="channelName" Text="IGP" FontSize="18"/>
<StackPanel Name="liveTag" Margin="5,0,0,0" BorderBrush="Red" BorderThickness="2" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/>
<TextBlock Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontWeight="Bold"/>
</StackPanel>
</StackPanel>
<TextBlock Name="subscribers" Text="120,452 subscribers" Foreground="Gray"/>
<TextBlock Name="videoCount" Foreground="Gray" Text="563,000 videos"/>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" Name="subscriptionPane">
<ToggleButton Grid.Column="2" Height="40" Width="200" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
<ToggleButton Grid.Column="3" Height="40" Width="40" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
</StackPanel>
</StackPanel>
</Grid>
</Button>
</UserControl>
+50
View File
@@ -0,0 +1,50 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
namespace FoxTube.Controls
{
public sealed partial class ChannelCardWide : UserControl
{
string channelId;
public ChannelCardWide(string id, string live)
{
this.InitializeComponent();
Initialize(id, live);
}
public async void Initialize(string id, string live)
{
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
ApplicationName = this.GetType().ToString()
});
ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics");
request.Id = id;
ChannelListResponse response = await request.ExecuteAsync();
var item = response.Items[0];
channelId = id;
channelName.Text = item.Snippet.Title;
subscribers.Text = string.Format("{0} subscribers", item.Statistics.SubscriberCount);
videoCount.Text = string.Format("{0} videos", item.Statistics.VideoCount);
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
if (live == "live")
liveTag.Visibility = Visibility.Visible;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToChannel(channelId);
}
}
}
+14
View File
@@ -0,0 +1,14 @@
<UserControl
x:Class="FoxTube.Controls.ShowMore"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<HyperlinkButton Foreground="Red" HorizontalAlignment="Center" Content="Show more" Name="btn" Click="btn_Click"/>
<ProgressBar Name="bar" IsIndeterminate="True" Foreground="Red" Visibility="Collapsed"/>
</Grid>
</UserControl>
+44
View File
@@ -0,0 +1,44 @@
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.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 User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace FoxTube.Controls
{
public delegate void Event();
public sealed partial class ShowMore : UserControl
{
public event Event Clicked;
public ShowMore()
{
this.InitializeComponent();
}
private void btn_Click(object sender, RoutedEventArgs e)
{
btn.Visibility = Visibility.Collapsed;
bar.Visibility = Visibility.Visible;
Clicked.Invoke();
}
public void Complete(bool close = false)
{
bar.Visibility = Visibility.Collapsed;
if (!close)
btn.Visibility = Visibility.Visible;
}
}
}
+13 -16
View File
@@ -1,8 +1,7 @@
<UserControl <UserControl
x:Class="FoxTube.VideoCard" x:Class="FoxTube.Controls.VideoCard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
@@ -12,36 +11,36 @@
d:DesignHeight="290" d:DesignHeight="290"
d:DesignWidth="384"> d:DesignWidth="384">
<Button Padding="0" Background="Transparent" VerticalAlignment="Top" Click="Button_Click"> <Button Padding="0" Background="Transparent" Click="Button_Click">
<Grid Background="WhiteSmoke" BorderBrush="LightGray" BorderThickness="1"> <Grid Background="WhiteSmoke" BorderBrush="LightGray" BorderThickness="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="75"/> <RowDefinition Height="75"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Black"> <Grid Background="Black">
<Image Name="thumbnail" Source="Assets/videoThumbSample.png" Stretch="Fill"/> <Image Name="thumbnail" Source="/Assets/videoThumbSample.png" Stretch="Fill"/>
<Grid Background="#7FFFFFFF" Name="watched" Visibility="Collapsed"> <Grid Background="#7FFFFFFF" Name="watched" Visibility="Collapsed">
<StackPanel Margin="5" Background="WhiteSmoke" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="5,2,5,2" BorderBrush="Gray" BorderThickness="1"> <StackPanel Margin="5" Background="WhiteSmoke" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="5,2,5,2" BorderBrush="Gray" BorderThickness="1">
<TextBlock Text="Watched" Foreground="Gray" FontSize="12"/> <TextBlock Text="Watched" Foreground="Gray" FontSize="12"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
<StackPanel Margin="0,0,5,5" Background="WhiteSmoke" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,0" Height="20"> <StackPanel Margin="0,0,5,5" Background="WhiteSmoke" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3">
<TextBlock Name="info" Text="[Duration] | [Published at]" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="12"/> <TextBlock Name="info" Text="[Duration] | [Published at]" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="12"/>
</StackPanel> </StackPanel>
<StackPanel Name="liveTag" Margin="0,0,5,30" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed"> <StackPanel Name="liveTag" Margin="0,0,5,30" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/> <TextBlock Text="&#xEC44; " VerticalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" FontWeight="Black"/>
<TextBlock Name="liveContent" Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/> <TextBlock Name="liveContent" Text="LIVE" VerticalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="2*"/> <RowDefinition Height="20"/>
<RowDefinition Height="5*"/> <RowDefinition Height="55"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0"> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/> <ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Ellipse Grid.Column="0" Height="50" Width="50" Margin="5,-30,5,10" Fill="WhiteSmoke"/> <Ellipse Grid.Column="0" Height="50" Width="50" Margin="5,-30,5,10" Fill="WhiteSmoke"/>
<PersonPicture Name="avatar" Grid.Column="0" Height="46" Margin="5,-30,5,0" BorderBrush="White" BorderThickness="10"/> <PersonPicture Name="avatar" Grid.Column="0" Height="46" Margin="5,-30,5,0" BorderBrush="White" BorderThickness="10"/>
@@ -49,9 +48,7 @@
<TextBlock Name="channelName" Grid.Column="1" Text="[Channel name]" Foreground="Gray" Margin="0,2,0,0" FontSize="12"/> <TextBlock Name="channelName" Grid.Column="1" Text="[Channel name]" Foreground="Gray" Margin="0,2,0,0" FontSize="12"/>
<TextBlock Grid.Column="1" Name="views" Text="[Views]" HorizontalAlignment="Right" Foreground="Gray" Margin="0,2,2,0" FontSize="12"/> <TextBlock Grid.Column="1" Name="views" Text="[Views]" HorizontalAlignment="Right" Foreground="Gray" Margin="0,2,2,0" FontSize="12"/>
</Grid> </Grid>
<StackPanel Grid.Row="1"> <TextBlock Grid.Row="1" Name="title" Text="[Title]" TextWrapping="WrapWholeWords" Margin="5" MaxLines="2"/>
<TextBlock Name="title" Text="[Title]" TextWrapping="WrapWholeWords" Margin="5" FontSize="14" MaxLines="2"/>
</StackPanel>
</Grid> </Grid>
</Grid> </Grid>
</Button> </Button>
+48 -48
View File
@@ -1,36 +1,21 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; 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;
using Google.Apis.Services;
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Imaging;
using System.Xml; using System.Xml;
using Windows.System; using Windows.System;
using Windows.UI.Popups;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 namespace FoxTube.Controls
namespace FoxTube
{ {
public sealed partial class VideoCard : UserControl public sealed partial class VideoCard : UserControl
{ {
public string videoId; public string videoId;
Google.Apis.YouTube.v3.Data.Video item; Google.Apis.YouTube.v3.Data.Video item;
bool embed = false; bool embed = true;
public VideoCard(string id) public VideoCard(string id)
{ {
this.InitializeComponent(); this.InitializeComponent();
@@ -51,58 +36,73 @@ namespace FoxTube
VideoListResponse response = await request.ExecuteAsync(); VideoListResponse response = await request.ExecuteAsync();
item = response.Items[0]; item = response.Items[0];
videoId = id; videoId = id;
title.Text = item.Snippet.Title; title.Text = item.Snippet.Title;
views.Text = string.Format("{0} views", item.Statistics.ViewCount); channelName.Text = item.Snippet.ChannelTitle;
string duration;
if (!string.IsNullOrWhiteSpace(item.ContentDetails.Duration))
{
TimeSpan ts = XmlConvert.ToTimeSpan(item.ContentDetails.Duration);
duration = string.Format("{0}{1:00}:{2:00} | ", ts.Hours == 0 ? "" : ts.Hours + ":", ts.Minutes, ts.Seconds);
}
else duration = string.Empty;
info.Text = string.Format("{0}{1} | {2}", duration, Methods.GetAgo(item.Snippet.PublishedAt.Value), (item.LiveStreamingDetails != null && item.LiveStreamingDetails.ConcurrentViewers.HasValue) ? item.LiveStreamingDetails.ConcurrentViewers + " viewers" : item.Statistics.ViewCount + " views");
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
if (item.Snippet.LiveBroadcastContent == "live") if (item.Snippet.LiveBroadcastContent == "live")
{ {
embed = true; views.Text = $"{item.LiveStreamingDetails.ConcurrentViewers} viewers";
if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && item.LiveStreamingDetails.ScheduledEndTime.HasValue)
info.Text = $"{item.LiveStreamingDetails.ScheduledEndTime - item.LiveStreamingDetails.ScheduledStartTime} | {Methods.GetAgo(item.LiveStreamingDetails.ActualStartTime.Value)}";
else
info.Text = item.LiveStreamingDetails.ActualStartTime.Value.ToString();
liveTag.Visibility = Visibility.Visible; liveTag.Visibility = Visibility.Visible;
} }
else if (item.Snippet.LiveBroadcastContent == "upcoming") else if(item.Snippet.LiveBroadcastContent == "upcoming")
{ {
embed = true; views.Text = "";
TimeSpan span; if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && item.LiveStreamingDetails.ScheduledEndTime.HasValue)
if (item.LiveStreamingDetails.ScheduledStartTime != null && (item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now).Value.TotalMilliseconds > 0) info.Text = $"{item.LiveStreamingDetails.ScheduledEndTime - item.LiveStreamingDetails.ScheduledStartTime} | {item.LiveStreamingDetails.ScheduledStartTime}";
{ else
span = (TimeSpan)(item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now); info.Text = $"{Methods.GetAgo(item.Snippet.PublishedAt.Value)}";
liveContent.Text = "Goes live in " + string.Format("{0}{1:00}:{2:00}:{3:00}", span.Days != 0 ? span.Days + ":" : "", span.Hours, span.Minutes, span.Seconds); liveTag.Visibility = Visibility.Visible;
if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && (item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now).Value.TotalMilliseconds > 0)
liveContent.Text = $"Goes live in {item.LiveStreamingDetails.ScheduledStartTime}";
else liveContent.Text = "Upcoming";
} }
else else
liveContent.Text = "Upcoming"; {
liveTag.Visibility = Visibility.Visible; views.Text = $"{item.Statistics.ViewCount} views";
info.Text = $"{XmlConvert.ToTimeSpan(item.ContentDetails.Duration)} | {Methods.GetAgo(item.Snippet.PublishedAt.Value)}";
embed = false;
} }
var request1 = ytService.Channels.List("snippet,contentDetails,statistics"); var request1 = ytService.Channels.List("snippet");
request1.Id = item.Snippet.ChannelId; request1.Id = item.Snippet.ChannelId;
ChannelListResponse response1 = await request1.ExecuteAsync(); ChannelListResponse response1 = await request1.ExecuteAsync();
var item1 = response1.Items[0]; try
{
avatar.ProfilePicture = new BitmapImage(new Uri(response1.Items[0].Snippet.Thumbnails.Medium.Url));
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
}
catch { }
avatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url)); foreach(PlaylistItem i in SecretsVault.UserHistory)
channelName.Text = item1.Snippet.Title; if (i.Snippet.ResourceId.VideoId == id)
{
if (SecretsVault.UserHistory.Contains(item.Id))
watched.Visibility = Visibility.Visible; watched.Visibility = Visibility.Visible;
break;
}
} }
private async void Button_Click(object sender, RoutedEventArgs e) private async void Button_Click(object sender, RoutedEventArgs e)
{ {
if (embed) if (embed)
await Launcher.LaunchUriAsync(new Uri(string.Format("https://www.youtube.com/watch?v={0}", videoId))); {
MessageDialog dialog = new MessageDialog("Unfortunately, at this stage of application development we don't support live steams. This issue will be fixed in the next update. Sorry. Would you like us to open this stream in browser?", "Open in browser");
dialog.Commands.Add(new UICommand("Yes", async (command) =>
{
await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/watch?v={videoId}"));
}));
dialog.Commands.Add(new UICommand("No"));
dialog.DefaultCommandIndex = 0;
dialog.CancelCommandIndex = 1;
await dialog.ShowAsync();
}
else else
Methods.MainPage.GoToVideo(videoId); Methods.MainPage.GoToVideo(videoId);
} }
+2 -2
View File
@@ -92,8 +92,8 @@ namespace FoxTube
channelName.Text = item1.Snippet.Title; channelName.Text = item1.Snippet.Title;
channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount); channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount);
if (SecretsVault.UserHistory.Contains(item.Id)) //if (SecretsVault.UserHistory.Contains(item.Id))
watched.Visibility = Visibility.Visible; //watched.Visibility = Visibility.Visible;
} }
private void channelLink_Click(object sender, RoutedEventArgs e) private void channelLink_Click(object sender, RoutedEventArgs e)
+17 -3
View File
@@ -98,6 +98,9 @@
</Compile> </Compile>
<Compile Include="Classes\Methods.cs" /> <Compile Include="Classes\Methods.cs" />
<Compile Include="Classes\ObjectEventArgs.cs" /> <Compile Include="Classes\ObjectEventArgs.cs" />
<Compile Include="Controls\ChannelCard.xaml.cs">
<DependentUpon>ChannelCard.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\CommentCard.xaml.cs"> <Compile Include="Controls\CommentCard.xaml.cs">
<DependentUpon>CommentCard.xaml</DependentUpon> <DependentUpon>CommentCard.xaml</DependentUpon>
</Compile> </Compile>
@@ -105,14 +108,17 @@
<Compile Include="Controls\DownloadItem.xaml.cs"> <Compile Include="Controls\DownloadItem.xaml.cs">
<DependentUpon>DownloadItem.xaml</DependentUpon> <DependentUpon>DownloadItem.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\ShowMore.xaml.cs">
<DependentUpon>ShowMore.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\SuggestionsQueries.xaml.cs"> <Compile Include="Controls\SuggestionsQueries.xaml.cs">
<DependentUpon>SuggestionsQueries.xaml</DependentUpon> <DependentUpon>SuggestionsQueries.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Pages\Channel.xaml.cs"> <Compile Include="Pages\Channel.xaml.cs">
<DependentUpon>Channel.xaml</DependentUpon> <DependentUpon>Channel.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\ChannelCard.xaml.cs"> <Compile Include="Controls\ChannelCardWide.xaml.cs">
<DependentUpon>ChannelCard.xaml</DependentUpon> <DependentUpon>ChannelCardWide.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Pages\CommentsPage.xaml.cs"> <Compile Include="Pages\CommentsPage.xaml.cs">
<DependentUpon>CommentsPage.xaml</DependentUpon> <DependentUpon>CommentsPage.xaml</DependentUpon>
@@ -258,6 +264,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="Controls\ChannelCard.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\CommentCard.xaml"> <Page Include="Controls\CommentCard.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -266,6 +276,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Controls\ShowMore.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\SuggestionsQueries.xaml"> <Page Include="Controls\SuggestionsQueries.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -274,7 +288,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Controls\ChannelCard.xaml"> <Page Include="Controls\ChannelCardWide.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
+2 -2
View File
@@ -35,7 +35,7 @@
<Pivot SelectedIndex="0" Name="content" IsHeaderItemsCarouselEnabled="False" SelectionChanged="content_SelectionChanged"> <Pivot SelectedIndex="0" Name="content" IsHeaderItemsCarouselEnabled="False" SelectionChanged="content_SelectionChanged">
<PivotItem Margin="0,-48,0,0"> <PivotItem Margin="0,-48,0,0">
<StackPanel Name="videos"> <StackPanel Name="videos">
<Image Name="channelCover" Stretch="Uniform" Source="Assets/ChannelCoverTemplate.png"/> <Image Name="channelCover" Stretch="Uniform" Source="/Assets/ChannelCoverTemplate.png"/>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/> <ColumnDefinition Width="120"/>
@@ -55,7 +55,7 @@
</Grid> </Grid>
</StackPanel> </StackPanel>
</PivotItem> </PivotItem>
<PivotItem Margin="0,-48,0,0"> <PivotItem Margin="0,-48,0,0" >
<Grid Padding="10"> <Grid Padding="10">
<ProgressRing Name="playlistRing" Width="100" Height="100" Foreground="Red" IsActive="True"/> <ProgressRing Name="playlistRing" Width="100" Height="100" Foreground="Red" IsActive="True"/>
<StackPanel Visibility="Visible" Name="playlistPane"> <StackPanel Visibility="Visible" Name="playlistPane">
+7 -10
View File
@@ -9,11 +9,11 @@
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="grid"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="grid">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="0"/> <RowDefinition Height="auto"/>
<RowDefinition Height="*"/> <RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Red"> <StackPanel Name="navigation" Visibility="Collapsed" Orientation="Horizontal" Padding="10,0,10,0" Background="Red" Height="47">
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<HyperlinkButton Name="toRecommended" Click="toRecommended_Click" Foreground="White" Margin="0,0,10,0"> <HyperlinkButton Name="toRecommended" Click="toRecommended_Click" Foreground="White" Margin="0,0,10,0">
<TextBlock Text="Recommended"/> <TextBlock Text="Recommended"/>
</HyperlinkButton> </HyperlinkButton>
@@ -24,10 +24,8 @@
<TextBlock Text="Subscriptions"/> <TextBlock Text="Subscriptions"/>
</HyperlinkButton> </HyperlinkButton>
</StackPanel> </StackPanel>
</Grid> <ScrollViewer Grid.Row="1">
<Grid Grid.Row="1"> <Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged">
<ScrollViewer Margin="0,0,0,50">
<Pivot Name="pivot">
<PivotItem Margin="0,-48,0,0"> <PivotItem Margin="0,-48,0,0">
</PivotItem> </PivotItem>
@@ -39,9 +37,8 @@
</PivotItem> </PivotItem>
</Pivot> </Pivot>
</ScrollViewer> </ScrollViewer>
<CommandBar VerticalAlignment="Bottom"> <CommandBar Grid.Row="2">
<AppBarButton Icon="Refresh" Label="Refresh page" Name="refresh" Click="refresh_Click"/> <AppBarButton Icon="Refresh" Label="Refresh page" Name="refresh" Click="refresh_Click"/>
</CommandBar> </CommandBar>
</Grid> </Grid>
</Grid>
</Page> </Page>
+75 -24
View File
@@ -17,6 +17,7 @@ using System.Globalization;
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using Windows.Storage; using Windows.Storage;
using Windows.UI.Text;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -27,6 +28,9 @@ namespace FoxTube
/// </summary> /// </summary>
public sealed partial class Home : Page public sealed partial class Home : Page
{ {
private bool recLoaded = false;
private bool trendLoaded = false;
private bool subsLoaded = false;
public Home() public Home()
{ {
this.InitializeComponent(); this.InitializeComponent();
@@ -35,7 +39,6 @@ namespace FoxTube
public async void Initialize() public async void Initialize()
{ {
#region Vairables declaring
VideoGrid videoGrid = new VideoGrid(); VideoGrid videoGrid = new VideoGrid();
string reg; string reg;
@@ -47,58 +50,106 @@ namespace FoxTube
{ {
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper(); reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper();
} }
#endregion
pivot.Items.Clear(); pivot.Items.Clear();
grid.RowDefinitions[0].Height = new GridLength(0);
#region Request-Response VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("snippet,contentDetails,statistics");
request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
request.RegionCode = reg;
request.MaxResults = 48; request.MaxResults = 48;
if(SecretsVault.IsAuthorized)
{
navigation.Visibility = Visibility.Visible;
for(int k = 0; k < 3; k++)
{
StackPanel stack = new StackPanel();
stack.Children.Add(new VideoGrid());
stack.Children.Add(new LoadingPage());
pivot.Items.Add(new PivotItem()
{
Margin = new Thickness(0, -48, 0, 0),
Content = stack
});
}
//Initializing recommended videos loading
recLoaded = true;
(((pivot.Items[0] as PivotItem).Content as StackPanel).Children[1] as LoadingPage).Block();
}
else
{
Grid g = new Grid();
StackPanel stack = new StackPanel();
stack.Children.Add(new VideoGrid());
stack.Children.Add(new HyperlinkButton()
{
});
g.Children.Add(stack);
g.Children.Add(new LoadingPage());
pivot.Items.Add(new PivotItem()
{
Margin = new Thickness(0, -48, 0, 0),
Content = g
});
//Initializing recommended videos loading
request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
request.RegionCode = reg;
VideoListResponse response = await request.ExecuteAsync(); VideoListResponse response = await request.ExecuteAsync();
#endregion
foreach (Google.Apis.YouTube.v3.Data.Video vid in response.Items) foreach (Google.Apis.YouTube.v3.Data.Video vid in response.Items)
{ {
VideoCard vCard = new VideoCard(vid.Id); VideoCard vCard = new VideoCard(vid.Id);
videoGrid.AddCards(vCard); videoGrid.AddCards(vCard);
} }
trendLoaded = true;
pivot.Items.Add(new PivotItem() }
{
Margin = new Thickness(0,-48,0,0),
Name = "trending",
Content = videoGrid
});
/*if((Parent as MainPage).Logged)
{
grid.RowDefinitions[0].Height = new GridLength(47);
//TO-DO: Add initializing recommended and subscriptions tabs
}*/
} }
private void toRecommended_Click(object sender, RoutedEventArgs e) private void toRecommended_Click(object sender, RoutedEventArgs e)
{ {
pivot.SelectedIndex = 0;
} }
private void toTrending_Click(object sender, RoutedEventArgs e) private void toTrending_Click(object sender, RoutedEventArgs e)
{ {
if (pivot.Items.Count > 1)
pivot.SelectedIndex = 1;
else
pivot.SelectedIndex = 0;
} }
private void tosubs_Click(object sender, RoutedEventArgs e) private void tosubs_Click(object sender, RoutedEventArgs e)
{ {
pivot.SelectedIndex = 2;
} }
private void refresh_Click(object sender, RoutedEventArgs e) private void refresh_Click(object sender, RoutedEventArgs e)
{ {
Initialize(); Initialize();
} }
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
toRecommended.FontWeight = FontWeights.Normal;
toTrending.FontWeight = FontWeights.Normal;
tosubs.FontWeight = FontWeights.Normal;
switch(pivot.SelectedIndex)
{
case 2:
tosubs.FontWeight = FontWeights.Bold;
break;
case 1:
toTrending.FontWeight = FontWeights.Bold;
break;
case 0:
if (pivot.Items.Count > 1)
toRecommended.FontWeight = FontWeights.Bold;
else toTrending.FontWeight = FontWeights.Bold;
break;
}
}
} }
} }
+8 -1
View File
@@ -22,7 +22,7 @@ namespace FoxTube
/// </summary> /// </summary>
public sealed partial class LoadingPage : Page public sealed partial class LoadingPage : Page
{ {
public event EventHandler RefreshPage; public event RoutedEventHandler RefreshPage;
public LoadingPage() public LoadingPage()
{ {
@@ -54,6 +54,7 @@ namespace FoxTube
public void Block() public void Block()
{ {
Visibility = Visibility.Visible;
ring.IsActive = false; ring.IsActive = false;
trouble.Visibility = Visibility.Collapsed; trouble.Visibility = Visibility.Collapsed;
wifiTrouble.Visibility = Visibility.Collapsed; wifiTrouble.Visibility = Visibility.Collapsed;
@@ -86,10 +87,16 @@ namespace FoxTube
public void Refresh() public void Refresh()
{ {
Visibility = Visibility.Visible;
ring.IsActive = true; ring.IsActive = true;
trouble.Visibility = Visibility.Collapsed; trouble.Visibility = Visibility.Collapsed;
wifiTrouble.Visibility = Visibility.Collapsed; wifiTrouble.Visibility = Visibility.Collapsed;
blockIcon.Visibility = Visibility.Collapsed; blockIcon.Visibility = Visibility.Collapsed;
} }
public void Close()
{
Visibility = Visibility.Collapsed;
}
} }
} }
+5 -1
View File
@@ -108,6 +108,10 @@
<SplitView Name="menu" Grid.Row="1" OpenPaneLength="250" CompactPaneLength="50" DisplayMode="CompactInline" IsPaneOpen="True" PaneClosing="menu_PaneClosed" PaneOpening="menu_PaneOpened"> <SplitView Name="menu" Grid.Row="1" OpenPaneLength="250" CompactPaneLength="50" DisplayMode="CompactInline" IsPaneOpen="True" PaneClosing="menu_PaneClosed" PaneOpening="menu_PaneOpened">
<SplitView.Pane> <SplitView.Pane>
<Grid> <Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ScrollViewer> <ScrollViewer>
<StackPanel> <StackPanel>
<ListBox Name="mainList" SelectionChanged="HamburgerSelectionChanged"> <ListBox Name="mainList" SelectionChanged="HamburgerSelectionChanged">
@@ -211,7 +215,7 @@
</ListBox> </ListBox>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
<ListBox VerticalAlignment="Bottom" Name="serviceList" SelectionChanged="HamburgerSelectionChanged"> <ListBox Grid.Row="1" VerticalAlignment="Bottom" Name="serviceList" SelectionChanged="HamburgerSelectionChanged">
<ListBoxItem Padding="0" IsEnabled="False"> <ListBoxItem Padding="0" IsEnabled="False">
<Line X2="250" Stroke="Gray"/> <Line X2="250" Stroke="Gray"/>
</ListBoxItem> </ListBoxItem>
+15 -6
View File
@@ -195,7 +195,9 @@ namespace FoxTube
private void HamburgerSelectionChanged(object sender, SelectionChangedEventArgs e) private void HamburgerSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if(sender == mainList) try
{
if (sender == mainList)
{ {
subscriptionsList.SelectedItem = null; subscriptionsList.SelectedItem = null;
categoriesList.SelectedItem = null; categoriesList.SelectedItem = null;
@@ -209,14 +211,14 @@ namespace FoxTube
serviceList.SelectedItem = null; serviceList.SelectedItem = null;
SubscriptionSelected(); SubscriptionSelected();
} }
else if(sender == categoriesList) else if (sender == categoriesList)
{ {
subscriptionsList.SelectedItem = null; subscriptionsList.SelectedItem = null;
mainList.SelectedItem = null; mainList.SelectedItem = null;
serviceList.SelectedItem = null; serviceList.SelectedItem = null;
FeaturedSelected(); FeaturedSelected();
} }
else if(sender == serviceList) else if (sender == serviceList)
{ {
subscriptionsList.SelectedItem = null; subscriptionsList.SelectedItem = null;
mainList.SelectedItem = null; mainList.SelectedItem = null;
@@ -230,6 +232,7 @@ namespace FoxTube
categoriesList.SelectedItem = null; categoriesList.SelectedItem = null;
serviceList.SelectedItem = null; serviceList.SelectedItem = null;
} }
} catch { }
} }
void MainListSelected() void MainListSelected()
@@ -371,10 +374,14 @@ namespace FoxTube
} }
private void menu_PaneOpened(SplitView sender, object args) private void menu_PaneOpened(SplitView sender, object args)
{
try
{ {
subsTitle.Visibility = Visibility.Visible; subsTitle.Visibility = Visibility.Visible;
catTitle.Visibility = Visibility.Visible; catTitle.Visibility = Visibility.Visible;
} }
catch { }
}
private async void createAccount_Click(object sender, RoutedEventArgs e) private async void createAccount_Click(object sender, RoutedEventArgs e)
{ {
@@ -418,8 +425,10 @@ namespace FoxTube
private void searchButton_Click(object sender, RoutedEventArgs e) private void searchButton_Click(object sender, RoutedEventArgs e)
{ {
if (searchField.Text != "" || (!(content.Content is Search) && (content.Content as Search).Term != searchField.Text)) if (!string.IsNullOrWhiteSpace(searchField.Text) || !(content.Content is Search))
content.Navigate(typeof(Search), searchField.Text); content.Navigate(typeof(Search), searchField.Text);
else if (content.Content is Search)
(content.Content as Search).Initialize(searchField.Text);
} }
public void GoToSearch(string keyword) public void GoToSearch(string keyword)
@@ -428,7 +437,7 @@ namespace FoxTube
searchButton_Click(this, null); searchButton_Click(this, null);
} }
private async void StartSearch(string keyword) /*private async void StartSearch(string keyword)
{ {
content.Navigate(typeof(Search)); content.Navigate(typeof(Search));
HamburgerSelectionChanged(null, null); HamburgerSelectionChanged(null, null);
@@ -458,7 +467,7 @@ namespace FoxTube
s.ring.IsActive = false; s.ring.IsActive = false;
s.content.Visibility = Visibility.Visible; s.content.Visibility = Visibility.Visible;
Debug.WriteLine("done"); Debug.WriteLine("done");
} }*/
private void searchField_KeyUp(object sender, KeyRoutedEventArgs e) private void searchField_KeyUp(object sender, KeyRoutedEventArgs e)
{ {
+64 -29
View File
@@ -5,41 +5,76 @@
xmlns:local="using:FoxTube" xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:FoxTube.Controls"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ScrollViewer> <ScrollViewer>
<Grid> <StackPanel Margin="10">
<ProgressRing HorizontalAlignment="Center" VerticalAlignment="Center" IsActive="True" Name="progressRing" Foreground="Red" Width="100" Height="100"/> <TextBlock Name="searchTerm" Text="Search results for: [searchTerm]" FontSize="28"/>
<StackPanel Orientation="Vertical" Margin="10" Visibility="Collapsed" Name="displaying"> <TextBlock Name="resultsCount" Text="Found: [resultCount] item(s)" FontSize="14" Foreground="Gray"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Search results for: " FontSize="28"/>
<TextBlock Name="searchTerm" Text="[searchTerm]" FontSize="28" Margin="10,0,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Found:" FontSize="14" Foreground="Gray" Margin="0,-5,0,10"/>
<TextBlock Name="resultsCount" Text="[resultsCount]" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
<TextBlock Text="items" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
</StackPanel>
<HyperlinkButton Content="Show filters &#xE71C;" FontFamily="Default, Segoe MDL2 Assets" FontSize="18" Visibility="Collapsed"/>
<Grid Background="WhiteSmoke" Padding="5" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Type" FontSize="20"/>
<Line StrokeThickness="1" Stroke="Gray" X1="0" X2="150"/>
<RadioButton Content="All" IsChecked="True"/>
<RadioButton Content="Videos"/>
<RadioButton Content="Channels"/>
<RadioButton Content="Playlists"/>
</StackPanel>
</Grid>
<StackPanel Name="resultsList" Orientation="Vertical">
<HyperlinkButton Name="toggleFilters" Click="toggleFilters_Click" Content="Show filters &#xE71C;" FontFamily="Default, Segoe MDL2 Assets" Visibility="Visible"/>
<StackPanel Name="filters" Visibility="Collapsed">
<GridView Padding="5" Visibility="Visible">
<ComboBox Name="order" Header="Sort by" Width="150" SelectedIndex="0">
<ComboBoxItem Content="Relevance"/>
<ComboBoxItem Content="Upload date"/>
<ComboBoxItem Content="View count"/>
<ComboBoxItem Content="Rating"/>
<ComboBoxItem Content="Title"/>
</ComboBox>
<ComboBox Name="type" Header="Type" Width="150" SelectedIndex="0">
<ComboBoxItem Content="All"/>
<ComboBoxItem Content="Video"/>
<ComboBoxItem Content="Channel"/>
<ComboBoxItem Content="Playlist"/>
</ComboBox>
<ComboBox Name="date" Header="Upload date" Width="150" SelectedIndex="0">
<ComboBoxItem Content="Anytime"/>
<ComboBoxItem Content="Last hour"/>
<ComboBoxItem Content="Today"/>
<ComboBoxItem Content="This week"/>
<ComboBoxItem Content="This month"/>
<ComboBoxItem Content="This year"/>
</ComboBox>
<ComboBox Name="duration" Header="Duration" Width="150" SelectedIndex="0">
<ComboBoxItem Content="Any"/>
<ComboBoxItem Content="Short (&#x3C; 4 minutes)"/>
<ComboBoxItem Content="Medium"/>
<ComboBoxItem Content="Long (&#x3E; 20 minutes)"/>
</ComboBox>
</GridView>
<StackPanel Orientation="Horizontal">
<Button Content="Features" Margin="10,0,0,10">
<Button.Flyout>
<Flyout>
<ListView Name="features" SelectionMode="Multiple" Header="Features">
<TextBlock Text="HD"/>
<TextBlock Text="3D"/>
<TextBlock Text="Subtitles/CC"/>
<TextBlock Text="Live"/>
<TextBlock Text="Creative Commons"/>
</ListView>
</Flyout>
</Button.Flyout>
</Button>
<Button Content="Apply" Margin="10,0,0,10"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid> <local:VideoGrid Name="list"/>
<controls:ShowMore Name="more" Clicked="more_Clicked" Visibility="Collapsed"/>
</StackPanel>
</ScrollViewer> </ScrollViewer>
<CommandBar Grid.Row="1" DefaultLabelPosition="Right">
<AppBarButton Label="Refresh" Icon="Refresh" Click="AppBarButton_Click"/>
</CommandBar>
<local:LoadingPage Name="loading" Grid.RowSpan="2" Visibility="Collapsed" RefreshPage="AppBarButton_Click"/>
</Grid> </Grid>
</Page> </Page>
+202 -16
View File
@@ -1,4 +1,5 @@
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -7,6 +8,7 @@ using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime; using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation; using Windows.Foundation;
using Windows.Foundation.Collections; using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Controls.Primitives;
@@ -25,22 +27,22 @@ namespace FoxTube
public sealed partial class Search : Page public sealed partial class Search : Page
{ {
public string Term; public string Term;
public ProgressRing ring; SearchResource.ListRequest request;
public StackPanel content; string nextToken;
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
public Search() public Search()
{ {
this.InitializeComponent(); this.InitializeComponent();
ring = progressRing;
content = displaying;
} }
public void SetResults(string keyword, int count) public string SetResults(int? count)
{ {
searchTerm.Text = keyword;
if (count == 1000000) if (count == 1000000)
resultsCount.Text = count + "+"; return count + "+";
else if (count == null)
return "0";
else else
resultsCount.Text = count.ToString(); return count.ToString();
} }
public void AddItem(SearchResult result) public void AddItem(SearchResult result)
@@ -49,23 +51,207 @@ namespace FoxTube
{ {
case "youtube#video": case "youtube#video":
VideoCardWide vCard = new VideoCardWide(result.Id.VideoId); VideoCardWide vCard = new VideoCardWide(result.Id.VideoId);
resultsList.Children.Add(vCard); list.Add(vCard);
break; break;
case "youtube#channel": case "youtube#channel":
ChannelCard cCard = new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent); ChannelCard cCard = new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent);
resultsList.Children.Add(cCard); list.Add(cCard);
break; break;
case "youtube#playlist": case "youtube#playlist":
PlaylistCardWide pCard = new PlaylistCardWide(result.Id.PlaylistId); PlaylistCardWide pCard = new PlaylistCardWide(result.Id.PlaylistId);
resultsList.Children.Add(pCard); list.Add(pCard);
break;
default:
Debug.WriteLine("Skipped");
break; break;
} }
} }
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter == null)
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated.");
else
Initialize(e.Parameter as string);
}
public async void Initialize(string term, bool forceInitialization = false)
{
if (term == Term && !forceInitialization)
return;
loading.Refresh();
try
{
Term = term;
request = SecretsVault.Service.Search.List("id");
request.Q = term;
request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"];
try
{
request.RelevanceLanguage = settings.Values["region"].ToString().Remove(2).ToLower();
}
catch (ArgumentOutOfRangeException)
{
request.RelevanceLanguage = settings.Values["region"].ToString().ToLower();
}
request.MaxResults = 48;
request.Order = Order;
request.Type = Type;
request.PublishedAfter = Date;
if (Duration != SearchResource.ListRequest.VideoDurationEnum.Any)
{
request.Type = "video";
type.SelectedIndex = 1;
request.VideoDuration = Duration;
}
request.VideoDuration = Duration;
if (features.SelectedItems.Count > 0)
{
request.Type = "video";
type.SelectedIndex = 1;
if (features.SelectedItems.Contains(features.Items[0]))
request.VideoDefinition = SearchResource.ListRequest.VideoDefinitionEnum.High;
if (features.SelectedItems.Contains(features.Items[1]))
request.VideoDimension = SearchResource.ListRequest.VideoDimensionEnum.Value3d;
if (features.SelectedItems.Contains(features.Items[2]))
request.VideoCaption = SearchResource.ListRequest.VideoCaptionEnum.ClosedCaption;
if (features.SelectedItems.Contains(features.Items[3]))
request.EventType = SearchResource.ListRequest.EventTypeEnum.Live;
if (features.SelectedItems.Contains(features.Items[4]))
request.VideoLicense = SearchResource.ListRequest.VideoLicenseEnum.CreativeCommon;
}
SearchListResponse response = await request.ExecuteAsync();
searchTerm.Text = $"Search results for: {Term}";
resultsCount.Text = $"Found: {SetResults(response.PageInfo.TotalResults)} item(s)";
if (response.NextPageToken != null)
{
nextToken = response.NextPageToken;
more.Visibility = Visibility.Visible;
}
foreach (SearchResult item in response.Items)
AddItem(item);
loading.Close();
}
catch
{
loading.Error();
}
}
private void toggleFilters_Click(object sender, RoutedEventArgs e)
{
if(filters.Visibility == Visibility.Collapsed)
{
filters.Visibility = Visibility.Visible;
toggleFilters.Content = "Hide filters &#xE71C;";
}
else
{
filters.Visibility = Visibility.Collapsed;
toggleFilters.Content = "Show filters &#xE71C;";
}
}
SearchResource.ListRequest.OrderEnum Order
{
get
{
switch (order.SelectedIndex)
{
case 1:
return SearchResource.ListRequest.OrderEnum.Date;
case 2:
return SearchResource.ListRequest.OrderEnum.ViewCount;
case 3:
return SearchResource.ListRequest.OrderEnum.Rating;
case 4:
return SearchResource.ListRequest.OrderEnum.Title;
default:
return SearchResource.ListRequest.OrderEnum.Relevance;
}
}
}
string Type
{
get
{
switch(type.SelectedIndex)
{
case 1:
return "video";
case 2:
return "channel";
case 3:
return "playlist";
default:
return "video,channel,playlist";
}
}
}
DateTime? Date
{
get
{
switch(date.SelectedIndex)
{
case 1:
return DateTime.Now.Subtract(TimeSpan.FromHours(1));
case 2:
return DateTime.Now.Subtract(TimeSpan.FromDays(1));
case 3:
return DateTime.Now.Subtract(TimeSpan.FromDays(7));
case 4:
return DateTime.Now.Subtract(TimeSpan.FromDays(31));
case 5:
return DateTime.Now.Subtract(TimeSpan.FromDays(365));
default:
return null;
}
}
}
SearchResource.ListRequest.VideoDurationEnum Duration
{
get
{
switch (type.SelectedIndex)
{
case 1:
return SearchResource.ListRequest.VideoDurationEnum.Short__;
case 2:
return SearchResource.ListRequest.VideoDurationEnum.Medium;
case 3:
return SearchResource.ListRequest.VideoDurationEnum.Long__;
default:
return SearchResource.ListRequest.VideoDurationEnum.Any;
}
}
}
private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
Initialize(Term, true);
}
private async void more_Clicked()
{
request.PageToken = nextToken;
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult item in response.Items)
AddItem(item);
if (response.NextPageToken != null)
{
nextToken = response.NextPageToken;
more.Complete();
}
else
more.Complete(true);
}
} }
} }
+3 -3
View File
@@ -190,7 +190,7 @@ namespace FoxTube
LoadRelatedVideos(); LoadRelatedVideos();
if (SecretsVault.IsAuthorized && SecretsVault.UserHistory[0] != item.Id) /*if (SecretsVault.IsAuthorized && SecretsVault.UserHistory[0] != item.Id)
{ {
await SecretsVault.Service.PlaylistItems.Insert(new PlaylistItem() await SecretsVault.Service.PlaylistItems.Insert(new PlaylistItem()
{ {
@@ -205,7 +205,7 @@ namespace FoxTube
} }
}, "snippet").ExecuteAsync(); }, "snippet").ExecuteAsync();
SecretsVault.UserHistory.Insert(0, item.Id); SecretsVault.UserHistory.Insert(0, item.Id);
} }*/
} }
catch catch
{ {
@@ -595,7 +595,7 @@ namespace FoxTube
PlaylistId = SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater PlaylistId = SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater
} }
}, "snippet").ExecuteAsync(); }, "snippet").ExecuteAsync();
SecretsVault.WatchLater.Insert(0, new KeyValuePair<string, string>(pi.Id, item.Id)); SecretsVault.WatchLater.Insert(0, pi);
} }
else else
{ {
+4 -15
View File
@@ -5,23 +5,12 @@
xmlns:local="using:FoxTube" xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
x:Name="root" x:Name="root"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Padding="5" Name="grid" SizeChanged="grid_SizeChanged"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions> <controls:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None"/>
<ColumnDefinition Width="*"/> <TextBlock Name="empty" Text="&#xD8;" FontSize="200" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Name="col0">
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1" Name="col1">
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Name="col2">
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="3" Name="col3">
</StackPanel>
</Grid> </Grid>
</Page> </Page>
+4 -49
View File
@@ -15,6 +15,7 @@ using Windows.UI.Xaml.Navigation;
using System.Diagnostics; using System.Diagnostics;
using System.Timers; using System.Timers;
using Windows.UI.Core; using Windows.UI.Core;
using Microsoft.Toolkit.Uwp.UI.Controls;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -25,61 +26,15 @@ namespace FoxTube
/// </summary> /// </summary>
public sealed partial class VideoGrid : Page public sealed partial class VideoGrid : Page
{ {
int cols = 0;
List<VideoCard> cards = new List<VideoCard>();
public VideoGrid() public VideoGrid()
{ {
this.InitializeComponent(); this.InitializeComponent();
} }
public void AddCards(VideoCard vCard) public void Add(UIElement card)
{ {
cards.Add(vCard); list.Items.Add(card);
} empty.Visibility = Visibility.Collapsed;
void SetColumns(int num)
{
cols = num;
for (int k = 0; k < grid.ColumnDefinitions.Count; k++)
grid.ColumnDefinitions[k].Width = new GridLength(1, GridUnitType.Star);
for (int k = num; k < grid.ColumnDefinitions.Count; k++)
grid.ColumnDefinitions[k].Width = new GridLength(0);
col0.Children.Clear();
col1.Children.Clear();
col2.Children.Clear();
col3.Children.Clear();
for (int k = 0; k < cards.Count; k += num)
col0.Children.Add(cards[k]);
if(num > 1)
{
for (int k = 1; k < cards.Count; k += num)
col1.Children.Add(cards[k]);
if(num > 2)
{
for (int k = 2; k < cards.Count; k += num)
col2.Children.Add(cards[k]);
if(num > 3)
{
for (int k = 3; k < cards.Count; k += num)
col3.Children.Add(cards[k]);
}
}
}
}
private void grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.NewSize.Width >= 1000 && cols != 4)
SetColumns(4);
else if (e.NewSize.Width >= 800 && e.NewSize.Width < 1000 && cols != 3)
SetColumns(3);
else if (e.NewSize.Width >= 600 && e.NewSize.Width < 800 && cols != 2)
SetColumns(2);
else if (e.NewSize.Width < 600 && cols != 1)
SetColumns(1);
} }
} }
} }