Archived
1
0

Notification system development 1

This commit is contained in:
Michael Gordeev
2018-08-18 09:21:57 +03:00
parent 26907c9aac
commit 4c4f4ed967
13 changed files with 291 additions and 155 deletions
+8 -16
View File
@@ -16,7 +16,7 @@ using Windows.UI.Notifications;
namespace FoxTube.Background
{
public delegate void NotificationHandler(object sender, string xml);
public delegate void NotificationHandler(object sender, Notification item);
public sealed class BackgroundProcessor : IBackgroundTask
{
@@ -45,7 +45,7 @@ namespace FoxTube.Background
{
def = taskInstance.GetDeferral();
if (settings.Values["lastCheck"] == null)
settings.Values.Add("lastCheck", XmlConvert.ToString(DateTime.Now));
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)
@@ -57,9 +57,6 @@ namespace FoxTube.Background
settings.Values.Add("notificationsHistory", doc.InnerXml);
}
if((bool)settings.Values["authorized"] == true)
CheckAccount();
CheckAnnouncements();
SendNSave();
@@ -114,36 +111,32 @@ namespace FoxTube.Background
}
}
string CheckAnnouncements()
void CheckAnnouncements()
{
XmlDocument doc = new XmlDocument();
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)
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["notificationHeader"].InnerText,
doc["posts"].FirstChild["content"].InnerText,
XmlConvert.ToDateTime((doc["posts"].FirstChild as XmlElement).GetAttribute("time"),
XmlDateTimeSerializationMode.Unspecified),
XmlConvert.ToDateTimeOffset((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), "YYYY-MM-DDThh:mm:ss"),
(doc["posts"].FirstChild as XmlElement).GetAttribute("image"), null));
return doc.InnerXml;
}
void SendNotification(Notification notification)
{
ToastNotificationManager.CreateToastNotifier().Show(notification.GetToast(0));
ToastNotificationManager.CreateToastNotifier().Show(notification.GetToast());
}
void SendNSave()
{
foreach (Notification n in Notifications)
{
NotificationRecieved.Invoke(this, n.GetXml());
NotificationRecieved.Invoke(this, n);
doc["history"].InnerXml += n.GetXml();
}
settings.Values.Add("notificationsHistory", doc.InnerXml);
if ((bool)settings.Values["notifications"])
foreach (Notification n in Notifications)
switch (n.Type)
{
@@ -153,7 +146,6 @@ namespace FoxTube.Background
break;
case NotificationType.Internal:
if ((bool)settings.Values["newmessagesNotification"])
SendNotification(n);
break;
}
+29 -11
View File
@@ -15,7 +15,7 @@ namespace FoxTube.Background
{
public enum NotificationType
{
Video, Comment, Post, Internal
Video, Comment, Post, Internal, Changelog
}
public sealed class Notification
@@ -35,6 +35,7 @@ namespace FoxTube.Background
Channel = channelName;
Content = content;
TimeStamp = date;
Id = id;
Type = TypeConversion(type);
Avatar = avatarUrl == null? "ms-appx:///Assets/Icons/Profile.png" : avatarUrl;
Thumbnail = thumbnailUrl;
@@ -136,13 +137,13 @@ namespace FoxTube.Background
return item;
}
public ToastNotification GetToast(int assignedId)
public ToastNotification GetToast()
{
XmlDocument template = new XmlDocument();
switch (Type)
{
case NotificationType.Comment:
template.LoadXml($@"<toast launch='type=comment&amp;action=open&amp;id={assignedId}'>
template.LoadXml($@"<toast launch='comment&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='appLogoOverride' hint-crop='circle' src='{Avatar}'/>
@@ -156,16 +157,16 @@ namespace FoxTube.Background
<action content='Send' imageUri='Assets/Icons/Send.png'
hint-inputId='textBox' activationType='background'
arguments='type=comment&amp;action=sendReply&amp;id={assignedId}'/>
arguments='comment&{Id}&send'/>
<action content='Like'
arguments='type=comment&amp;action=like&amp;id={assignedId}'/>
arguments='comment&{Id}&like'/>
</actions>
</toast>");
break;
case NotificationType.Video:
template.LoadXml($@"<toast launch='action=viewPhoto&amp;photoId=92187'>
template.LoadXml($@"<toast launch='video&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='appLogoOverride' hint-crop='circle' src='{Avatar}'/>
@@ -178,16 +179,29 @@ namespace FoxTube.Background
<actions>
<action content='Watch later'
activationType='background'
arguments='likePhoto&amp;photoId=92187'/>
arguments='video&{Id}&later'/>
<action content='Go to channel'
arguments='action=commentPhoto&amp;photoId=92187'/>
arguments='video&{Id}&channel'/>
</actions>
</toast>");
break;
case NotificationType.Changelog:
template.LoadXml($@"<toast launch='changelog&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='hero' src='Assets/WhatsNewThumb.png'/>
<image placement='appLogoOverride' hint-crop='circle' src='Assets/LogoAvatar.png'/>
<text>{Content}</text>
<text>Changelog</text>
</binding>
</visual>
</toast>");
break;
case NotificationType.Internal:
string thumb1 = string.IsNullOrWhiteSpace(Thumbnail) ? "Assets/AnnouncementThumb.png" : Thumbnail;
template.LoadXml($@"<toast launch='action=openThread&amp;threadId=92187'>
template.LoadXml($@"<toast launch='internal&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='hero' src='{thumb1}'/>
@@ -199,9 +213,9 @@ namespace FoxTube.Background
<actions>
<action content='Watch full post'
arguments='action=commentPhoto&amp;photoId=92187'/>
arguments='internal&{Id}'/>
<action content='Manage notifications'
arguments='action=commentPhoto&amp;photoId=92187'/>
arguments='notifications'/>
</actions>
</toast>");
break;
@@ -246,6 +260,8 @@ namespace FoxTube.Background
return "post";
case NotificationType.Video:
return "video";
case NotificationType.Changelog:
return "changelog";
default:
return "internal";
}
@@ -261,6 +277,8 @@ namespace FoxTube.Background
return NotificationType.Post;
case "video":
return NotificationType.Video;
case "changelog":
return NotificationType.Changelog;
default:
return NotificationType.Internal;
}
+5 -2
View File
@@ -13,6 +13,7 @@ namespace FoxTube.Classes
public string PatchVersion { get; set; }
public string Subject { get; set; }
public string Content { get; set; }
public string Id { get; set; }
public string Icon
{
@@ -47,20 +48,22 @@ namespace FoxTube.Classes
}
public InboxItem(string version, string content, string timeStamp)
public InboxItem(string version, string content, string timeStamp, string id)
{
Type = InboxItemType.PatchNote;
PatchVersion = version;
Content = content;
TimeStamp = DateTime.Parse(timeStamp);
Id = id;
}
public InboxItem(string title, string content, DateTime timeStamp)
public InboxItem(string title, string content, DateTime timeStamp, string id)
{
Type = InboxItemType.Default;
Content = content;
Subject = title;
TimeStamp = timeStamp;
Id = id;
}
}
}
+13 -5
View File
@@ -110,12 +110,20 @@ namespace FoxTube
}
public static async void Authorize()
{
try { Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(Secrets, new[] { Google.Apis.Oauth2.v2.Oauth2Service.Scope.UserinfoProfile, YouTubeService.Scope.YoutubeForceSsl }, "user", CancellationToken.None); }
catch { }
if(Credential != null)
{
try
{
Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
Secrets,
new[]
{
Google.Apis.Oauth2.v2.Oauth2Service.Scope.UserinfoProfile,
YouTubeService.Scope.YoutubeForceSsl
},
"user",
CancellationToken.None);
if (Credential != null)
{
if (settings.Values["authorized"] == null)
settings.Values.Add("authorized", true);
@@ -174,6 +182,7 @@ namespace FoxTube
Subscriptions.Add(s);
}
}
}
catch
{
MessageDialog dialog = new MessageDialog("We were unabled to retrieve your account information due to weak internet connection or Google servers' problems. PLease, try again later", "Failed to connect");
@@ -195,7 +204,6 @@ namespace FoxTube
AuthorizationStateChanged.Invoke(null, null);
}
}
public static async void Deauthenticate()
{
+5 -8
View File
@@ -6,17 +6,14 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="350">
d:DesignHeight="400"
d:DesignWidth="300">
<StackPanel Background="WhiteSmoke" Padding="0,10,0,0">
<Grid>
<StackPanel Background="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}" Width="300" Margin="-10" MinHeight="400">
<Grid Height="50">
<TextBlock Text="Notifications" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"/>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button Visibility="Collapsed" Background="Transparent" Foreground="Gray" FontFamily="Segoe MDL2 Assets" Content="&#xE74D;" Height="50" Width="50" ToolTipService.ToolTip="Clear all" Name="clear" Click="clear_Click"/>
<Button Background="Transparent" Foreground="Gray" FontFamily="Segoe MDL2 Assets" Content="&#xE10A;" Height="50" Width="50" ToolTipService.ToolTip="Close" Name="close" Click="close_Click"/>
</StackPanel>
<Button Visibility="Collapsed" Background="Transparent" Foreground="Gray" FontFamily="Segoe MDL2 Assets" Content="&#xE74D;" Height="50" Width="50" HorizontalAlignment="Right" ToolTipService.ToolTip="Clear all" Name="clear" Click="clear_Click"/>
</Grid>
<TextBlock Text="You have no any notification" Name="noNotifications" Foreground="Gray" FontStyle="Italic" Padding="10" Visibility="Visible"/>
<ScrollViewer>
+8 -17
View File
@@ -32,7 +32,10 @@ namespace FoxTube
public NotificationsCenter()
{
this.InitializeComponent();
}
public void Initialize()
{
if (settings.Values["notificationsHistory"] != null)
{
doc.LoadXml(settings.Values["notificationsHistory"] as string);
@@ -59,33 +62,21 @@ namespace FoxTube
BackgroundProcessor.NotificationRecieved += NewNotification;
}
private void NewNotification(object sender, string xml)
private void NewNotification(object sender, Notification item)
{
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")
));
AddNotification(item);
}
private void clear_Click(object sender, RoutedEventArgs e)
{
array.Children.Clear();
notifications.Clear();
doc["history"].InnerXml = "";
settings.Values["notificationsHistory"] = doc.InnerXml;
clear.Visibility = Visibility.Collapsed;
noNotifications.Visibility = Visibility.Visible;
}
private void close_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.notificationMenu_Click(this, null);
}
public void AddNotification(Notification notification)
{
notifications.Add(notification);
@@ -101,7 +92,7 @@ namespace FoxTube
private void Notification_Click(object sender, RoutedEventArgs e)
{
Notification n = notifications[((sender as Button).Parent as StackPanel).Children.IndexOf(sender as Button)];
Notification n = notifications[array.Children.IndexOf(sender as Button)];
switch(n.Type)
{
case NotificationType.Internal:
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<history>
<item time="YYYY-MM-DDThh:mm:ss" type="" id="">
<item time="YYYY-MM-DDThh:mm:ss-03" type="" id="">
<images thumbnail="" avatar=""/>
<channelName></channelName>
<content></content>
+7 -3
View File
@@ -52,16 +52,20 @@
</NavigationView.AutoSuggestBox>
<NavigationView.Header>
<Grid Margin="10,10,0,0">
<Grid Margin="10,-5,0,-11">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock FontSize="28" VerticalAlignment="Center" Text="Home" Name="header"/>
<StackPanel Orientation="Horizontal" Grid.Column="1" Margin="0,17,0,0">
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Name="notificationMenu" ToolTipService.ToolTip="Notifications" Click="notificationMenu_Click"
FontFamily="Segoe MDL2 Assets" Content="&#xED0D;"
Width="50" Height="50" Background="Transparent"/>
Width="50" Height="50" Background="Transparent">
<Button.Flyout>
<Flyout Content="{x:Bind notificationsCenter}"/>
</Button.Flyout>
</Button>
<Button Name="account" ToolTipService.ToolTip="Sign in"
FontFamily="Segoe MDL2 Assets" Content="&#xE8FA;"
+131 -17
View File
@@ -39,6 +39,7 @@ using Google.Apis.Oauth2.v2.Data;
using FoxTube.Controls;
using FoxTube.Pages;
using Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.ApplicationModel;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
@@ -89,6 +90,40 @@ namespace FoxTube
if (settings.Values["defaultDownload"] == null)
settings.Values.Add("defaultDownload", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\DownloadedVideos");
PackageVersion ver = Package.Current.Id.Version;
if (settings.Values["ver"] == null)
settings.Values.Add("var", $"{ver.Major}.{ver.Minor}");
if((string)settings.Values["ver"] != $"{ver.Major}.{ver.Minor}")
{
try
{
XmlDocument changelog = new XmlDocument();
changelog.Load("http://foxgame.hol.es/foxtube-changelog.xml");
XmlElement e = changelog["items"].ChildNodes[0] as XmlElement;
XmlDocument doc = new XmlDocument();
doc.LoadXml(settings.Values["notificationsHistory"] as string);
Background.Notification n = new Background.Notification("changelog",
$"changelog-{e.GetAttribute("version")}",
"Changelog",
$"What's new in version {e.GetAttribute("version")}",
XmlConvert.ToDateTimeOffset(e.GetAttribute("time"), "YYYY-MM-DDThh:mm:ss"),
"",
"");
doc["history"].InnerXml += n.GetXml();
settings.Values["notificationsHistory"] = doc.InnerXml;
ToastNotificationManager.CreateToastNotifier().Show(n.GetToast());
settings.Values["ver"] = $"{ver.Major}.{ver.Minor}";
}
catch { }
}
notificationsCenter.Initialize();
SecretsVault.AuthorizationStateChanged += Vault_AuthorizationStateChanged;
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
}
@@ -284,7 +319,7 @@ namespace FoxTube
public void GoToDeveloper(string id)
{
MinimizeAsInitializer();
content.Navigate(typeof(Settings), "inbox");
content.Navigate(typeof(Settings), $"inbox&{id}");
}
public void GoToPlaylist(string id)
@@ -374,6 +409,8 @@ namespace FoxTube
private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
if(search.Text.Length > 2)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load($"http://suggestqueries.google.com/complete/search?output=toolbar&hl={(settings.Values["region"] as string).Remove(2)}&q={search.Text}");
@@ -385,6 +422,11 @@ namespace FoxTube
search.ItemsSource = suggestions;
}
catch (System.Net.WebException)
{
search.ItemsSource = new List<string>();
}
}
}
private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
@@ -414,7 +456,7 @@ namespace FoxTube
content.Navigate(typeof(ChannelPage), SecretsVault.Subscriptions[Convert.ToInt32((args.SelectedItem as NavigationViewItem).Name)].Snippet.ResourceId.ChannelId);
}
}
else if (s == Sender.Frame)
else
s = Sender.None;
}
@@ -440,25 +482,98 @@ namespace FoxTube
Dictionary<Type, Action> navCase = new Dictionary<Type, Action>()
{
{ typeof(Settings), () => nav.SelectedItem = nav.SettingsItem },
{ typeof(Settings), () =>
{
if(nav.SelectedItem != nav.SettingsItem)
nav.SelectedItem = nav.SettingsItem;
else
s = Sender.None;
} },
{ typeof(ChannelPage), () =>
{
//Check channel
if((content.Content as ChannelPage).channelId == SecretsVault.AccountId)
{
if(nav.SelectedItem != toChannel)
nav.SelectedItem = toChannel;
else
s = Sender.None;
}
else
{
bool b = false;
for(int k = 0; k < SecretsVault.Subscriptions.Count && k < 10; k++)
if(SecretsVault.Subscriptions[k].Snippet.ResourceId.ChannelId == (content.Content as ChannelPage).channelId)
{
if(nav.SelectedItem != nav.MenuItems[k + 9])
nav.SelectedItem = nav.MenuItems[k + 9];
else
s = Sender.None;
b = true;
break;
}
if(!b)
{
nav.SelectedItem = null;
}
}
} },
{ typeof(PlaylistPage), () =>
{
//Check playlist
if((content.Content as PlaylistPage).playlistId == SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes)
{
if(nav.SelectedItem != toLiked)
nav.SelectedItem = toLiked;
else
s = Sender.None;
}
else if ((content.Content as PlaylistPage).playlistId == SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater)
{
if(nav.SelectedItem != toLater)
nav.SelectedItem = toLater;
else
s = Sender.None;
}
else
{
nav.SelectedItem = null;
}
} },
{ typeof(Search), () => nav.SelectedItem = null },
{ typeof(History), () => nav.SelectedItem = toHistory },
{ typeof(Home), () => nav.SelectedItem = toHome },
{ typeof(Downloads), () => nav.SelectedItem = toDownloads }
{ typeof(Search), () =>
{
nav.SelectedItem = null;
} },
{ typeof(History), () =>
{
if(nav.SelectedItem != toHistory)
nav.SelectedItem = toHistory;
else
s = Sender.None;
} },
{ typeof(Home), () =>
{
if(nav.SelectedItem != toHome)
nav.SelectedItem = toHome;
else
s = Sender.None;
} },
{ typeof(Downloads), () =>
{
if(nav.SelectedItem != toDownloads)
nav.SelectedItem = toDownloads;
else
s = Sender.None;
} }
};
try { navCase[e.SourcePageType](); }
catch { }
catch
{
nav.SelectedItem = null;
}
else if (s == Sender.Menu)
}
else
s = Sender.None;
if (content.CanGoBack)
@@ -466,13 +581,17 @@ namespace FoxTube
else
nav.IsBackEnabled = false;
if ((e.SourcePageType == typeof(Home) || e.SourcePageType == typeof(Settings)) && nav.DisplayMode == NavigationViewDisplayMode.Expanded)
nav.IsPaneOpen = true;
else
nav.IsPaneOpen = false;
if (videoPlaceholder.Content != null && (videoPlaceholder.Parent as DropShadowPanel).HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer();
}
private void toChannel_Click(object sender, RoutedEventArgs e)
{
nav.SelectedItem = null;
GoToChannel(SecretsVault.UserChannel.Id);
}
@@ -489,10 +608,5 @@ namespace FoxTube
else
content.GoBack();
}
public void CloseApp()
{
CoreApplication.Exit();
}
}
}
+1 -1
View File
@@ -31,7 +31,7 @@ namespace FoxTube.Pages
/// </summary>
public sealed partial class PlaylistPage : Page
{
string playlistId;
public string playlistId;
Playlist item;
LoadingPage loading;
+6 -5
View File
@@ -42,9 +42,13 @@ namespace FoxTube
{
pivot.SelectedIndex = 1;
if ((string)e.Parameter != "feedback")
{
((pivot.Items[1] as PivotItem).Content as Feedback).PreDefine(Convert.ToBoolean((e.Parameter as string).Split('&', '=')[2]), (e.Parameter as string).Split('&', '=')[4]);
((pivot.SelectedItem as PivotItem).Content as Feedback).PreDefine(Convert.ToBoolean((e.Parameter as string).Split('&', '=')[2]), (e.Parameter as string).Split('&', '=')[4]);
}
else if ((e.Parameter as string).Contains("inbox"))
{
pivot.SelectedIndex = 4;
if ((string)e.Parameter != "inbox")
((pivot.SelectedItem as PivotItem).Content as Inbox).Open((e.Parameter as string).Split('&')[1]);
}
else
switch(e.Parameter as string)
@@ -55,9 +59,6 @@ namespace FoxTube
case "translate":
pivot.SelectedIndex = 3;
break;
case "inbox":
pivot.SelectedIndex = 4;
break;
}
}
}
+6 -6
View File
@@ -53,14 +53,14 @@
<ColumnDefinition/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<ScrollViewer>
<ScrollViewer Background="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}">
<StackPanel VerticalAlignment="Stretch">
<ComboBox Header="Filter" Margin="10" HorizontalAlignment="Stretch" SelectedIndex="0" Name="filter" SelectionChanged="filter_SelectionChanged">
<ComboBoxItem Content="All"/>
<ComboBoxItem Content="Messages"/>
<ComboBoxItem Content="Patch notes"/>
</ComboBox>
<ListBox Name="list" SelectionChanged="list_SelectionChanged">
<ListBox Name="list" SelectionChanged="list_SelectionChanged" Background="Transparent">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="10"/>
@@ -72,18 +72,18 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid Margin="0,0,10,0">
<Ellipse Fill="Red" Height="40" Width="40"/>
<TextBlock Foreground="White" FontFamily="Segoe MDL2 Assets" Text="{Binding Path=Icon}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Light" FontSize="17"/>
</Grid>
<StackPanel Grid.Column="1">
<TextBlock FontWeight="Bold" Text="{Binding Path=Title}"/>
<TextBlock Foreground="Gray" Text="{Binding Path=Subtitle}"/>
<TextBlock FontWeight="Bold" Text="{Binding Path=Title}" MaxLines="1" TextWrapping="Wrap"/>
<TextBlock Opacity=".5" Text="{Binding Path=Subtitle}"/>
</StackPanel>
<TextBlock Foreground="Gray" FontSize="13" Text="{Binding Path=TimeStamp}" Grid.Column="2"/>
<TextBlock Opacity=".5" FontSize="13" Text="{Binding Path=TimeStamp}" Grid.Column="2" TextWrapping="WrapWholeWords"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
+19 -11
View File
@@ -16,6 +16,7 @@ using FoxTube.Classes;
using System.Xml;
using Windows.Storage;
using System.Diagnostics;
using Windows.UI.Popups;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -26,7 +27,6 @@ namespace FoxTube.Pages.SettingsPages
/// </summary>
public sealed partial class Inbox : Page
{
public bool Loaded = false;
List<InboxItem> backup = new List<InboxItem>();
List<InboxItem> items = new List<InboxItem>();
public Inbox()
@@ -34,35 +34,36 @@ namespace FoxTube.Pages.SettingsPages
this.InitializeComponent();
}
public async void LoadItems()
public void LoadItems()
{
try
{
XmlDocument doc = new XmlDocument();
string path = @"Assets\Data\Patchnotes.xml";
StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile file = await InstallationFolder.GetFileAsync(path);
Stream Countries = await file.OpenStreamForReadAsync();
doc.Load(Countries);
doc.Load("http://foxgame.hol.es/foxtube-changelog.xml");
foreach (XmlElement e in doc["items"].ChildNodes)
items.Add(new InboxItem(
e.GetAttribute("version"),
e["content"].InnerText,
e.GetAttribute("time")
e.GetAttribute("time"),
e.GetAttribute("id")
));
doc.Load("http://foxgame.hol.es/ftp.xml");
doc.Load("http://foxgame.hol.es/foxtube-messages.xml");
foreach (XmlElement e in doc["posts"].ChildNodes)
items.Add(new InboxItem(
e["header"].InnerText,
e["content"].InnerText,
DateTime.Parse(e.GetAttribute("time"))
DateTime.Parse(e.GetAttribute("time")),
e.GetAttribute("id")
));
items.OrderBy(item => item.TimeStamp);
foreach (InboxItem i in items)
backup.Add(i);
}
catch { }
list.ItemsSource = items;
}
@@ -138,5 +139,12 @@ namespace FoxTube.Pages.SettingsPages
Debug.WriteLine("Closed");
}
}
public void Open(string id)
{
InboxItem item = items.Find(x => x.Id == id);
if(item != null)
list.SelectedIndex = items.IndexOf(item);
}
}
}