Archived
1
0

Feedback hub removed, Subscription page development, changelog notifications

This commit is contained in:
Michael Gordeev
2018-08-19 00:14:20 +03:00
parent 4c4f4ed967
commit bf4262426d
16 changed files with 306 additions and 385 deletions
+24 -22
View File
@@ -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)
+30 -82
View File
@@ -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&amp;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&amp;threadId=92187'/>
<action content='Like'
arguments='action=commentPhoto&amp;photoId=92187'/>
</actions>
</toast>");
break;
}
+4 -18
View File
@@ -36,28 +36,13 @@ namespace FoxTube
public void Initialize()
{
if (settings.Values["notificationsHistory"] != null)
try
{
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);
AddNotification(new Notification(n.ToString()));
}
catch { }
BackgroundProcessor.NotificationRecieved += NewNotification;
}
@@ -95,6 +80,7 @@ namespace FoxTube
Notification n = notifications[array.Children.IndexOf(sender as Button)];
switch(n.Type)
{
case NotificationType.Changelog:
case NotificationType.Internal:
Methods.MainPage.GoToDeveloper(n.Id);
break;
+7 -7
View File
@@ -130,9 +130,6 @@
<Compile Include="Pages\SettingsPages\About.xaml.cs">
<DependentUpon>About.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\SettingsPages\Feedback.xaml.cs">
<DependentUpon>Feedback.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\History.xaml.cs">
<DependentUpon>History.xaml</DependentUpon>
</Compile>
@@ -160,6 +157,9 @@
<Compile Include="Pages\PlaylistPage.xaml.cs">
<DependentUpon>PlaylistPage.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\Subscriptions.xaml.cs">
<DependentUpon>Subscriptions.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Pages\Search.xaml.cs">
<DependentUpon>Search.xaml</DependentUpon>
@@ -315,10 +315,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\SettingsPages\Feedback.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\History.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -367,6 +363,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\Subscriptions.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\VideoPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
+2 -4
View File
@@ -72,11 +72,9 @@ namespace FoxTube
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:troubleshoot"));
}
private void feedback_Click(object sender, RoutedEventArgs e)
private async void feedback_Click(object sender, RoutedEventArgs e)
{
Frame root = Window.Current.Content as Frame;
MainPage main = root.Content as MainPage;
main.PreDefineFeedback(true, string.Format("Exception:\n{0}\n\nMessage:\n{1}", exception, message));
await Windows.System.Launcher.LaunchUriAsync(new Uri("feedback-hub:"));
}
private void wifiRefresh_Click(object sender, RoutedEventArgs e)
+1 -1
View File
@@ -52,7 +52,7 @@
</NavigationView.AutoSuggestBox>
<NavigationView.Header>
<Grid Margin="10,-5,0,-11">
<Grid Margin="10,25,0,-11">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
+38 -25
View File
@@ -90,9 +90,17 @@ namespace FoxTube
if (settings.Values["defaultDownload"] == null)
settings.Values.Add("defaultDownload", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\DownloadedVideos");
if (settings.Values["notificationsHistory"] == null)
{
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
doc.AppendChild(doc.CreateElement("history"));
settings.Values.Add("notificationsHistory", doc.InnerXml);
}
PackageVersion ver = Package.Current.Id.Version;
if (settings.Values["ver"] == null)
settings.Values.Add("var", $"{ver.Major}.{ver.Minor}");
settings.Values.Add("ver", $"{ver.Major}.{ver.Minor}");
if((string)settings.Values["ver"] != $"{ver.Major}.{ver.Minor}")
{
@@ -106,12 +114,12 @@ namespace FoxTube
doc.LoadXml(settings.Values["notificationsHistory"] as string);
Background.Notification n = new Background.Notification("changelog",
$"changelog-{e.GetAttribute("version")}",
$"changelog-{e.GetAttribute("version").Replace('.', '-')}",
"Changelog",
$"What's new in version {e.GetAttribute("version")}",
XmlConvert.ToDateTimeOffset(e.GetAttribute("time"), "YYYY-MM-DDThh:mm:ss"),
"",
"");
$"What&apos;s new in version {e.GetAttribute("version")}",
DateTime.Parse(e.GetAttribute("time")),
"http://foxgame.hol.es/FoxTubeAssets/WhatsNewThumb.png",
"http://foxgame.hol.es/FoxTubeAssets/NewsAvatar.png");
doc["history"].InnerXml += n.GetXml();
settings.Values["notificationsHistory"] = doc.InnerXml;
@@ -137,14 +145,19 @@ namespace FoxTube
public void SetTitleBar()
{
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonForegroundColor = Colors.Black;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonHoverBackgroundColor = Colors.IndianRed;
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
if (RequestedTheme == ElementTheme.Dark)
titleBar.ButtonForegroundColor = Colors.White;
else if(RequestedTheme == ElementTheme.Light)
titleBar.ButtonForegroundColor = Colors.Black;
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = false;
coreTitleBar.ExtendViewIntoTitleBar = true;
}
private void SecretsVault_SubscriptionsChanged(object sender, params object[] args)
@@ -255,14 +268,9 @@ namespace FoxTube
notificationMenu.Content = "\xED0D";
}
private void feedback_Click(object sender, RoutedEventArgs e)
private async void feedback_Click(object sender, RoutedEventArgs e)
{
content.Navigate(typeof(Settings), "feedback");
}
public void PreDefineFeedback(bool isProblem, string meta)
{
content.Navigate(typeof(Settings), $"feedback&isProblem={isProblem}&meta={meta}");
await Launcher.LaunchUriAsync(new Uri("feedback-hub:"));
}
private async void createAccount_Click(object sender, RoutedEventArgs e)
@@ -447,7 +455,7 @@ namespace FoxTube
else if (args.SelectedItem == toLater)
content.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater);
else if (args.SelectedItem == toSubscriptions)
content.Navigate(typeof(Settings));
content.Navigate(typeof(Subscriptions));
else if (args.SelectedItem == toDownloads)
content.Navigate(typeof(Downloads));
else if (args.SelectedItem == toChannel)
@@ -468,6 +476,7 @@ namespace FoxTube
{ typeof(ChannelPage), () => header.Text = "Channel" },
{ typeof(PlaylistPage), () => header.Text = "Playlist" },
{ typeof(Search), () => header.Text = "Search" },
{ typeof(Subscriptions), () => header.Text = "Subscriptions" },
{ typeof(History), () => header.Text = "History" },
{ typeof(Home), () => header.Text = "Home" },
{ typeof(Downloads), () => header.Text = "Downloads" }
@@ -488,9 +497,9 @@ namespace FoxTube
nav.SelectedItem = nav.SettingsItem;
else
s = Sender.None;
} },
{ typeof(ChannelPage), () =>
{ typeof(ChannelPage), () =>
{
if((content.Content as ChannelPage).channelId == SecretsVault.AccountId)
{
@@ -512,14 +521,14 @@ namespace FoxTube
b = true;
break;
}
if(!b)
{
nav.SelectedItem = null;
}
}
} },
{ typeof(PlaylistPage), () =>
{ typeof(PlaylistPage), () =>
{
if((content.Content as PlaylistPage).playlistId == SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes)
{
@@ -540,10 +549,14 @@ namespace FoxTube
nav.SelectedItem = null;
}
} },
{ typeof(Search), () =>
{
nav.SelectedItem = null;
} },
{ typeof(Search), () => nav.SelectedItem = null },
{typeof(Subscriptions), () =>
{
if(nav.SelectedItem != toSubscriptions)
nav.SelectedItem = toSubscriptions;
else
s = Sender.None;
} },
{ typeof(History), () =>
{
if(nav.SelectedItem != toHistory)
-5
View File
@@ -16,11 +16,6 @@
<settingspages:General/>
</ScrollViewer>
</PivotItem>
<PivotItem Header="Leave a feedback">
<ScrollViewer>
<settingspages:Feedback/>
</ScrollViewer>
</PivotItem>
<PivotItem Header="About us">
<ScrollViewer>
<settingspages:About/>
+2 -8
View File
@@ -38,13 +38,7 @@ namespace FoxTube
base.OnNavigatedTo(e);
if(!string.IsNullOrWhiteSpace(e.Parameter as string))
{
if((e.Parameter as string).Contains("feedback"))
{
pivot.SelectedIndex = 1;
if ((string)e.Parameter != "feedback")
((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"))
if ((e.Parameter as string).Contains("inbox"))
{
pivot.SelectedIndex = 4;
if ((string)e.Parameter != "inbox")
@@ -65,7 +59,7 @@ namespace FoxTube
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (pivot.SelectedIndex == 4 && !inboxLoaded)
if (pivot.SelectedIndex == 3 && !inboxLoaded)
{
(((pivot.Items[4] as PivotItem).Content as ScrollViewer).Content as Inbox).LoadItems();
inboxLoaded = true;
+2 -1
View File
@@ -8,7 +8,7 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Padding="10" Name="grid">
<Grid Name="grid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
@@ -50,6 +50,7 @@
<HyperlinkButton Content="YouTube Community Guidelines" NavigateUri="https://youtube.com/t/community_guidelines" Padding="0,0,0,10"/>
<TextBlock Text="© 2018 Michael Gordeev"/>
<TextBlock Text="© 2018 YouTube, LLC"/>
<Button Content="Leave feedback" Margin="5" Click="Button_Click"/>
</StackPanel>
<Image Grid.Column="1" Source="/Assets/LogoAvatar.png" VerticalAlignment="Top" Width="128"/>
</Grid>
@@ -29,5 +29,10 @@ namespace FoxTube.Pages.SettingsPages
this.InitializeComponent();
version.Text = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("feedback-hub:"));
}
}
}
-60
View File
@@ -1,60 +0,0 @@
<Page
x:Class="FoxTube.Pages.SettingsPages.Feedback"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MaxWidth="1000"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Text="Feedback Hub" FontSize="28"/>
<TextBlock Text="What kind of feedback is it?" FontSize="18" Margin="0,10,0,0"/>
<StackPanel Orientation="Horizontal">
<RadioButton Name="suggestionRadio" Content="Suggestion" IsChecked="True"/>
<RadioButton Name="promblemRadio" Content="Problem"/>
</StackPanel>
<TextBlock Text="Tell us about it" FontSize="18" Margin="0,10,0,0"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<TextBox Name="subject" Grid.Column="0" HorizontalAlignment="Stretch" GotFocus="subject_GotFocus" Header="Summarize your issue (max 400 characters)" MaxLength="400"/>
<TextBlock Name="subjectMissed" Grid.Column="1" FontFamily="Segoe MDL2 Assets" Text="&#xE814;" Foreground="Red" FontSize="30" Visibility="Collapsed" VerticalAlignment="Bottom" Margin="1"/>
</Grid>
<TextBox Name="details" HorizontalAlignment="Stretch" Height="200" AcceptsReturn="True" ScrollViewer.VerticalScrollBarVisibility="Auto" MaxLength="1000" Margin="0,5,30,0" Header="Give us more detail (optional) (max 1000 characters)"/>
<CheckBox Content="I'd like to get response from developers" Name="emailToggle" Click="emailToggle_Click"/>
<TextBox Header="E-mail adress for response:" PlaceholderText="someone@example.com" IsEnabled="False" Name="email" Margin="0,5,30,0"/>
<StackPanel Orientation="Horizontal" BorderBrush="Green" BorderThickness="5" Margin="0,10,30,0" Name="debugAttached" Visibility="Collapsed">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE16C;" FontSize="40" Foreground="Green" Margin="5"/>
<StackPanel>
<TextBlock Text="Logs attached!" Foreground="Green" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="You don't have to attach error code or exception details to you feedback. We did it ourselves." Foreground="Green"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" BorderBrush="Green" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="greenResult">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE76E;" FontSize="40" Foreground="Green" Margin="5"/>
<StackPanel>
<TextBlock Text="Your feedback has been sent!" Foreground="Green" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="Thank you! It's very imortant for us. Thank you for helping us making the app better" Foreground="Green"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" BorderBrush="OrangeRed" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="cooldown">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7BA;" FontSize="40" Foreground="OrangeRed" Margin="5"/>
<StackPanel>
<TextBlock Text="You reached your daily feedback limit" Foreground="OrangeRed" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="To prevent spaming our mailbox we allow our users to send 1 feedback per day. Come back later to leave additional feedback." Foreground="OrangeRed"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="Submit feedback" Name="submit" Margin="0,10,10,10" Click="submit_Click" Background="{ThemeResource SystemControlForegroundAccentBrush}" Foreground="White"/>
<ProgressRing VerticalAlignment="Center" Name="ring" Foreground="Red"/>
</StackPanel>
</StackPanel>
</Grid>
</Page>
@@ -1,152 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Storage;
using System.Net.Mail;
using System.Net;
using Windows.UI.Popups;
using Windows.UI;
using System.Threading.Tasks;
using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages.SettingsPages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Feedback : Page
{
string debugData = "";
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
public Feedback()
{
this.InitializeComponent();
if (settings.Values["feedbackRecord"] == null)
settings.Values.Add("feedbackRecord", DateTimeToString(DateTime.Now - new TimeSpan(2, 0, 0, 0)));
TimeSpan interval = new TimeSpan(1, 0, 0, 0);
if(DateTime.Now - StringDateTime(settings.Values["feedbackRecord"].ToString()) < interval)
{
subject.IsEnabled = false;
details.IsEnabled = false;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = false;
submit.IsEnabled = false;
cooldown.Visibility = Visibility.Visible;
}
}
string DateTimeToString(DateTime dateTime)
{
string value = string.Format("{0} {1} {2} {3} {4} {5}", dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
Debug.WriteLine("Debag " + value);
return value;
}
DateTime StringDateTime(string value)
{
string[] t = value.Split(' ');
List<int> i = new List<int>();
foreach (string s in t)
i.Add(Convert.ToInt32(s));
return new DateTime(i[0], i[1], i[2], i[3], i[4], i[5]);
}
private async void submit_Click(object sender, RoutedEventArgs e)
{
//subject.Text = "This is test feedback";
//details.Text = "This is test for FoxTube Feedback System (FTFS)\nAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz 0123456789";
if (subject.Text == "")
{
subjectMissed.Visibility = Visibility.Visible;
subject.Background = new SolidColorBrush(Colors.Pink);
}
else
{
string Type()
{
if ((bool)suggestionRadio.IsChecked) return "Suggestion";
else return "Problem";
}
MailMessage msg = new MailMessage();
msg.To.Add("foxgameofficial+foxtube@gmail.com");
msg.From = new MailAddress("foxgameofficial+foxtube@gmail.com");
msg.Subject = "FoxTube feedback";
msg.Body = string.Format("Type: {0}\nTime: {1}\n\nTitle:\n{2}\n\nDetails:\n{3}\n\nResponse e-mail: {4}\n\nException details:\n{5}", Type(), DateTime.Now, subject.Text, details.Text, email.Text, debugData);
subject.IsEnabled = false;
details.IsEnabled = false;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = false;
submit.IsEnabled = false;
ring.IsActive = true;
await Task.Delay(1000);
Submit(msg);
}
}
async void Submit(MailMessage mes)
{
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = SecretsVault.EmailCredential;
try
{
client.Send(mes);
greenResult.Visibility = Visibility.Visible;
settings.Values["feedbackRecord"] = DateTimeToString(DateTime.Now);
}
catch
{
MessageDialog message = new MessageDialog("We was unable to send your feedback due to connection problems or internal server error. Please, try again later.", "Failed to send your feedback");
await message.ShowAsync();
subject.IsEnabled = true;
details.IsEnabled = true;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = true;
submit.IsEnabled = true;
}
ring.IsActive = false;
}
private void subject_GotFocus(object sender, RoutedEventArgs e)
{
subjectMissed.Visibility = Visibility.Collapsed;
subject.Background = new SolidColorBrush();
}
private void emailToggle_Click(object sender, RoutedEventArgs e)
{
email.IsEnabled = (bool)emailToggle.IsChecked;
}
public void PreDefine(bool isProblem, string meta)
{
if (isProblem)
{
promblemRadio.IsChecked = true;
suggestionRadio.IsChecked = false;
}
else
{
promblemRadio.IsChecked = false;
suggestionRadio.IsChecked = true;
}
debugData = meta;
debugAttached.Visibility = Visibility.Visible;
}
}
}
@@ -114,6 +114,8 @@ namespace FoxTube.Pages.SettingsPages
else
Methods.MainPage.RequestedTheme = ElementTheme.Light;
}
Methods.MainPage.SetTitleBar();
}
}
}
+159
View File
@@ -0,0 +1,159 @@
<Page
x:Class="FoxTube.Pages.Subscriptions"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<SemanticZoom Margin="5">
<SemanticZoom.ZoomedInView>
<GridView>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
<Button Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Padding="0" Width="200" Height="50" HorizontalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Height="36" Margin="5"/>
<TextBlock Grid.Column="1" FontSize="14" Text="Kuplinov Play" TextWrapping="WrapWholeWords" MaxLines="2" VerticalAlignment="Center"/>
</Grid>
</Button>
</GridView>
</SemanticZoom.ZoomedInView>
</SemanticZoom>
</Grid>
</Page>
+30
View File
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Subscriptions : Page
{
public Subscriptions()
{
this.InitializeComponent();
}
}
}