Development 6
This commit is contained in:
@@ -16,11 +16,15 @@ using Windows.UI.Notifications;
|
|||||||
|
|
||||||
namespace FoxTube.Background
|
namespace FoxTube.Background
|
||||||
{
|
{
|
||||||
|
public delegate void NotificationHandler(object sender, string xml);
|
||||||
|
|
||||||
public sealed class BackgroundProcessor : IBackgroundTask
|
public sealed class BackgroundProcessor : IBackgroundTask
|
||||||
{
|
{
|
||||||
public List<Notification> Notifications = new List<Notification>();
|
public static event NotificationHandler NotificationRecieved;
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
|
||||||
private ClientSecrets Secrets => new ClientSecrets()
|
private ClientSecrets Secrets => new ClientSecrets()
|
||||||
@@ -29,11 +33,17 @@ namespace FoxTube.Background
|
|||||||
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
|
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private YouTubeService Service => new YouTubeService(new BaseClientService.Initializer()
|
||||||
|
{
|
||||||
|
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
||||||
|
ApplicationName = "FoxTube"
|
||||||
|
});
|
||||||
|
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
BackgroundTaskDeferral def;
|
BackgroundTaskDeferral def;
|
||||||
public async void Run(IBackgroundTaskInstance taskInstance)
|
public void Run(IBackgroundTaskInstance taskInstance)
|
||||||
{
|
{
|
||||||
def = taskInstance.GetDeferral();
|
def = taskInstance.GetDeferral();
|
||||||
XmlDocument doc = new XmlDocument();
|
|
||||||
if (settings.Values["lastCheck"] == null)
|
if (settings.Values["lastCheck"] == null)
|
||||||
settings.Values.Add("lastCheck", XmlConvert.ToString(DateTime.Now));
|
settings.Values.Add("lastCheck", XmlConvert.ToString(DateTime.Now));
|
||||||
else lastCheck = XmlConvert.ToDateTime(settings.Values["lastCheck"] as string, XmlDateTimeSerializationMode.Unspecified);
|
else lastCheck = XmlConvert.ToDateTime(settings.Values["lastCheck"] as string, XmlDateTimeSerializationMode.Unspecified);
|
||||||
@@ -43,14 +53,17 @@ namespace FoxTube.Background
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
|
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
|
||||||
doc.AppendChild(doc.CreateElement("notifications"));
|
doc.AppendChild(doc.CreateElement("history"));
|
||||||
settings.Values.Add("notificationsHistory", doc.InnerXml);
|
settings.Values.Add("notificationsHistory", doc.InnerXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckAccount();
|
if((bool)settings.Values["authorized"] == true)
|
||||||
|
CheckAccount();
|
||||||
|
|
||||||
CheckAnnouncements();
|
CheckAnnouncements();
|
||||||
|
|
||||||
|
SendNSave();
|
||||||
|
|
||||||
def.Complete();
|
def.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,10 +81,10 @@ namespace FoxTube.Background
|
|||||||
subRequest.Mine = true;
|
subRequest.Mine = true;
|
||||||
subRequest.MaxResults = 50;
|
subRequest.MaxResults = 50;
|
||||||
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
||||||
List<string> subs = new List<string>();
|
List<KeyValuePair<string, string>> subs = new List<KeyValuePair<string, string>>();
|
||||||
|
|
||||||
foreach (Subscription s in subResponse.Items)
|
foreach (Subscription s in subResponse.Items)
|
||||||
subs.Add(s.Snippet.ResourceId.ChannelId);
|
subs.Add(new KeyValuePair<string, string>(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url));
|
||||||
|
|
||||||
string nextToken = subResponse.NextPageToken;
|
string nextToken = subResponse.NextPageToken;
|
||||||
while (nextToken != null)
|
while (nextToken != null)
|
||||||
@@ -79,26 +92,25 @@ namespace FoxTube.Background
|
|||||||
subRequest.PageToken = nextToken;
|
subRequest.PageToken = nextToken;
|
||||||
subResponse = await subRequest.ExecuteAsync();
|
subResponse = await subRequest.ExecuteAsync();
|
||||||
foreach (Subscription s in subResponse.Items)
|
foreach (Subscription s in subResponse.Items)
|
||||||
subs.Add(s.Snippet.ResourceId.ChannelId);
|
subs.Add(new KeyValuePair<string, string>(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(string s in subs)
|
foreach(var s in subs)
|
||||||
{
|
{
|
||||||
var request = new YouTubeService(new BaseClientService.Initializer()
|
var request = Service.Search.List("snippet");
|
||||||
{
|
|
||||||
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
|
||||||
ApplicationName = "FoxTube"
|
|
||||||
}).Activities.List("snippet");
|
|
||||||
request.PublishedAfter = lastCheck;
|
request.PublishedAfter = lastCheck;
|
||||||
request.ChannelId = s;
|
request.ChannelId = s.Key;
|
||||||
request.MaxResults = 10;
|
request.Type = "video";
|
||||||
var response = await request.ExecuteAsync();
|
var response = await request.ExecuteAsync();
|
||||||
|
|
||||||
if(response.Items.Count > 0)
|
if(response.Items.Count > 0)
|
||||||
foreach (Activity a in response.Items)
|
foreach (var a in response.Items)
|
||||||
{
|
Notifications.Add(new Notification("video", a.Id.VideoId,
|
||||||
if(a.Snippet.Type == "upload")
|
a.Snippet.ChannelTitle,
|
||||||
}
|
a.Snippet.Title,
|
||||||
|
a.Snippet.PublishedAt.Value,
|
||||||
|
a.Snippet.Thumbnails.Standard.Url,
|
||||||
|
s.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,11 +119,12 @@ namespace FoxTube.Background
|
|||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.Load(XmlReader.Create("http://foxgame.hol.es/ftp.xml"));
|
doc.Load(XmlReader.Create("http://foxgame.hol.es/ftp.xml"));
|
||||||
if ((XmlConvert.ToDateTime((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), XmlDateTimeSerializationMode.Utc) - lastCheck.ToUniversalTime()).TotalSeconds > 0)
|
if ((XmlConvert.ToDateTime((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), XmlDateTimeSerializationMode.Utc) - lastCheck.ToUniversalTime()).TotalSeconds > 0)
|
||||||
Add(new Notification(NotificationType.Internal,
|
Notifications.Add(new Notification("internal", (doc["posts"].FirstChild as XmlElement).GetAttribute("id"),
|
||||||
doc["posts"].FirstChild["notificationHeader"].InnerText,
|
doc["posts"].FirstChild["notificationHeader"].InnerText,
|
||||||
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.Local), (doc["posts"].FirstChild as XmlElement).GetAttribute("image")));
|
XmlDateTimeSerializationMode.Unspecified),
|
||||||
|
(doc["posts"].FirstChild as XmlElement).GetAttribute("image")));
|
||||||
|
|
||||||
return doc.InnerXml;
|
return doc.InnerXml;
|
||||||
}
|
}
|
||||||
@@ -121,9 +134,29 @@ namespace FoxTube.Background
|
|||||||
ToastNotificationManager.CreateToastNotifier().Show(notification.GetToast(0));
|
ToastNotificationManager.CreateToastNotifier().Show(notification.GetToast(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Add(Notification notification)
|
void SendNSave()
|
||||||
{
|
{
|
||||||
|
foreach (Notification n in Notifications)
|
||||||
|
{
|
||||||
|
NotificationRecieved.Invoke(this, n.GetXml());
|
||||||
|
doc["history"].InnerXml += n.GetXml();
|
||||||
|
}
|
||||||
|
settings.Values.Add("notificationsHistory", doc.InnerXml);
|
||||||
|
|
||||||
|
if ((bool)settings.Values["notifications"])
|
||||||
|
foreach (Notification n in Notifications)
|
||||||
|
switch (n.Type)
|
||||||
|
{
|
||||||
|
case NotificationType.Video:
|
||||||
|
if ((bool)settings.Values["newVideoNotification"])
|
||||||
|
SendNotification(n);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NotificationType.Internal:
|
||||||
|
if ((bool)settings.Values["newmessagesNotification"])
|
||||||
|
SendNotification(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,26 +26,30 @@ namespace FoxTube.Background
|
|||||||
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 Notification(NotificationType type,
|
public Notification(string type, string id,
|
||||||
string channelName, string content, DateTime date,
|
string channelName, string content, DateTime date,
|
||||||
string thumbnailUrl, string avatarUrl = "ms-appx:///Assets/Icons/Profile.png")
|
string thumbnailUrl, string avatarUrl = "ms-appx:///Assets/Icons/Profile.png")
|
||||||
{
|
{
|
||||||
Channel = channelName;
|
Channel = channelName;
|
||||||
Content = content;
|
Content = content;
|
||||||
TimeStamp = date;
|
TimeStamp = date;
|
||||||
Type = type;
|
Type = TypeConversion(type);
|
||||||
Avatar = avatarUrl;
|
Avatar = avatarUrl;
|
||||||
Thumbnail = thumbnailUrl;
|
Thumbnail = thumbnailUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetXml()
|
public string GetXml()
|
||||||
{
|
{
|
||||||
|
return $@"<item time='{TimeStamp.ToString("YYYY-MM-DDThh:mm:ss")}' type='{TypeConversion(Type)}' id='{Id}'>
|
||||||
return string.Empty;
|
<images thumbnail='{Thumbnail}' avatar='{Avatar}'/>
|
||||||
|
<channelName>{Channel}</channelName>
|
||||||
|
<content>{Content}</content>
|
||||||
|
</item>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public UIElement GetNotification()
|
public Button GetNotification()
|
||||||
{
|
{
|
||||||
StackPanel stackPanel = new StackPanel() { Margin = new Thickness(10, 0, 0, 0) };
|
StackPanel stackPanel = new StackPanel() { Margin = new Thickness(10, 0, 0, 0) };
|
||||||
|
|
||||||
@@ -231,5 +235,35 @@ namespace FoxTube.Background
|
|||||||
|
|
||||||
return new ToastNotification(template);
|
return new ToastNotification(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string TypeConversion(NotificationType type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case NotificationType.Comment:
|
||||||
|
return "comment";
|
||||||
|
case NotificationType.Post:
|
||||||
|
return "post";
|
||||||
|
case NotificationType.Video:
|
||||||
|
return "video";
|
||||||
|
default:
|
||||||
|
return "internal";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private NotificationType TypeConversion(string type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case "comment":
|
||||||
|
return NotificationType.Comment;
|
||||||
|
case "post":
|
||||||
|
return NotificationType.Post;
|
||||||
|
case "video":
|
||||||
|
return NotificationType.Video;
|
||||||
|
default:
|
||||||
|
return NotificationType.Internal;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-36
@@ -11,48 +11,24 @@
|
|||||||
<Style TargetType="TextBlock" x:Key="ItemIcon">
|
<Style TargetType="TextBlock" x:Key="ItemIcon">
|
||||||
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
|
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
|
||||||
<Setter Property="FontSize" Value="16"/>
|
<Setter Property="FontSize" Value="16"/>
|
||||||
<Setter Property="Margin" Value="5,5,20,2"/>
|
<Setter Property="Padding" Value="5,4,17,6"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="TextBlock" x:Key="MenuItem">
|
<Style TargetType="TextBlock" x:Key="MenuItem">
|
||||||
<Setter Property="Foreground" Value="Black"/>
|
<Setter Property="Margin" Value="5,0,0,0"/>
|
||||||
<Setter Property="Margin" Value="0,2,0,0"/>
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="ToggleButton" x:Key="hPanel">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ToggleButton">
|
||||||
|
<ToggleButton />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="HyperlinkButton" x:Key="Pivot">
|
<Style TargetType="HyperlinkButton" x:Key="Pivot">
|
||||||
|
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<!--<Style x:Key="MenuItemStyle1" TargetType="ListViewItem">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate TargetType="ListViewItem">
|
|
||||||
<ListViewItemPresenter
|
|
||||||
SelectedBackground="Pink"
|
|
||||||
SelectedPointerOverBackground="LightPink"
|
|
||||||
PressedBackground="Red"
|
|
||||||
SelectedPressedBackground="Red"
|
|
||||||
ContentMargin="{TemplateBinding Padding}"
|
|
||||||
ContentTransitions="{TemplateBinding ContentTransitions}"
|
|
||||||
SelectionCheckMarkVisualEnabled="True"
|
|
||||||
CheckBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
|
|
||||||
CheckBoxBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
|
|
||||||
DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
|
|
||||||
DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
|
|
||||||
FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}"
|
|
||||||
FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}"
|
|
||||||
PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
|
|
||||||
PointerOverBackground="{ThemeResource SystemControlHighlightListLowBrush}"
|
|
||||||
PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
|
|
||||||
SelectedForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
|
|
||||||
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
|
|
||||||
DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
|
|
||||||
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
|
|
||||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
||||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
||||||
CheckMode="Inline"/>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>-->
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
|||||||
@@ -1,171 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Windows.Data.Xml.Dom;
|
|
||||||
using Windows.UI;
|
|
||||||
using Windows.UI.Notifications;
|
|
||||||
using Windows.UI.Xaml;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Media;
|
|
||||||
using Windows.UI.Xaml.Media.Imaging;
|
|
||||||
|
|
||||||
namespace FoxTube
|
|
||||||
{
|
|
||||||
public enum NotificationType
|
|
||||||
{
|
|
||||||
Video, Comment, Post, Internal
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Notification
|
|
||||||
{
|
|
||||||
public string Channel { get; set; }
|
|
||||||
public string Content { get; set; }
|
|
||||||
public DateTime TimeStamp { get; set; }
|
|
||||||
public NotificationType Type { get; set; }
|
|
||||||
public string Avatar { get; set; }
|
|
||||||
public string Thumbnail { get; set; }
|
|
||||||
|
|
||||||
public Notification(NotificationType type,
|
|
||||||
string channelName, string content, DateTime date,
|
|
||||||
string thumbnailUrl, string avatarUrl = "ms-appx:///Assets/Icons/Profile.png")
|
|
||||||
{
|
|
||||||
Channel = channelName;
|
|
||||||
Content = content;
|
|
||||||
TimeStamp = date;
|
|
||||||
Type = type;
|
|
||||||
Avatar = avatarUrl;
|
|
||||||
Thumbnail = thumbnailUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UIElement GetNotification()
|
|
||||||
{
|
|
||||||
StackPanel stackPanel = new StackPanel() { Margin = new Thickness(10, 0, 0, 0) };
|
|
||||||
|
|
||||||
//Channel
|
|
||||||
switch (Type)
|
|
||||||
{
|
|
||||||
case NotificationType.Comment:
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
FontSize = 14,
|
|
||||||
FontStyle = Windows.UI.Text.FontStyle.Italic,
|
|
||||||
Foreground = new SolidColorBrush(Colors.Gray),
|
|
||||||
Text = string.Format("{0} replied to your comment", Channel)
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NotificationType.Internal:
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
FontSize = 14,
|
|
||||||
FontStyle = Windows.UI.Text.FontStyle.Italic,
|
|
||||||
Foreground = new SolidColorBrush(Colors.Gray),
|
|
||||||
Text = Channel
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NotificationType.Post:
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
FontSize = 14,
|
|
||||||
FontStyle = Windows.UI.Text.FontStyle.Italic,
|
|
||||||
Foreground = new SolidColorBrush(Colors.Gray),
|
|
||||||
Text = string.Format("{0} published new post", Channel)
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NotificationType.Video:
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
FontSize = 14,
|
|
||||||
FontStyle = Windows.UI.Text.FontStyle.Italic,
|
|
||||||
Foreground = new SolidColorBrush(Colors.Gray),
|
|
||||||
Text = string.Format("{0} uploaded new video", Channel)
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Content
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
TextWrapping = TextWrapping.WrapWholeWords,
|
|
||||||
Text = Content,
|
|
||||||
});
|
|
||||||
//Time
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
FontSize = 13,
|
|
||||||
Foreground = new SolidColorBrush(Colors.Gray),
|
|
||||||
Text = TimeStamp.ToString()
|
|
||||||
});
|
|
||||||
PersonPicture avatar = new PersonPicture()
|
|
||||||
{
|
|
||||||
Height = 50,
|
|
||||||
VerticalAlignment = VerticalAlignment.Top,
|
|
||||||
ProfilePicture = string.IsNullOrWhiteSpace(Avatar) ? null : new BitmapImage(new Uri(Avatar))
|
|
||||||
};
|
|
||||||
|
|
||||||
Grid grid = new Grid();
|
|
||||||
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50) });
|
|
||||||
grid.ColumnDefinitions.Add(new ColumnDefinition());
|
|
||||||
|
|
||||||
grid.Children.Add(avatar);
|
|
||||||
Grid.SetColumn(stackPanel, 1);
|
|
||||||
grid.Children.Add(stackPanel);
|
|
||||||
|
|
||||||
Button item = new Button()
|
|
||||||
{
|
|
||||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
|
||||||
HorizontalContentAlignment = HorizontalAlignment.Left,
|
|
||||||
Background = new SolidColorBrush(Colors.Transparent),
|
|
||||||
Content = grid
|
|
||||||
};
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ToastNotification GetToast(int assignedId)
|
|
||||||
{
|
|
||||||
System.Xml.XmlDocument template = new System.Xml.XmlDocument();
|
|
||||||
switch(Type)
|
|
||||||
{
|
|
||||||
case NotificationType.Comment:
|
|
||||||
template.Load("ms-appx:///Assets/Notifications/Comment.xml");
|
|
||||||
template["toast"]["visual"]["binding"]["image"].SetAttribute("src", Avatar);
|
|
||||||
template["toast"]["visual"]["binding"].ChildNodes[1].InnerText = string.Format("{0} posted a new comment", Channel);
|
|
||||||
template["toast"]["visual"]["binding"].LastChild.InnerText = Content;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NotificationType.Video:
|
|
||||||
template.Load("ms-appx:///Assets/Notifications/Video.xml");
|
|
||||||
(template["toast"]["visual"]["binding"].FirstChild as System.Xml.XmlElement).SetAttribute("src", Avatar);
|
|
||||||
template["toast"]["visual"]["binding"].ChildNodes[1].InnerText = string.Format("{0} uploaded a new video", Channel);
|
|
||||||
template["toast"]["visual"]["binding"].ChildNodes[2].InnerText = Content;
|
|
||||||
(template["toast"]["visual"]["binding"].LastChild as System.Xml.XmlElement).SetAttribute("src", Thumbnail);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NotificationType.Internal:
|
|
||||||
template.Load("ms-appx:///Assets/Notifications/Internal.xml");
|
|
||||||
if(!string.IsNullOrWhiteSpace(Thumbnail))
|
|
||||||
(template["toast"]["visual"]["binding"].FirstChild as System.Xml.XmlElement).SetAttribute("src", Avatar);
|
|
||||||
template["toast"]["visual"]["binding"].LastChild.InnerText = Channel;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NotificationType.Post:
|
|
||||||
template.Load("ms-appx:///Assets/Notifications/Video.xml");
|
|
||||||
(template["toast"]["visual"]["binding"].FirstChild as System.Xml.XmlElement).SetAttribute("src", Thumbnail);
|
|
||||||
(template["toast"]["visual"]["binding"].ChildNodes[1] as System.Xml.XmlElement).SetAttribute("src", Avatar);
|
|
||||||
template["toast"]["visual"]["binding"].ChildNodes[2].InnerText = string.Format("{0} published a new post", Channel);
|
|
||||||
template["toast"]["visual"]["binding"].ChildNodes[3].InnerText = Content;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
XmlDocument toastXml = new XmlDocument();
|
|
||||||
toastXml.LoadXml(template.InnerXml);
|
|
||||||
|
|
||||||
return new ToastNotification(toastXml);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,9 +28,9 @@ namespace FoxTube
|
|||||||
public static bool IsAuthorized => Vault.IsLoged;
|
public static bool IsAuthorized => Vault.IsLoged;
|
||||||
|
|
||||||
public static Google.Apis.YouTube.v3.Data.Channel UserChannel => Methods.MainPage.Vault.channel;
|
public static Google.Apis.YouTube.v3.Data.Channel UserChannel => Methods.MainPage.Vault.channel;
|
||||||
public static List<KeyValuePair<string, string>> WatchLater => Methods.MainPage.Vault.later;
|
public static List<PlaylistItem> WatchLater => Methods.MainPage.Vault.later;
|
||||||
public static List<string> UserHistory => Methods.MainPage.Vault.history;
|
public static List<PlaylistItem> UserHistory => Methods.MainPage.Vault.history;
|
||||||
public static List<string> Subscriptions => Methods.MainPage.Vault.subs;
|
public static List<Subscription> Subscriptions => Methods.MainPage.Vault.subs;
|
||||||
|
|
||||||
public static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer()
|
public static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer()
|
||||||
{
|
{
|
||||||
@@ -48,9 +48,9 @@ namespace FoxTube
|
|||||||
#region Object containers
|
#region Object containers
|
||||||
public bool IsLoged = false;
|
public bool IsLoged = false;
|
||||||
public string userId;
|
public string userId;
|
||||||
public List<string> history = new List<string>();
|
public List<PlaylistItem> history = new List<PlaylistItem>();
|
||||||
public List<string> subs = new List<string>();
|
public List<Subscription> subs = new List<Subscription>();
|
||||||
public List<KeyValuePair<string, string>> later = new List<KeyValuePair<string, string>>();
|
public List<PlaylistItem> later = new List<PlaylistItem>();
|
||||||
public Google.Apis.YouTube.v3.Data.Channel channel;
|
public Google.Apis.YouTube.v3.Data.Channel channel;
|
||||||
public UserCredential Credential;
|
public UserCredential Credential;
|
||||||
public event EventHandler AuthorizationStateChanged;
|
public event EventHandler AuthorizationStateChanged;
|
||||||
@@ -66,58 +66,60 @@ namespace FoxTube
|
|||||||
settings.Values.Add("authorized", true);
|
settings.Values.Add("authorized", true);
|
||||||
else settings.Values["authorized"] = true;
|
else settings.Values["authorized"] = true;
|
||||||
IsLoged = true;
|
IsLoged = true;
|
||||||
AuthorizationStateChanged.Invoke(this, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
var request = Service.Channels.List("snippet,contentDetails");
|
var request = Service.Channels.List("snippet,contentDetails");
|
||||||
request.Mine = true;
|
request.Mine = true;
|
||||||
channel = (await request.ExecuteAsync()).Items[0];
|
channel = (await request.ExecuteAsync()).Items[0];
|
||||||
userId = channel.Id;
|
userId = channel.Id;
|
||||||
|
|
||||||
var historyRequest = Service.PlaylistItems.List("snippet");
|
PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet");
|
||||||
historyRequest.PlaylistId = channel.ContentDetails.RelatedPlaylists.WatchHistory;
|
playlistRequest.PlaylistId = channel.ContentDetails.RelatedPlaylists.WatchHistory;
|
||||||
historyRequest.MaxResults = 50;
|
playlistRequest.MaxResults = 50;
|
||||||
var response = await historyRequest.ExecuteAsync();
|
PlaylistItemListResponse playlistResponse = await playlistRequest.ExecuteAsync();
|
||||||
history.Clear();
|
history.Clear();
|
||||||
foreach (PlaylistItem i in response.Items)
|
foreach (PlaylistItem i in playlistResponse.Items)
|
||||||
history.Add(i.Snippet.ResourceId.VideoId);
|
history.Add(i);
|
||||||
|
|
||||||
var laterRequest = Service.PlaylistItems.List("snippet");
|
playlistRequest = Service.PlaylistItems.List("snippet");
|
||||||
laterRequest.PlaylistId = channel.ContentDetails.RelatedPlaylists.WatchLater;
|
playlistRequest.PlaylistId = channel.ContentDetails.RelatedPlaylists.WatchLater;
|
||||||
laterRequest.MaxResults = 50;
|
playlistRequest.MaxResults = 50;
|
||||||
var laterResponse = await laterRequest.ExecuteAsync();
|
playlistResponse = await playlistRequest.ExecuteAsync();
|
||||||
later.Clear();
|
later.Clear();
|
||||||
|
|
||||||
foreach (PlaylistItem i in laterResponse.Items)
|
foreach (PlaylistItem i in playlistResponse.Items)
|
||||||
later.Add(new KeyValuePair<string, string>(i.Id, i.Snippet.ResourceId.VideoId));
|
later.Add(i);
|
||||||
|
|
||||||
string nextToken = laterResponse.NextPageToken;
|
string nextToken = playlistResponse.NextPageToken;
|
||||||
while (nextToken != null)
|
while (nextToken != null)
|
||||||
{
|
{
|
||||||
laterRequest.PageToken = nextToken;
|
playlistRequest.PageToken = nextToken;
|
||||||
laterResponse = await laterRequest.ExecuteAsync();
|
playlistResponse = await playlistRequest.ExecuteAsync();
|
||||||
foreach (PlaylistItem i in laterResponse.Items)
|
foreach (PlaylistItem i in playlistResponse.Items)
|
||||||
later.Add(new KeyValuePair<string, string>(i.Id, i.Snippet.ResourceId.VideoId));
|
later.Add(i);
|
||||||
|
|
||||||
nextToken = laterResponse.NextPageToken;
|
nextToken = playlistResponse.NextPageToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscriptionsResource.ListRequest subRequest = SecretsVault.Service.Subscriptions.List("snippet");
|
SubscriptionsResource.ListRequest subRequest = Service.Subscriptions.List("snippet");
|
||||||
subRequest.Mine = true;
|
subRequest.Mine = true;
|
||||||
subRequest.MaxResults = 50;
|
subRequest.MaxResults = 50;
|
||||||
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
subRequest.Order = SubscriptionsResource.ListRequest.OrderEnum.Relevance;
|
||||||
subs.Clear();
|
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
||||||
|
subs.Clear();
|
||||||
|
|
||||||
foreach (Subscription s in subResponse.Items)
|
|
||||||
subs.Add(s.Snippet.ResourceId.ChannelId);
|
|
||||||
|
|
||||||
nextToken = subResponse.NextPageToken;
|
|
||||||
while(nextToken != null)
|
|
||||||
{
|
|
||||||
subRequest.PageToken = nextToken;
|
|
||||||
subResponse = await subRequest.ExecuteAsync();
|
|
||||||
foreach (Subscription s in subResponse.Items)
|
foreach (Subscription s in subResponse.Items)
|
||||||
subs.Add(s.Snippet.ResourceId.ChannelId);
|
subs.Add(s);
|
||||||
|
|
||||||
|
nextToken = subResponse.NextPageToken;
|
||||||
|
while(nextToken != null)
|
||||||
|
{
|
||||||
|
subRequest.PageToken = nextToken;
|
||||||
|
subResponse = await subRequest.ExecuteAsync();
|
||||||
|
foreach (Subscription s in subResponse.Items)
|
||||||
|
subs.Add(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthorizationStateChanged.Invoke(this, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
using Microsoft.Toolkit.Uwp.Notifications;
|
using FoxTube.Background;
|
||||||
|
using Microsoft.Toolkit.Uwp.Notifications;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
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;
|
||||||
|
using System.Xml;
|
||||||
using Windows.Foundation;
|
using Windows.Foundation;
|
||||||
using Windows.Foundation.Collections;
|
using Windows.Foundation.Collections;
|
||||||
|
using Windows.Storage;
|
||||||
using Windows.UI;
|
using Windows.UI;
|
||||||
using Windows.UI.Notifications;
|
|
||||||
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,9 +27,50 @@ namespace FoxTube
|
|||||||
{
|
{
|
||||||
List<Notification> notifications = new List<Notification>();
|
List<Notification> notifications = new List<Notification>();
|
||||||
|
|
||||||
|
private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
public NotificationsCenter()
|
public NotificationsCenter()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
|
|
||||||
|
if (settings.Values["notificationsHistory"] != null)
|
||||||
|
{
|
||||||
|
doc.LoadXml(settings.Values["notificationsHistory"] as string);
|
||||||
|
foreach(XmlElement n in doc["history"].ChildNodes)
|
||||||
|
{
|
||||||
|
AddNotification(new Notification(
|
||||||
|
n.GetAttribute("type"),
|
||||||
|
n.GetAttribute("id"),
|
||||||
|
n["channelName"].InnerText,
|
||||||
|
n["content"].InnerText,
|
||||||
|
XmlConvert.ToDateTime(n.GetAttribute("time"), "YYYY-MM-DDThh:mm:ss"),
|
||||||
|
n["images"].GetAttribute("thumbnail"),
|
||||||
|
n["images"].GetAttribute("avatar")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
|
||||||
|
doc.AppendChild(doc.CreateElement("history"));
|
||||||
|
settings.Values.Add("notificationsHistory", doc.InnerXml);
|
||||||
|
}
|
||||||
|
|
||||||
|
BackgroundProcessor.NotificationRecieved += NewNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NewNotification(object sender, string xml)
|
||||||
|
{
|
||||||
|
XmlElement n = new XmlDocument().CreateElement("item");
|
||||||
|
AddNotification(new Notification(
|
||||||
|
n.GetAttribute("type"),
|
||||||
|
n.GetAttribute("id"),
|
||||||
|
n["channelName"].InnerText,
|
||||||
|
n["content"].InnerText,
|
||||||
|
XmlConvert.ToDateTime(n.GetAttribute("time"), "YYYY-MM-DDThh:mm:ss"),
|
||||||
|
n["images"].GetAttribute("thumbnail"),
|
||||||
|
n["images"].GetAttribute("avatar")
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clear_Click(object sender, RoutedEventArgs e)
|
private void clear_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -40,122 +83,34 @@ namespace FoxTube
|
|||||||
|
|
||||||
private void close_Click(object sender, RoutedEventArgs e)
|
private void close_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Methods.MainPage.ClosePopups();
|
Methods.MainPage.notificationMenu_Click(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddNotification(Notification notification)
|
||||||
public void AddNotification(Notification notification, bool needNotify = true)
|
|
||||||
{
|
{
|
||||||
notifications.Add(notification);
|
notifications.Add(notification);
|
||||||
Methods.MainPage.GotNotification();
|
Methods.MainPage.GotNotification();
|
||||||
noNotifications.Visibility = Visibility.Collapsed;
|
noNotifications.Visibility = Visibility.Collapsed;
|
||||||
clear.Visibility = Visibility.Visible;
|
clear.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
StackPanel stackPanel = new StackPanel() { Margin = new Thickness(10, 0, 0, 0) };
|
Button item = notification.GetNotification();
|
||||||
//Channel
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
FontSize = 14,
|
|
||||||
FontStyle = Windows.UI.Text.FontStyle.Italic,
|
|
||||||
Foreground = new SolidColorBrush(Colors.Gray),
|
|
||||||
Text = notification.Header
|
|
||||||
});
|
|
||||||
//Content
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
TextWrapping = TextWrapping.WrapWholeWords,
|
|
||||||
Text = notification.message,
|
|
||||||
});
|
|
||||||
//Time
|
|
||||||
stackPanel.Children.Add(new TextBlock()
|
|
||||||
{
|
|
||||||
FontSize = 13,
|
|
||||||
Foreground = new SolidColorBrush(Colors.Gray),
|
|
||||||
Text = notification.returnTimecode()
|
|
||||||
});
|
|
||||||
PersonPicture avatar = new PersonPicture()
|
|
||||||
{
|
|
||||||
Height = 50,
|
|
||||||
VerticalAlignment = VerticalAlignment.Top
|
|
||||||
};
|
|
||||||
|
|
||||||
Grid grid = new Grid();
|
|
||||||
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50) });
|
|
||||||
grid.ColumnDefinitions.Add(new ColumnDefinition());
|
|
||||||
|
|
||||||
grid.Children.Add(avatar);
|
|
||||||
Grid.SetColumn(stackPanel, 1);
|
|
||||||
grid.Children.Add(stackPanel);
|
|
||||||
|
|
||||||
Button item = new Button()
|
|
||||||
{
|
|
||||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
|
||||||
HorizontalContentAlignment = HorizontalAlignment.Left,
|
|
||||||
Background = new SolidColorBrush(Colors.Transparent),
|
|
||||||
Content = grid
|
|
||||||
};
|
|
||||||
item.Click += Notification_Click;
|
item.Click += Notification_Click;
|
||||||
|
|
||||||
array.Children.Add(item);
|
array.Children.Add(item);
|
||||||
|
|
||||||
//Sending notification
|
|
||||||
if (needNotify)
|
|
||||||
{
|
|
||||||
if (notification.Type == NotificationType.Update)
|
|
||||||
{
|
|
||||||
ToastContent toast = new ToastContent()
|
|
||||||
{
|
|
||||||
Visual = new ToastVisual()
|
|
||||||
{
|
|
||||||
BindingGeneric = new ToastBindingGeneric()
|
|
||||||
{
|
|
||||||
Children =
|
|
||||||
{
|
|
||||||
new AdaptiveText()
|
|
||||||
{
|
|
||||||
Text = notification.Header,
|
|
||||||
HintMaxLines = 2
|
|
||||||
},
|
|
||||||
new AdaptiveText()
|
|
||||||
{
|
|
||||||
Text = notification.message
|
|
||||||
}
|
|
||||||
},
|
|
||||||
HeroImage = new ToastGenericHeroImage()
|
|
||||||
{
|
|
||||||
Source = notification.Thumbnail
|
|
||||||
},
|
|
||||||
AppLogoOverride = new ToastGenericAppLogo()
|
|
||||||
{
|
|
||||||
Source = notification.Avatar,
|
|
||||||
HintCrop = ToastGenericAppLogoCrop.Circle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Actions = new ToastActionsCustom()
|
|
||||||
{
|
|
||||||
Buttons =
|
|
||||||
{
|
|
||||||
new ToastButton("View full post", "action=viewupdatenotification")
|
|
||||||
{
|
|
||||||
ActivationType = ToastActivationType.Foreground
|
|
||||||
},
|
|
||||||
new ToastButton("Manage notifications", "action=notificationsettings")
|
|
||||||
{
|
|
||||||
ActivationType = ToastActivationType.Foreground
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Launch = "action=viewupdatenotification"
|
|
||||||
};
|
|
||||||
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toast.GetXml()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Notification_Click(object sender, RoutedEventArgs e)
|
private void Notification_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Cliked notification index" + ((sender as Button).Parent as StackPanel).Children.IndexOf(sender as Button));
|
Notification n = notifications[((sender as Button).Parent as StackPanel).Children.IndexOf(sender as Button)];
|
||||||
|
switch(n.Type)
|
||||||
|
{
|
||||||
|
case NotificationType.Internal:
|
||||||
|
Methods.MainPage.GoToDeveloper(n.Id);
|
||||||
|
break;
|
||||||
|
case NotificationType.Video:
|
||||||
|
Methods.MainPage.GoToVideo(n.Id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,6 @@
|
|||||||
<Compile Include="Pages\MainPage.xaml.cs">
|
<Compile Include="Pages\MainPage.xaml.cs">
|
||||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Classes\Notification.cs" />
|
|
||||||
<Compile Include="Controls\NotificationsCenter.xaml.cs">
|
<Compile Include="Controls\NotificationsCenter.xaml.cs">
|
||||||
<DependentUpon>NotificationsCenter.xaml</DependentUpon>
|
<DependentUpon>NotificationsCenter.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -238,6 +237,7 @@
|
|||||||
<Content Include="Notifications\Internal.xml">
|
<Content Include="Notifications\Internal.xml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Notifications\NotificationsHistorySample.xml" />
|
||||||
<Content Include="Notifications\Post.xml">
|
<Content Include="Notifications\Post.xml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<history>
|
||||||
|
<item time="YYYY-MM-DDThh:mm:ss" type="" id="">
|
||||||
|
<images thumbnail="" avatar=""/>
|
||||||
|
<channelName></channelName>
|
||||||
|
<content></content>
|
||||||
|
</item>
|
||||||
|
</history>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<posts>
|
<posts>
|
||||||
<post time="YYYY-MM-DDThh:mm:ss-03" image="http://foxtube.hol.es/foxtube/FILE_NAME.png Hero image (not implemented yet)">
|
<post time="YYYY-MM-DDThh:mm:ss-03" image="http://foxtube.hol.es/foxtube/FILE_NAME.png Hero image (not implemented yet)" id="0">
|
||||||
<notificationHeader>Short headline for toast notifications</notificationHeader>
|
<notificationHeader>Short headline for toast notifications</notificationHeader>
|
||||||
<header>Main headline for full post</header>
|
<header>Main headline for full post</header>
|
||||||
<content>Announcement body (beware of special characters)</content>
|
<content>Announcement body (beware of special characters)</content>
|
||||||
|
|||||||
+110
-106
@@ -52,9 +52,9 @@
|
|||||||
<PersonPicture Width="30"/>
|
<PersonPicture Width="30"/>
|
||||||
<Button.Flyout>
|
<Button.Flyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuFlyoutItem Text="My channel"/>
|
<MenuFlyoutItem Text="My channel" Name="myChannel" Click="myChannel_Click"/>
|
||||||
<MenuFlyoutSeparator/>
|
<MenuFlyoutSeparator/>
|
||||||
<MenuFlyoutItem Text="Log out"/>
|
<MenuFlyoutItem Text="Log out" Name="logout" Click="logout_Click"/>
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</Button.Flyout>
|
</Button.Flyout>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -107,136 +107,140 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
<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>
|
||||||
<RelativePanel>
|
<Grid>
|
||||||
<ListBox SelectionChanged="ListBox_SelectionChanged" Name="topHamburger">
|
<ScrollViewer>
|
||||||
<ListBoxItem Name="homeMenu" IsSelected="True">
|
<StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
<ListBox Name="mainList" SelectionChanged="HamburgerSelectionChanged">
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<ListBoxItem Name="toHome" IsSelected="True">
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Home"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
</StackPanel>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
</ListBoxItem>
|
<TextBlock Style="{StaticResource MenuItem}" Text="Home"/>
|
||||||
<ListBoxItem Name="historyMenu" Visibility="Collapsed">
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
</ListBoxItem>
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<ListBoxItem Name="toHistory" Visibility="Visible">
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="History"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
</StackPanel>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
</ListBoxItem>
|
<TextBlock Style="{StaticResource MenuItem}" Text="History"/>
|
||||||
<ListBoxItem Name="likedMenu" Visibility="Collapsed">
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
</ListBoxItem>
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<ListBoxItem Name="toLiked" Visibility="Visible">
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Liked videos"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
</StackPanel>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
</ListBoxItem>
|
<TextBlock Style="{StaticResource MenuItem}" Text="Liked videos"/>
|
||||||
<ListBoxItem Name="watchLaterMenu" Visibility="Collapsed">
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
</ListBoxItem>
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<ListBoxItem Name="toLater" Visibility="Visible">
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Watch later"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
</StackPanel>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
</ListBoxItem>
|
<TextBlock Style="{StaticResource MenuItem}" Text="Watch later"/>
|
||||||
<ListBoxItem Name="subscriptionsMenu" Visibility="Collapsed">
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
</ListBoxItem>
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<ListBoxItem Name="toSubscriptions" Visibility="Visible">
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Subscriptions"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
</StackPanel>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
</ListBoxItem>
|
<TextBlock Style="{StaticResource MenuItem}" Text="Subscriptions"/>
|
||||||
</ListBox>
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
<ListBoxItem Name="toDownloads">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="Downloads"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
<ListBox RelativePanel.Below="topHamburger" Name="subscriptionsHamburger" Visibility="Visible">
|
<ListBox Name="subscriptionsList" Visibility="Collapsed" SelectionChanged="HamburgerSelectionChanged">
|
||||||
<ListBoxItem Name="subscriptionsTitle" Height="17" Margin="0" Padding="5, 0, 5, 0" IsEnabled="False">
|
<ListBoxItem IsEnabled="False" Height="17" Padding="0,0,5,0">
|
||||||
<StackPanel Orientation="Horizontal" Margin="0" Padding="0, 0, 0, 0">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Name="subsMenuTitle" Text="Subscriptions" Foreground="Gray" FontSize="12" Margin="0" Padding="0, 0, 5, 0"/>
|
<TextBlock Name="subsTitle" Text="Subscriptions" FontSize="12" Padding="5,0,5,0" Visibility="Visible"/>
|
||||||
<Line Name="subsMenuStroke" X1="0" Y1="10" X2="300" Y2="10" Stroke="Gray" StrokeThickness="2"/>
|
<Line X2="300" Stroke="Gray" VerticalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
<ListBoxItem IsEnabled="False" Name="subsLogErr" Visibility="Visible" HorizontalContentAlignment="Center">
|
</ListBox>
|
||||||
<TextBlock FontFamily="Default, Segoe MDL2 Assets" Text="Press  and add an account to see your featured channels and another useful stuff here" HorizontalTextAlignment="Center" Width="225" Foreground="Gray" TextWrapping="WrapWholeWords"/>
|
|
||||||
</ListBoxItem>
|
|
||||||
<ListBoxItem IsEnabled="False" Name="subsNull" Visibility="Collapsed" HorizontalContentAlignment="Center" Padding="0">
|
|
||||||
<TextBlock Text="You don't have any subscriptions" Width="225" Foreground="Gray" TextWrapping="WrapWholeWords"/>
|
|
||||||
</ListBoxItem>
|
|
||||||
</ListBox>
|
|
||||||
|
|
||||||
<ListBox RelativePanel.Below="subscriptionsHamburger" Name="categoriesHamburger" Visibility="Visible">
|
<ListBox Name="categoriesList" SelectionChanged="HamburgerSelectionChanged">
|
||||||
<ListBoxItem Name="categoriesTitle" Height="17" Margin="0" Padding="5, 0, 5, 0" IsEnabled="False">
|
<ListBoxItem IsEnabled="False" Height="17" Padding="0,0,5,0">
|
||||||
<StackPanel Orientation="Horizontal" Margin="0" Padding="0, 0, 0, 0">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Name="catMenuTitle" Text="Featured" Foreground="Gray" FontSize="12" Margin="0" Padding="0, 0, 5, 0"/>
|
<TextBlock Name="catTitle" Text="Featured" FontSize="12" Padding="5,0,5,0"/>
|
||||||
<Line Name="catMenuStroke" X1="0" Y1="10" X2="300" Y2="10" Stroke="Gray" StrokeThickness="2"/>
|
<Line X2="300" Stroke="Gray" VerticalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
<ListBoxItem>
|
|
||||||
<StackPanel Orientation="Horizontal" Name="musicMenu">
|
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Music"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ListBoxItem>
|
|
||||||
<ListBoxItem>
|
|
||||||
<StackPanel Orientation="Horizontal" Name="sportMenu">
|
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Sports"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ListBoxItem>
|
|
||||||
<ListBoxItem>
|
|
||||||
<StackPanel Name="gamingMenu" Orientation="Horizontal">
|
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Gaming"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ListBoxItem>
|
|
||||||
<ListBoxItem>
|
|
||||||
<StackPanel Orientation="Horizontal" Name="newsMenu">
|
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="News"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ListBoxItem>
|
|
||||||
<ListBoxItem>
|
|
||||||
<StackPanel Orientation="Horizontal" Name="liveMenu">
|
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Live"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ListBoxItem>
|
|
||||||
<ListBoxItem>
|
|
||||||
<StackPanel Orientation="Horizontal" Name="spotlightMenu">
|
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Spotlight"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ListBoxItem>
|
|
||||||
<ListBoxItem>
|
|
||||||
<StackPanel Orientation="Horizontal" Name="TSZMenu">
|
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="360° Video"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ListBoxItem>
|
|
||||||
</ListBox>
|
|
||||||
|
|
||||||
<ListBox RelativePanel.AlignBottomWithPanel="True" SelectionChanged="bottomHaburgerSelectionChanged" Name="bottomHaburger">
|
<ListBoxItem>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="Music"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
<ListBoxItem>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="Sports"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
<ListBoxItem>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="Gaming"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
<ListBoxItem>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="News"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
<ListBoxItem>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="Live"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
<ListBoxItem>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="Spotlight"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
<ListBoxItem>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
|
<TextBlock Style="{StaticResource MenuItem}" Text="360° Video"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListBoxItem>
|
||||||
|
</ListBox>
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
<ListBox VerticalAlignment="Bottom" Name="serviceList" SelectionChanged="HamburgerSelectionChanged">
|
||||||
<ListBoxItem Padding="0" IsEnabled="False">
|
<ListBoxItem Padding="0" IsEnabled="False">
|
||||||
<Line X1="0" X2="250" Stroke="Black" StrokeThickness="1"/>
|
<Line X2="250" Stroke="Gray"/>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
<ListBoxItem Name="channelMenu" Visibility="Collapsed">
|
<ListBoxItem Name="toChannel">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="My channel"/>
|
<TextBlock Style="{StaticResource MenuItem}" Text="My channel"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
<ListBoxItem Name="noadsMenu" Visibility="Visible">
|
<ListBoxItem Name="toRemoveAds">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Remove ads (2$)"/>
|
<TextBlock Style="{StaticResource MenuItem}" Text="Remove ads (2$)"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
<ListBoxItem Name="settingsMenu">
|
<ListBoxItem Name="toSettings">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
<TextBlock Style="{StaticResource ItemIcon}" Text=""/>
|
||||||
<TextBlock Style="{StaticResource MenuItem}" Text="Settings"/>
|
<TextBlock Style="{StaticResource MenuItem}" Text="Settings"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
</RelativePanel>
|
</Grid>
|
||||||
</SplitView.Pane>
|
</SplitView.Pane>
|
||||||
<SplitView.Content>
|
<SplitView.Content>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Frame Name="content"/>
|
<Frame Name="content"/>
|
||||||
<Frame Name="popupPlaceholder"/>
|
|
||||||
<Frame Name="videoPlaceholder"/>
|
<Frame Name="videoPlaceholder"/>
|
||||||
|
<Frame Name="popupPlaceholder" Visibility="Collapsed"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</SplitView.Content>
|
</SplitView.Content>
|
||||||
</SplitView>
|
</SplitView>
|
||||||
|
|||||||
+183
-141
@@ -37,6 +37,7 @@ using Windows.UI.Xaml.Documents;
|
|||||||
using Google.Apis.Oauth2.v2;
|
using Google.Apis.Oauth2.v2;
|
||||||
using Google.Apis.Oauth2.v2.Data;
|
using Google.Apis.Oauth2.v2.Data;
|
||||||
using FoxTube.Controls;
|
using FoxTube.Controls;
|
||||||
|
using FoxTube.Pages;
|
||||||
|
|
||||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||||
|
|
||||||
@@ -56,8 +57,6 @@ namespace FoxTube
|
|||||||
RightPaneState paneState = RightPaneState.Full;
|
RightPaneState paneState = RightPaneState.Full;
|
||||||
bool isForcedCollapsed = false;
|
bool isForcedCollapsed = false;
|
||||||
|
|
||||||
List<Subscription> subscriptions = new List<Subscription>();
|
|
||||||
|
|
||||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||||
|
|
||||||
NotificationsCenter notificationsCenter = new NotificationsCenter();
|
NotificationsCenter notificationsCenter = new NotificationsCenter();
|
||||||
@@ -94,48 +93,40 @@ namespace FoxTube
|
|||||||
settings.Values.Add("defaultDownload", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\DownloadedVideos");
|
settings.Values.Add("defaultDownload", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\DownloadedVideos");
|
||||||
|
|
||||||
content.Navigate(typeof(Home));
|
content.Navigate(typeof(Home));
|
||||||
|
notificationPane.Child = notificationsCenter;
|
||||||
|
|
||||||
Vault.AuthorizationStateChanged += Vault_AuthorizationStateChanged;
|
Vault.AuthorizationStateChanged += Vault_AuthorizationStateChanged;
|
||||||
|
Vault.CheckAuthorization();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Vault_AuthorizationStateChanged(object sender, EventArgs e)
|
private void Vault_AuthorizationStateChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if(Vault.IsLoged)
|
if(Vault.IsLoged)
|
||||||
{
|
{
|
||||||
account.Visibility = Visibility.Collapsed;
|
account.Visibility = Visibility.Collapsed;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Userinfoplus info = await new Oauth2Service(new BaseClientService.Initializer()
|
ToolTipService.SetToolTip(avatar, new ToolTip() { Content = SecretsVault.UserChannel.Snippet.Title });
|
||||||
{
|
(avatar.Content as PersonPicture).ProfilePicture = new BitmapImage(new Uri(SecretsVault.UserChannel.Snippet.Thumbnails.Standard.Url));
|
||||||
HttpClientInitializer = Vault.Credential,
|
|
||||||
ApplicationName = "FoxTube",
|
|
||||||
}).Userinfo.Get().ExecuteAsync();
|
|
||||||
|
|
||||||
(avatar.Content as PersonPicture).ProfilePicture = new BitmapImage(new Uri(info.Picture));
|
|
||||||
ToolTipService.SetToolTip(avatar, new ToolTip() { Content = string.Format("{0} ({1})", info.Name, info.Email) });
|
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
avatar.Visibility = Visibility.Visible;
|
avatar.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
historyMenu.Visibility = Visibility.Visible;
|
toHistory.Visibility = Visibility.Visible;
|
||||||
likedMenu.Visibility = Visibility.Visible;
|
toLiked.Visibility = Visibility.Visible;
|
||||||
watchLaterMenu.Visibility = Visibility.Visible;
|
toLater.Visibility = Visibility.Visible;
|
||||||
subscriptionsMenu.Visibility = Visibility.Visible;
|
toSubscriptions.Visibility = Visibility.Visible;
|
||||||
subsLogErr.Visibility = Visibility.Collapsed;
|
toChannel.Visibility = Visibility.Visible;
|
||||||
channelMenu.Visibility = Visibility.Visible;
|
|
||||||
|
|
||||||
SubscriptionsResource.ListRequest request = SecretsVault.Service.Subscriptions.List("snippet,contentDetails");
|
if (SecretsVault.Subscriptions.Count > 0)
|
||||||
request.Mine = true;
|
{
|
||||||
request.MaxResults = 10;
|
subscriptionsList.Visibility = Visibility.Visible;
|
||||||
SubscriptionListResponse response = await request.ExecuteAsync();
|
int l = SecretsVault.Subscriptions.Count;
|
||||||
|
int n = 10;
|
||||||
if (response.Items.Count == 0)
|
for(int k = 0; k < l && k < n; k++)
|
||||||
subsNull.Visibility = Visibility.Visible;
|
|
||||||
else
|
|
||||||
foreach (Subscription s in response.Items)
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
subscriptions.Add(s);
|
Subscription s = SecretsVault.Subscriptions[k];
|
||||||
StackPanel panel = new StackPanel() { Orientation = Orientation.Horizontal };
|
StackPanel panel = new StackPanel() { Orientation = Orientation.Horizontal };
|
||||||
panel.Children.Add(new PersonPicture()
|
panel.Children.Add(new PersonPicture()
|
||||||
{
|
{
|
||||||
@@ -148,19 +139,35 @@ namespace FoxTube
|
|||||||
VerticalAlignment = VerticalAlignment.Center,
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
Text = s.Snippet.Title
|
Text = s.Snippet.Title
|
||||||
});
|
});
|
||||||
subscriptionsHamburger.Items.Add(new ListBoxItem() { Content = panel });
|
subscriptionsList.Items.Add(new ListBoxItem() { Content = panel });
|
||||||
}
|
}
|
||||||
catch { }
|
catch { n++; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Debug.WriteLine("--<!!!Authorized!!!>--");
|
else
|
||||||
|
{
|
||||||
|
account.Visibility = Visibility.Visible;
|
||||||
|
avatar.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
|
toHistory.Visibility = Visibility.Collapsed;
|
||||||
|
toLiked.Visibility = Visibility.Collapsed;
|
||||||
|
toLater.Visibility = Visibility.Collapsed;
|
||||||
|
toSubscriptions.Visibility = Visibility.Collapsed;
|
||||||
|
toChannel.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
|
subscriptionsList.Visibility = Visibility.Collapsed;
|
||||||
|
for(int k = 1; k < subscriptionsList.Items.Count; k++)
|
||||||
|
subscriptionsList.Items.RemoveAt(k);
|
||||||
|
}
|
||||||
|
|
||||||
|
content.CacheSize = 0;
|
||||||
|
content.Navigate(typeof(Home));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnNavigatedTo(e);
|
base.OnNavigatedTo(e);
|
||||||
SetTitleBar();
|
SetTitleBar();
|
||||||
|
|
||||||
Vault.CheckAuthorization();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetTitleBar()
|
private void SetTitleBar()
|
||||||
@@ -186,33 +193,117 @@ namespace FoxTube
|
|||||||
notificationMenu.Content = "";
|
notificationMenu.Content = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClosePopups()
|
private void HamburgerSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
popupPlaceholder.Content = null;
|
if(sender == mainList)
|
||||||
notificationPane.Child = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if(topHamburger.SelectedItem != null)
|
subscriptionsList.SelectedItem = null;
|
||||||
bottomHaburger.SelectedItem = null;
|
categoriesList.SelectedItem = null;
|
||||||
MenuSelectionChanged();
|
serviceList.SelectedItem = null;
|
||||||
} catch { }
|
MainListSelected();
|
||||||
}
|
}
|
||||||
|
else if (sender == subscriptionsList)
|
||||||
private void bottomHaburgerSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if(bottomHaburger.SelectedItem != null)
|
mainList.SelectedItem = null;
|
||||||
topHamburger.SelectedItem = null;
|
categoriesList.SelectedItem = null;
|
||||||
MenuSelectionChanged();
|
serviceList.SelectedItem = null;
|
||||||
} catch { }
|
SubscriptionSelected();
|
||||||
|
}
|
||||||
|
else if(sender == categoriesList)
|
||||||
|
{
|
||||||
|
subscriptionsList.SelectedItem = null;
|
||||||
|
mainList.SelectedItem = null;
|
||||||
|
serviceList.SelectedItem = null;
|
||||||
|
FeaturedSelected();
|
||||||
|
}
|
||||||
|
else if(sender == serviceList)
|
||||||
|
{
|
||||||
|
subscriptionsList.SelectedItem = null;
|
||||||
|
mainList.SelectedItem = null;
|
||||||
|
categoriesList.SelectedItem = null;
|
||||||
|
ServiceListSelected();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mainList.SelectedItem = null;
|
||||||
|
subscriptionsList.SelectedItem = null;
|
||||||
|
categoriesList.SelectedItem = null;
|
||||||
|
serviceList.SelectedItem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MenuSelectionChanged()
|
void MainListSelected()
|
||||||
|
{
|
||||||
|
if (mainList.SelectedItem == null)
|
||||||
|
return;
|
||||||
|
object s = mainList.SelectedItem;
|
||||||
|
|
||||||
|
if (s == toHistory)
|
||||||
|
content.Navigate(typeof(Settings));
|
||||||
|
else if (s == toLiked)
|
||||||
|
content.Navigate(typeof(Settings));
|
||||||
|
else if (s == toLater)
|
||||||
|
content.Navigate(typeof(Settings));
|
||||||
|
else if (s == toSubscriptions)
|
||||||
|
content.Navigate(typeof(Settings));
|
||||||
|
else if (s == toDownloads)
|
||||||
|
content.Navigate(typeof(Downloads));
|
||||||
|
else
|
||||||
|
content.Navigate(typeof(Home));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceListSelected()
|
||||||
|
{
|
||||||
|
if (serviceList.SelectedItem == null)
|
||||||
|
return;
|
||||||
|
object s = serviceList.SelectedItem;
|
||||||
|
|
||||||
|
if (s == toChannel)
|
||||||
|
content.Navigate(typeof(Channel), SecretsVault.AccountId);
|
||||||
|
else if (s == toRemoveAds)
|
||||||
|
content.Navigate(typeof(Settings), "adblock");
|
||||||
|
else
|
||||||
|
content.Navigate(typeof(Settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubscriptionSelected()
|
||||||
|
{
|
||||||
|
if (subscriptionsList.SelectedItem == null)
|
||||||
|
return;
|
||||||
|
content.Navigate(typeof(Channel), SecretsVault.Subscriptions[subscriptionsList.SelectedIndex - 1].Snippet.ChannelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FeaturedSelected()
|
||||||
|
{
|
||||||
|
if (serviceList.SelectedItem == null)
|
||||||
|
return;
|
||||||
|
switch(serviceList.SelectedIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
content.Navigate(typeof(Channel), "UC-9-kyTW8ZkZNDHQJ6FgpwQ");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
content.Navigate(typeof(Channel), "UCEgdi0XIXXZ-qJOFPf4JSKw");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
content.Navigate(typeof(Channel), "UCOpNcN46UbXVtpKMrmU4Abg");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
content.Navigate(typeof(Channel), "UCYfdidRxbB8Qhf0Nx7ioOYw");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
content.Navigate(typeof(Channel), "UC4R8DWoMoI7CAwX8_LjQHig");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
content.Navigate(typeof(Channel), "UC8iNz9uwDGfomRnnKKbOhOQ");
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
content.Navigate(typeof(Channel), "UCzuqhhs6NWbgTzMuM09WKDQ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*private void MenuSelectionChanged()
|
||||||
{
|
{
|
||||||
if(topHamburger.SelectedIndex == 0)
|
if(topHamburger.SelectedIndex == 0)
|
||||||
{
|
{
|
||||||
@@ -224,11 +315,11 @@ namespace FoxTube
|
|||||||
}
|
}
|
||||||
else if (topHamburger.SelectedIndex == 1)
|
else if (topHamburger.SelectedIndex == 1)
|
||||||
{
|
{
|
||||||
/*content.Navigate(typeof(Video));
|
//content.Navigate(typeof(Video));
|
||||||
headerText.Text = "Video";
|
//headerText.Text = "Video";
|
||||||
menu.DisplayMode = SplitViewDisplayMode.CompactOverlay;
|
//menu.DisplayMode = SplitViewDisplayMode.CompactOverlay;
|
||||||
menu.IsPaneOpen = false;
|
//menu.IsPaneOpen = false;
|
||||||
isForcedCollapsed = true;*/
|
//isForcedCollapsed = true;
|
||||||
}
|
}
|
||||||
else if (bottomHaburger.SelectedIndex == 4)
|
else if (bottomHaburger.SelectedIndex == 4)
|
||||||
{
|
{
|
||||||
@@ -255,90 +346,34 @@ namespace FoxTube
|
|||||||
else if (content.SourcePageType == typeof(Channel))
|
else if (content.SourcePageType == typeof(Channel))
|
||||||
bottomHaburger.SelectedIndex = 1;
|
bottomHaburger.SelectedIndex = 1;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private void notificationMenu_Click(object sender, RoutedEventArgs e)
|
public void notificationMenu_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
notificationMenu.Content = "";
|
notificationMenu.Content = "";
|
||||||
if (Window.Current.Bounds.Width >= 500)
|
notificationPane.IsOpen = !notificationPane.IsOpen;
|
||||||
{
|
|
||||||
notificationPane.Child = notificationsCenter;
|
|
||||||
notificationPane.IsOpen = !notificationPane.IsOpen;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
popupPlaceholder.Content = notificationsCenter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void feedback_Click(object sender, RoutedEventArgs e)
|
private void feedback_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
bottomHaburger.SelectedIndex = 4;
|
content.Navigate(typeof(Settings), "feedback");
|
||||||
(content.Content as Settings).pivot.SelectedIndex = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreDefineFeedback(bool isProblem, string meta)
|
public void PreDefineFeedback(bool isProblem, string meta)
|
||||||
{
|
{
|
||||||
bottomHaburger.SelectedIndex = 4;
|
content.Navigate(typeof(Settings), $"feedback&isProblem={isProblem}&meta={meta}");
|
||||||
Settings s = content.Content as Settings;
|
|
||||||
s.pivot.SelectedIndex = 3;
|
|
||||||
s.fb.PreDefine(isProblem, meta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menu_PaneClosed(SplitView sender, object args)
|
private void menu_PaneClosed(SplitView sender, object args)
|
||||||
{
|
{
|
||||||
try
|
subsTitle.Visibility = Visibility.Collapsed;
|
||||||
{
|
catTitle.Visibility = Visibility.Collapsed;
|
||||||
subsMenuTitle.Visibility = Visibility.Collapsed;
|
|
||||||
subsMenuStroke.Y1 = subsMenuStroke.Y2 = 0;
|
|
||||||
subsMenuStroke.X2 = 40;
|
|
||||||
subscriptionsTitle.Height = 2;
|
|
||||||
|
|
||||||
catMenuTitle.Visibility = Visibility.Collapsed;
|
|
||||||
catMenuStroke.Y1 = catMenuStroke.Y2 = 0;
|
|
||||||
catMenuStroke.X2 = 40;
|
|
||||||
categoriesTitle.Height = 2;
|
|
||||||
if (Vault.IsLoged)
|
|
||||||
{
|
|
||||||
if (subscriptions.Count == 0)
|
|
||||||
{
|
|
||||||
subsNull.Visibility = Visibility.Collapsed;
|
|
||||||
subsMenuStroke.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
subsLogErr.Visibility = Visibility.Collapsed;
|
|
||||||
subsMenuStroke.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
} catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menu_PaneOpened(SplitView sender, object args)
|
private void menu_PaneOpened(SplitView sender, object args)
|
||||||
{
|
{
|
||||||
try
|
subsTitle.Visibility = Visibility.Visible;
|
||||||
{
|
catTitle.Visibility = Visibility.Visible;
|
||||||
subsMenuTitle.Visibility = Visibility.Visible;
|
|
||||||
subsMenuStroke.Y1 = catMenuStroke.Y2 = 10;
|
|
||||||
subsMenuStroke.X2 = 300;
|
|
||||||
subscriptionsTitle.Height = 17;
|
|
||||||
|
|
||||||
catMenuTitle.Visibility = Visibility.Visible;
|
|
||||||
catMenuStroke.Y1 = subsMenuStroke.Y2 = 10;
|
|
||||||
catMenuStroke.X2 = 300;
|
|
||||||
categoriesTitle.Height = 17;
|
|
||||||
if (Vault.IsLoged)
|
|
||||||
{
|
|
||||||
if (subscriptions.Count == 0)
|
|
||||||
{
|
|
||||||
subsNull.Visibility = Visibility.Visible;
|
|
||||||
subsMenuStroke.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
subsLogErr.Visibility = Visibility.Visible;
|
|
||||||
subsMenuStroke.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
} catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void createAccount_Click(object sender, RoutedEventArgs e)
|
private async void createAccount_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -351,6 +386,16 @@ namespace FoxTube
|
|||||||
Vault.Authorize();
|
Vault.Authorize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void myChannel_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
content.Navigate(typeof(Channel), SecretsVault.UserChannel.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logout_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Vault.Deauthenticate();
|
||||||
|
}
|
||||||
|
|
||||||
private void searchField_TextChanged(object sender, TextChangedEventArgs e)
|
private void searchField_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (searchField.Text.Length > 2)
|
if (searchField.Text.Length > 2)
|
||||||
@@ -373,21 +418,20 @@ namespace FoxTube
|
|||||||
|
|
||||||
private void searchButton_Click(object sender, RoutedEventArgs e)
|
private void searchButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if(searchField.Text != "")
|
if (searchField.Text != "" || (!(content.Content is Search) && (content.Content as Search).Term != searchField.Text))
|
||||||
StartSearch(searchField.Text);
|
content.Navigate(typeof(Search), searchField.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToSearch(string keyword)
|
public void GoToSearch(string keyword)
|
||||||
{
|
{
|
||||||
searchField.Text = keyword;
|
searchField.Text = keyword;
|
||||||
StartSearch(keyword);
|
searchButton_Click(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void StartSearch(string keyword)
|
private async void StartSearch(string keyword)
|
||||||
{
|
{
|
||||||
content.Navigate(typeof(Search));
|
content.Navigate(typeof(Search));
|
||||||
topHamburger.SelectedItem = null;
|
HamburgerSelectionChanged(null, null);
|
||||||
bottomHaburger.SelectedItem = null;
|
|
||||||
|
|
||||||
YouTubeService ytService = SecretsVault.IsAuthorized ? SecretsVault.Service : SecretsVault.NoAuthService;
|
YouTubeService ytService = SecretsVault.IsAuthorized ? SecretsVault.Service : SecretsVault.NoAuthService;
|
||||||
|
|
||||||
@@ -418,11 +462,11 @@ namespace FoxTube
|
|||||||
|
|
||||||
private void searchField_KeyUp(object sender, KeyRoutedEventArgs e)
|
private void searchField_KeyUp(object sender, KeyRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Windows.System.VirtualKey.Enter)
|
if (e.Key == VirtualKey.Enter)
|
||||||
{
|
{
|
||||||
searchButton_Click(this, null);
|
searchButton_Click(this, null);
|
||||||
content.Focus(FocusState.Pointer);
|
content.Focus(FocusState.Pointer);
|
||||||
searchSuggestions.Visibility = Visibility.Collapsed;
|
searchSuggestions.IsOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,10 +482,9 @@ namespace FoxTube
|
|||||||
|
|
||||||
public void GoToChannel(string id)
|
public void GoToChannel(string id)
|
||||||
{
|
{
|
||||||
|
MinimizeVideo();
|
||||||
headerText.Text = "Channel overview";
|
headerText.Text = "Channel overview";
|
||||||
content.Navigate(typeof(Channel));
|
content.Navigate(typeof(Channel), id);
|
||||||
Channel page = content.Content as Channel;
|
|
||||||
page.Initialize(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToVideo(string id)
|
public void GoToVideo(string id)
|
||||||
@@ -458,8 +501,12 @@ namespace FoxTube
|
|||||||
videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch;
|
videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||||
videoPlaceholder.Margin = new Thickness(0);
|
videoPlaceholder.Margin = new Thickness(0);
|
||||||
|
|
||||||
videoPlaceholder.Navigate(typeof(Video));
|
videoPlaceholder.Navigate(typeof(Video), id);
|
||||||
(videoPlaceholder.Content as Video).Initialize(id);
|
}
|
||||||
|
|
||||||
|
public void GoToDeveloper(string id)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
@@ -505,11 +552,6 @@ namespace FoxTube
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeNotification_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
notificationPane.IsOpen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MinimizeVideo()
|
public void MinimizeVideo()
|
||||||
{
|
{
|
||||||
videoPlaceholder.Width = 432;
|
videoPlaceholder.Width = 432;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace FoxTube
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class Search : Page
|
public sealed partial class Search : Page
|
||||||
{
|
{
|
||||||
|
public string Term;
|
||||||
public ProgressRing ring;
|
public ProgressRing ring;
|
||||||
public StackPanel content;
|
public StackPanel content;
|
||||||
public Search()
|
public Search()
|
||||||
|
|||||||
Reference in New Issue
Block a user