Feedback hub removed, Subscription page development, changelog notifications
This commit is contained in:
@@ -32,7 +32,6 @@ namespace FoxTube.Background
|
||||
ClientId = "349735264870-2ekqlm0a4mkg3mmrfcv90s3qp3o15dq0.apps.googleusercontent.com",
|
||||
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
|
||||
};
|
||||
|
||||
private YouTubeService Service => new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
||||
@@ -41,6 +40,7 @@ namespace FoxTube.Background
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
BackgroundTaskDeferral def;
|
||||
|
||||
public void Run(IBackgroundTaskInstance taskInstance)
|
||||
{
|
||||
def = taskInstance.GetDeferral();
|
||||
@@ -48,16 +48,17 @@ namespace FoxTube.Background
|
||||
settings.Values.Add("lastCheck", XmlConvert.ToString(DateTime.Now, "YYYY-MM-DDThh:mm:ss"));
|
||||
else lastCheck = XmlConvert.ToDateTime(settings.Values["lastCheck"] as string, XmlDateTimeSerializationMode.Unspecified);
|
||||
|
||||
if (settings.Values["notificationsHistory"] != null)
|
||||
doc.LoadXml(settings.Values["notificationsHistory"] as string);
|
||||
else
|
||||
try
|
||||
{
|
||||
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
|
||||
doc.AppendChild(doc.CreateElement("history"));
|
||||
settings.Values.Add("notificationsHistory", doc.InnerXml);
|
||||
doc.LoadXml(settings.Values["notificationsHistory"] as string);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckAnnouncements();
|
||||
CheckAccount();
|
||||
|
||||
SendNSave();
|
||||
|
||||
@@ -78,36 +79,37 @@ namespace FoxTube.Background
|
||||
subRequest.Mine = true;
|
||||
subRequest.MaxResults = 50;
|
||||
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
||||
List<KeyValuePair<string, string>> subs = new List<KeyValuePair<string, string>>();
|
||||
Dictionary<string, string> subs = new Dictionary<string, string>();
|
||||
|
||||
foreach (Subscription s in subResponse.Items)
|
||||
subs.Add(new KeyValuePair<string, string>(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url));
|
||||
subs.Add(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url);
|
||||
|
||||
string nextToken = subResponse.NextPageToken;
|
||||
while (nextToken != null)
|
||||
{
|
||||
subRequest.PageToken = nextToken;
|
||||
subResponse = await subRequest.ExecuteAsync();
|
||||
nextToken = subResponse.NextPageToken;
|
||||
|
||||
foreach (Subscription s in subResponse.Items)
|
||||
subs.Add(new KeyValuePair<string, string>(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url));
|
||||
subs.Add(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url);
|
||||
}
|
||||
|
||||
foreach(var s in subs)
|
||||
{
|
||||
var request = Service.Search.List("snippet");
|
||||
SearchResource.ListRequest request = Service.Search.List("snippet");
|
||||
request.PublishedAfter = lastCheck;
|
||||
request.ChannelId = s.Key;
|
||||
request.Type = "video";
|
||||
var response = await request.ExecuteAsync();
|
||||
SearchListResponse response = await request.ExecuteAsync();
|
||||
|
||||
if(response.Items.Count > 0)
|
||||
foreach (var a in response.Items)
|
||||
Notifications.Add(new Notification("video", a.Id.VideoId,
|
||||
a.Snippet.ChannelTitle,
|
||||
a.Snippet.Title,
|
||||
a.Snippet.PublishedAt.Value,
|
||||
a.Snippet.Thumbnails.Standard.Url,
|
||||
s.Value));
|
||||
foreach (var i in response.Items)
|
||||
Notifications.Add(new Notification("video", i.Id.VideoId,
|
||||
i.Snippet.ChannelTitle,
|
||||
i.Snippet.Title,
|
||||
i.Snippet.PublishedAt.Value,
|
||||
i.Snippet.Thumbnails.Standard.Url,
|
||||
s.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,10 +119,10 @@ namespace FoxTube.Background
|
||||
doc.Load(XmlReader.Create("http://foxgame.hol.es/foxtube-messages.xml"));
|
||||
if ((XmlConvert.ToDateTimeOffset((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), "YYYY-MM-DDThh:mm:ss") - lastCheck.ToUniversalTime()).TotalSeconds > 0)
|
||||
Notifications.Add(new Notification("internal", (doc["posts"].FirstChild as XmlElement).GetAttribute("id"),
|
||||
doc["posts"].FirstChild["header"].InnerText,
|
||||
doc["posts"].FirstChild["notificationHeader"].InnerText,
|
||||
doc["posts"].FirstChild["content"].InnerText,
|
||||
XmlConvert.ToDateTimeOffset((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), "YYYY-MM-DDThh:mm:ss"),
|
||||
(doc["posts"].FirstChild as XmlElement).GetAttribute("image"), null));
|
||||
(doc["posts"].FirstChild as XmlElement).GetAttribute("image"), (doc["posts"].FirstChild as XmlElement).GetAttribute("avatar")));
|
||||
}
|
||||
|
||||
void SendNotification(Notification notification)
|
||||
|
||||
@@ -37,10 +37,25 @@ namespace FoxTube.Background
|
||||
TimeStamp = date;
|
||||
Id = id;
|
||||
Type = TypeConversion(type);
|
||||
Avatar = avatarUrl == null? "ms-appx:///Assets/Icons/Profile.png" : avatarUrl;
|
||||
Avatar = avatarUrl ?? "ms-appx:///Assets/Icons/Profile.png";
|
||||
Thumbnail = thumbnailUrl;
|
||||
}
|
||||
|
||||
public Notification(string xmlSource)
|
||||
{
|
||||
System.Xml.XmlDocument d = new System.Xml.XmlDocument();
|
||||
d.InnerXml = xmlSource;
|
||||
System.Xml.XmlElement xml = d["item"];
|
||||
|
||||
Channel = xml["channelName"].InnerText;
|
||||
Content = xml["content"].InnerText;
|
||||
TimeStamp = DateTimeOffset.Parse(xml.GetAttribute("time"));
|
||||
Id = xml.GetAttribute("id");
|
||||
Type = TypeConversion(xml.GetAttribute("type"));
|
||||
Avatar = xml["images"].GetAttribute("avatar");
|
||||
Thumbnail = xml["images"].GetAttribute("thumbnail");
|
||||
}
|
||||
|
||||
public string GetXml()
|
||||
{
|
||||
return $@"<item time='{TimeStamp.ToString("YYYY-MM-DDThh:mm:ss")}' type='{TypeConversion(Type)}' id='{Id}'>
|
||||
@@ -57,33 +72,23 @@ namespace FoxTube.Background
|
||||
//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
|
||||
Text = "Developer's message"
|
||||
});
|
||||
break;
|
||||
|
||||
case NotificationType.Post:
|
||||
case NotificationType.Changelog:
|
||||
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)
|
||||
Text = "Changelog"
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -93,7 +98,7 @@ namespace FoxTube.Background
|
||||
FontSize = 14,
|
||||
FontStyle = Windows.UI.Text.FontStyle.Italic,
|
||||
Foreground = new SolidColorBrush(Colors.Gray),
|
||||
Text = string.Format("{0} uploaded new video", Channel)
|
||||
Text = $"{Channel} uploaded new video"
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -142,36 +147,13 @@ namespace FoxTube.Background
|
||||
XmlDocument template = new XmlDocument();
|
||||
switch (Type)
|
||||
{
|
||||
case NotificationType.Comment:
|
||||
template.LoadXml($@"<toast launch='comment&{Id}'>
|
||||
<visual>
|
||||
<binding template='ToastGeneric'>
|
||||
<image placement='appLogoOverride' hint-crop='circle' src='{Avatar}'/>
|
||||
<text>{Channel} posted a new comment</text>
|
||||
<text>{Content}</text>
|
||||
</binding>
|
||||
</visual>
|
||||
|
||||
<actions>
|
||||
<input id='textBox' type='text' placeHolderContent='Send a reply'/>
|
||||
|
||||
<action content='Send' imageUri='Assets/Icons/Send.png'
|
||||
hint-inputId='textBox' activationType='background'
|
||||
arguments='comment&{Id}&send'/>
|
||||
|
||||
<action content='Like'
|
||||
arguments='comment&{Id}&like'/>
|
||||
</actions>
|
||||
</toast>");
|
||||
break;
|
||||
|
||||
case NotificationType.Video:
|
||||
template.LoadXml($@"<toast launch='video&{Id}'>
|
||||
template.LoadXml($@"<toast launch='video={Id}'>
|
||||
<visual>
|
||||
<binding template='ToastGeneric'>
|
||||
<image placement='appLogoOverride' hint-crop='circle' src='{Avatar}'/>
|
||||
<text>{Channel} uploaded a new video</text>
|
||||
<text>{Content}</text>
|
||||
<text>{Channel} uploaded a new video</text>
|
||||
<image src='{Thumbnail}'/>
|
||||
</binding>
|
||||
</visual>
|
||||
@@ -187,62 +169,28 @@ namespace FoxTube.Background
|
||||
break;
|
||||
|
||||
case NotificationType.Changelog:
|
||||
template.LoadXml($@"<toast launch='changelog&{Id}'>
|
||||
template.LoadXml($@"<toast launch='{Id}'>
|
||||
<visual>
|
||||
<binding template='ToastGeneric'>
|
||||
<image placement='hero' src='Assets/WhatsNewThumb.png'/>
|
||||
<image placement='appLogoOverride' hint-crop='circle' src='Assets/LogoAvatar.png'/>
|
||||
<image placement='hero' src='http://foxgame.hol.es/FoxTubeAssets/WhatsNewThumb.png'/>
|
||||
<image placement='appLogoOverride' hint-crop='circle' src='http://foxgame.hol.es/FoxTubeAssets/NewsAvatar.png'/>
|
||||
<text>{Content}</text>
|
||||
<text>Changelog</text>
|
||||
<text>{Channel}</text>
|
||||
</binding>
|
||||
</visual>
|
||||
</toast>");
|
||||
break;
|
||||
|
||||
case NotificationType.Internal:
|
||||
string thumb1 = string.IsNullOrWhiteSpace(Thumbnail) ? "Assets/AnnouncementThumb.png" : Thumbnail;
|
||||
template.LoadXml($@"<toast launch='internal&{Id}'>
|
||||
template.LoadXml($@"<toast launch='internal={Id}'>
|
||||
<visual>
|
||||
<binding template='ToastGeneric'>
|
||||
<image placement='hero' src='{thumb1}'/>
|
||||
<image placement='appLogoOverride' hint-crop='circle' src='Assets/LogoAvatar.png'/>
|
||||
<text>{Channel}</text>
|
||||
<text hint-maxLines='5'>{Content}</text>
|
||||
</binding>
|
||||
</visual>
|
||||
|
||||
<actions>
|
||||
<action content='Watch full post'
|
||||
arguments='internal&{Id}'/>
|
||||
<action content='Manage notifications'
|
||||
arguments='notifications'/>
|
||||
</actions>
|
||||
</toast>");
|
||||
break;
|
||||
|
||||
case NotificationType.Post:
|
||||
string thumb2 = string.IsNullOrWhiteSpace(Thumbnail) ? "" : $"<image placement='hero' src ='{Thumbnail}'/>";
|
||||
template.LoadXml($@"<toast launch='action=openThread&threadId=92187'>
|
||||
<visual>
|
||||
<binding template='ToastGeneric'>
|
||||
{thumb2}
|
||||
<image placement='hero' src='{Thumbnail}'/>
|
||||
<image placement='appLogoOverride' hint-crop='circle' src='{Avatar}'/>
|
||||
<text>{Channel}</text>
|
||||
<text hint-maxLines='5'>{Content}</text>
|
||||
<text>{Content}</text>
|
||||
<text hint-maxLines='5'>{Channel}</text>
|
||||
</binding>
|
||||
</visual>
|
||||
|
||||
<actions>
|
||||
<input id='textBox' type='text' placeHolderContent='Leave a comment'/>
|
||||
<action content='Send'
|
||||
imageUri='Assets/Icons/send.png'
|
||||
hint-inputId='textBox'
|
||||
activationType='background'
|
||||
arguments='action=reply&threadId=92187'/>
|
||||
|
||||
<action content='Like'
|
||||
arguments='action=commentPhoto&photoId=92187'/>
|
||||
</actions>
|
||||
</toast>");
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user