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
+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;"
+137 -23
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)
@@ -375,15 +410,22 @@ namespace FoxTube
{
if(search.Text.Length > 2)
{
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}");
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}");
List<string> suggestions = new List<string>();
List<string> suggestions = new List<string>();
for (int i = 0; i < doc["toplevel"].ChildNodes.Count && i < 5; i++)
suggestions.Add(doc["toplevel"].ChildNodes[i]["suggestion"].GetAttribute("data"));
for (int i = 0; i < doc["toplevel"].ChildNodes.Count && i < 5; i++)
suggestions.Add(doc["toplevel"].ChildNodes[i]["suggestion"].GetAttribute("data"));
search.ItemsSource = suggestions;
search.ItemsSource = suggestions;
}
catch (System.Net.WebException)
{
search.ItemsSource = new List<string>();
}
}
}
@@ -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;
+7 -6
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>
+33 -25
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()
{
XmlDocument doc = new XmlDocument();
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("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("id")
));
doc.Load(Countries);
foreach (XmlElement e in doc["items"].ChildNodes)
items.Add(new InboxItem(
e.GetAttribute("version"),
e["content"].InnerText,
e.GetAttribute("time")
));
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")),
e.GetAttribute("id")
));
doc.Load("http://foxgame.hol.es/ftp.xml");
foreach (XmlElement e in doc["posts"].ChildNodes)
items.Add(new InboxItem(
e["header"].InnerText,
e["content"].InnerText,
DateTime.Parse(e.GetAttribute("time"))
));
items.OrderBy(item => item.TimeStamp);
items.OrderBy(item => item.TimeStamp);
foreach (InboxItem i in items)
backup.Add(i);
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);
}
}
}