Archived
1
0

Broke everything; #220: Fixed

This commit is contained in:
Michael Gordeev
2018-12-09 13:41:00 +03:00
parent 1a6447a4aa
commit f16be876c6
19 changed files with 201 additions and 145 deletions
+21 -18
View File
@@ -24,30 +24,33 @@ namespace FoxTube.Background
public async void Run(IBackgroundTaskInstance taskInstance) public async void Run(IBackgroundTaskInstance taskInstance)
{ {
def = taskInstance.GetDeferral();
try try
{ {
if (settings.Values["lastCheck"] == null) def = taskInstance.GetDeferral();
settings.Values.Add("lastCheck", XmlConvert.ToString(DateTime.Now));
else lastCheck = XmlConvert.ToDateTime(settings.Values["lastCheck"] as string, XmlDateTimeSerializationMode.Unspecified);
}
catch
{
lastCheck = DateTime.Now;
}
ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, "Background task initialized. Retrieving videos since", lastCheck.ToString(), null, null)); if (settings.Values["lastCheck"] == null)
{
settings.Values.Add("lastCheck", DateTime.UtcNow.ToString());
def.Complete();
return;
}
else
lastCheck = DateTime.Parse(settings.Values["lastCheck"] as string);
//ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, $"{DateTime.Now} Retrieving videos since", lastCheck.ToString(), null, null));
bool[] notificationsSettings = JsonConvert.DeserializeObject<bool[]>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json"))); bool[] notificationsSettings = JsonConvert.DeserializeObject<bool[]>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json")));
if(notificationsSettings[0]) if (notificationsSettings[0])
CheckAnnouncements(); CheckAnnouncements();
if(notificationsSettings[1]) if (notificationsSettings[1])
CheckAccount(); CheckAccount();
}
settings.Values["lastCheck"] = XmlConvert.ToString(DateTime.Now, "YYYY-MM-DDThh:mm:ss"); catch { }
finally
{
settings.Values["lastCheck"] = DateTime.UtcNow.ToString();
def.Complete(); def.Complete();
ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, "Background task complete", DateTime.Now.ToString(), null, null)); }
} }
async void CheckAccount() async void CheckAccount()
@@ -77,8 +80,8 @@ namespace FoxTube.Background
try try
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
doc.Load(XmlReader.Create("http://foxgame.hol.es/foxtube-messages.xml")); doc.Load(XmlReader.Create("http://foxgame-studio.000webhostapp.com/foxtube-messages.xml"));
if ((XmlConvert.ToDateTimeOffset((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), "YYYY-MM-DDThh:mm:ss") - lastCheck.ToUniversalTime()).TotalSeconds > 0) if ((DateTime.Parse((doc["posts"].FirstChild as XmlElement).GetAttribute("time")) - lastCheck).TotalSeconds > 0)
ToastNotificationManager.CreateToastNotifier().Show( ToastNotificationManager.CreateToastNotifier().Show(
Notification.GetInternalToast(doc["posts"].FirstChild["id"].InnerText, Notification.GetInternalToast(doc["posts"].FirstChild["id"].InnerText,
doc["posts"].FirstChild["header"].InnerText, doc["posts"].FirstChild["header"].InnerText,
+1 -1
View File
@@ -11,7 +11,7 @@
<AssemblyName>FoxTube.Background</AssemblyName> <AssemblyName>FoxTube.Background</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage> <DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17134.0</TargetPlatformVersion> <TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion> <TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
+5 -5
View File
@@ -12,8 +12,8 @@ namespace FoxTube.Background
template.LoadXml($@"<toast activationType='foreground' launch='changelog|{version}'> template.LoadXml($@"<toast activationType='foreground' launch='changelog|{version}'>
<visual> <visual>
<binding template='ToastGeneric'> <binding template='ToastGeneric'>
<image placement='hero' src='http://foxgame.hol.es/FoxTubeAssets/WhatsNewThumb.png'/> <image placement='hero' src='http://foxgame-studio.000webhostapp.com/FoxTubeAssets/WhatsNewThumb.png'/>
<image placement='appLogoOverride' hint-crop='circle' src='http://foxgame.hol.es/FoxTubeAssets/NewsAvatar.png'/> <image placement='appLogoOverride' hint-crop='circle' src='http://foxgame-studio.000webhostapp.com/FoxTubeAssets/NewsAvatar.png'/>
<text>Changelog</text> <text>Changelog</text>
<text>See what's new in version {version}</text> <text>See what's new in version {version}</text>
</binding> </binding>
@@ -31,7 +31,7 @@ namespace FoxTube.Background
<visual> <visual>
<binding template='ToastGeneric'> <binding template='ToastGeneric'>
<image placement='hero' src='{thumbnail.Replace("&", "%26")}'/> <image placement='hero' src='{thumbnail.Replace("&", "%26")}'/>
<image placement='appLogoOverride' hint-crop='circle' src='{avatar.Replace("&", "%26") ?? "http://foxgame.hol.es/FoxTubeAssets/LogoAvatar.png"}'/> <image placement='appLogoOverride' hint-crop='circle' src='{avatar.Replace("&", "%26") ?? "http://foxgame-studio.000webhostapp.com/FoxTubeAssets/LogoAvatar.png"}'/>
<text>{title}</text> <text>{title}</text>
<text>{channel} uploaded a new video</text> <text>{channel} uploaded a new video</text>
</binding> </binding>
@@ -53,8 +53,8 @@ namespace FoxTube.Background
template.LoadXml($@"<toast activationType='foreground' launch='inbox|{id}'> template.LoadXml($@"<toast activationType='foreground' launch='inbox|{id}'>
<visual> <visual>
<binding template='ToastGeneric'> <binding template='ToastGeneric'>
<image placement='hero' src='{thumbnail ?? "http://foxgame.hol.es/FoxTubeAssets/AnnouncementThumb.png"}'/> <image placement='hero' src='{thumbnail ?? "http://foxgame-studio.000webhostapp.com/FoxTubeAssets/AnnouncementThumb.png"}'/>
<image placement='appLogoOverride' hint-crop='circle' src='{avatar ?? "http://foxgame.hol.es/FoxTubeAssets/LogoAvatar.png"}'/> <image placement='appLogoOverride' hint-crop='circle' src='{avatar ?? "http://foxgame-studio.000webhostapp.com/FoxTubeAssets/LogoAvatar.png"}'/>
<text>{header}</text> <text>{header}</text>
<text hint-maxLines='5'>{content}</text> <text hint-maxLines='5'>{content}</text>
</binding> </binding>
+14 -2
View File
@@ -1,5 +1,6 @@
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -13,6 +14,7 @@ using Windows.Globalization;
using Windows.Storage; using Windows.Storage;
using Windows.System.Power; using Windows.System.Power;
using Windows.UI.Notifications; using Windows.UI.Notifications;
using Windows.UI.Popups;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
@@ -258,10 +260,20 @@ namespace FoxTube
/// </summary> /// </summary>
/// <param name="sender">The source of the suspend request.</param> /// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param> /// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e) private async void OnSuspending(object sender, SuspendingEventArgs e)
{ {
var deferral = e.SuspendingOperation.GetDeferral(); var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity //await new MessageDialog("suspending").ShowAsync();
//Saving history
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(SecretsVault.UserHistory));
//Saving WL playlist
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(SecretsVault.WatchLater));
//Saving downloads
Methods.MainPage.Agent.QuitPrompt();
deferral.Complete(); deferral.Complete();
} }
} }
+7 -7
View File
@@ -7,6 +7,7 @@ using Newtonsoft.Json;
using Windows.UI.Popups; using Windows.UI.Popups;
using YoutubeExplode.Models.MediaStreams; using YoutubeExplode.Models.MediaStreams;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using Windows.Foundation;
namespace FoxTube.Controls namespace FoxTube.Controls
{ {
@@ -14,6 +15,7 @@ namespace FoxTube.Controls
{ {
public List<DownloadItem> items = new List<DownloadItem>(); public List<DownloadItem> items = new List<DownloadItem>();
StorageFolder roaming = ApplicationData.Current.RoamingFolder; StorageFolder roaming = ApplicationData.Current.RoamingFolder;
public IAsyncOperation<IUICommand> prompt;
public DownloadAgent() public DownloadAgent()
{ {
@@ -50,13 +52,13 @@ namespace FoxTube.Controls
items.Remove(item); items.Remove(item);
} }
public async void QuitPrompt() public void QuitPrompt()
{ {
if(items.Find(x => x.InProgress) != null) if(items.Exists(x => x.InProgress))
{ {
MessageDialog dialog = new MessageDialog("You have some unfinished downloads. Quitting now will erase all downloaded data. Are you sure to continue?", "Some downloads are still pending"); MessageDialog dialog = new MessageDialog($"Waiting pending downloads ({items.FindAll(x => x.InProgress).Count})...");
dialog.Commands.Add(new UICommand("Yes", async (command) => dialog.Commands.Add(new UICommand("Force quit", async (command) =>
{ {
foreach (DownloadItem i in items.FindAll(x => x.InProgress)) foreach (DownloadItem i in items.FindAll(x => x.InProgress))
i.Cancel(); i.Cancel();
@@ -70,10 +72,8 @@ namespace FoxTube.Controls
await roaming.CreateFileAsync("downloads.json", CreationCollisionOption.ReplaceExisting), await roaming.CreateFileAsync("downloads.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(containers)); JsonConvert.SerializeObject(containers));
})); }));
dialog.Commands.Add(new UICommand("No"));
dialog.DefaultCommandIndex = 1; prompt = dialog.ShowAsync();
await dialog.ShowAsync();
} }
} }
} }
+42 -39
View File
@@ -16,6 +16,24 @@ using Windows.UI.Popups;
namespace FoxTube namespace FoxTube
{ {
public class HistoryItem
{
public string Id { get; set; }
public double LeftOn { get; set; }
public HistoryItem(string id, TimeSpan elapsed, TimeSpan total)
{
Id = id;
LeftOn = elapsed.TotalSeconds / total.TotalSeconds * 100;
}
public HistoryItem(string id)
{
Id = id;
LeftOn = 0;
}
}
public static class SecretsVault public static class SecretsVault
{ {
public static event EventHandler AuthorizationStateChanged; public static event EventHandler AuthorizationStateChanged;
@@ -40,7 +58,7 @@ namespace FoxTube
public static Channel UserChannel { get; private set; } public static Channel UserChannel { get; private set; }
public static List<string> WatchLater { get; private set; } = new List<string>(); public static List<string> WatchLater { get; private set; } = new List<string>();
public static List<string> UserHistory { get; private set; } = new List<string>(); public static List<HistoryItem> UserHistory { get; private set; } = new List<HistoryItem>();
public static List<Subscription> Subscriptions { get; private set; } = new List<Subscription>(); public static List<Subscription> Subscriptions { get; private set; } = new List<Subscription>();
public static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer() public static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer()
@@ -59,35 +77,13 @@ namespace FoxTube
} }
} }
public static async void HistoryAdd(string id) public static void HistoryAdd(string id, TimeSpan elapsed, TimeSpan total)
{ {
UserHistory.Remove(id); UserHistory.Remove(UserHistory.Find(x => x.Id == id));
UserHistory.Add(id); UserHistory.Add(new HistoryItem(id, elapsed, total));
if (UserHistory.Count > 100) if (UserHistory.Count > 100)
UserHistory.RemoveAt(UserHistory.Count - 1); UserHistory.RemoveAt(UserHistory.Count - 1);
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(UserHistory));
}
public static async void LaterAdd(string id)
{
WatchLater.Add(id);
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(UserHistory));
}
public static async void LaterRemove(string id)
{
WatchLater.Remove(id);
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(UserHistory));
} }
public static async Task<bool> ChangeSubscriptionState(string id) public static async Task<bool> ChangeSubscriptionState(string id)
@@ -95,7 +91,7 @@ namespace FoxTube
if (!IsAuthorized) if (!IsAuthorized)
return false; return false;
if(Subscriptions.Find(x => x.Snippet.ResourceId.ChannelId == id) != null) if(Subscriptions.Exists(x => x.Snippet.ResourceId.ChannelId == id))
{ {
Subscription s = Subscriptions.Find(x => x.Snippet.ResourceId.ChannelId == id); Subscription s = Subscriptions.Find(x => x.Snippet.ResourceId.ChannelId == id);
@@ -151,6 +147,8 @@ namespace FoxTube
return false; return false;
Subscriptions.Add(s); Subscriptions.Add(s);
SubscriptionsChanged.Invoke(null, "add", s); SubscriptionsChanged.Invoke(null, "add", s);
SaveSubscriptions();
return true; return true;
} }
@@ -213,27 +211,28 @@ namespace FoxTube
try try
{ {
await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json"); await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json");
UserHistory = JsonConvert.DeserializeObject<List<HistoryItem>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json")));
} }
catch (FileNotFoundException) catch
{ {
await FileIO.WriteTextAsync( await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting), await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(new List<string>())); JsonConvert.SerializeObject(new List<HistoryItem>()));
UserHistory = new List<HistoryItem>();
} }
try try
{ {
await ApplicationData.Current.RoamingFolder.GetFileAsync("watchlater.json"); await ApplicationData.Current.RoamingFolder.GetFileAsync("watchlater.json");
WatchLater = JsonConvert.DeserializeObject<List<string>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("watchlater.json")));
} }
catch (FileNotFoundException) catch
{ {
await FileIO.WriteTextAsync( await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting), await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(new List<string>())); JsonConvert.SerializeObject(new List<string>()));
WatchLater = new List<string>();
} }
UserHistory = JsonConvert.DeserializeObject<List<string>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json")));
WatchLater = JsonConvert.DeserializeObject<List<string>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("watchlater.json")));
/*PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet"); /*PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet");
playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchHistory; playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchHistory;
playlistRequest.MaxResults = 50; playlistRequest.MaxResults = 50;
@@ -280,12 +279,7 @@ namespace FoxTube
foreach (Subscription s in subResponse.Items) foreach (Subscription s in subResponse.Items)
Subscriptions.Add(s); Subscriptions.Add(s);
} }
SaveSubscriptions();
Dictionary<string, string> subs = new Dictionary<string, string>();
Subscriptions.ForEach(x => subs.Add(x.Snippet.ResourceId.ChannelId, x.Snippet.Thumbnails.Medium.Url));
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("background.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(subs));
} }
catch catch
{ {
@@ -309,6 +303,15 @@ namespace FoxTube
AuthorizationStateChanged.Invoke(null, null); AuthorizationStateChanged.Invoke(null, null);
} }
public static async void SaveSubscriptions()
{
Dictionary<string, string> subs = new Dictionary<string, string>();
Subscriptions.ForEach(x => subs.Add(x.Snippet.ResourceId.ChannelId, x.Snippet.Thumbnails.Medium.Url));
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("background.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(subs));
}
public static async void Deauthenticate() public static async void Deauthenticate()
{ {
if(await Credential.RevokeTokenAsync(CancellationToken.None)) if(await Credential.RevokeTokenAsync(CancellationToken.None))
+1
View File
@@ -15,6 +15,7 @@ using Windows.UI.Popups;
using Windows.Storage.Pickers; using Windows.Storage.Pickers;
using Windows.UI.Notifications; using Windows.UI.Notifications;
using Microsoft.Toolkit.Uwp.Notifications; using Microsoft.Toolkit.Uwp.Notifications;
using Windows.Foundation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
+1
View File
@@ -22,6 +22,7 @@
<StackPanel Margin="5" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="5,2,5,2" BorderBrush="Gray" BorderThickness="1"> <StackPanel Margin="5" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="5,2,5,2" BorderBrush="Gray" BorderThickness="1">
<TextBlock Text="Watched" Foreground="Gray" FontSize="12"/> <TextBlock Text="Watched" Foreground="Gray" FontSize="12"/>
</StackPanel> </StackPanel>
<ProgressBar VerticalAlignment="Bottom" Margin="54,0,0,0" Foreground="Red" Name="leftOn"/>
</Grid> </Grid>
<StackPanel Margin="0,0,5,5" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3"> <StackPanel Margin="0,0,5,5" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3">
<TextBlock Name="info" Text="[Duration] | [Published at]" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="12"/> <TextBlock Name="info" Text="[Duration] | [Published at]" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="12"/>
+4 -1
View File
@@ -82,8 +82,11 @@ namespace FoxTube.Controls
} }
catch { } catch { }
if(SecretsVault.UserHistory.Contains(videoId)) if(SecretsVault.UserHistory.Exists(x => x.Id == videoId))
{
watched.Visibility = Visibility.Visible; watched.Visibility = Visibility.Visible;
leftOn.Value = SecretsVault.UserHistory.Find(x => x.Id == videoId).LeftOn;
}
} }
public async void Button_Click(object sender, RoutedEventArgs e) public async void Button_Click(object sender, RoutedEventArgs e)
+6 -2
View File
@@ -134,7 +134,7 @@ namespace FoxTube
else else
s = (string)settings.Values["quality"]; s = (string)settings.Values["quality"];
if (quality.Items.ToList().Find(x => (x as ComboBoxItem).Content as string == s) != null) if (quality.Items.ToList().Exists(x => (x as ComboBoxItem).Content as string == s))
quality.SelectedItem = quality.Items.First(x => (x as ComboBoxItem).Content as string == s); quality.SelectedItem = quality.Items.First(x => (x as ComboBoxItem).Content as string == s);
else else
quality.SelectedItem = quality.Items.First(); quality.SelectedItem = quality.Items.First();
@@ -203,6 +203,8 @@ namespace FoxTube
systemControls.ButtonPressed += SystemControls_Engaged; systemControls.ButtonPressed += SystemControls_Engaged;
systemControls.IsEnabled = true; systemControls.IsEnabled = true;
SecretsVault.HistoryAdd(videoId, elapsed, total);
t.Start(); t.Start();
Visibility = Visibility.Visible; Visibility = Visibility.Visible;
@@ -348,7 +350,7 @@ namespace FoxTube
settings.Values["rememberedQuality"] = (quality.SelectedItem as ComboBoxItem).Content as string; settings.Values["rememberedQuality"] = (quality.SelectedItem as ComboBoxItem).Content as string;
if(streamInfo.Muxed.ToList().Find(x => x.VideoQualityLabel == (quality.SelectedItem as ComboBoxItem).Content as string) != null) if(streamInfo.Muxed.ToList().Exists(x => x.VideoQualityLabel == (quality.SelectedItem as ComboBoxItem).Content as string))
{ {
isMuxed = true; isMuxed = true;
videoSource.Source = streamInfo.Muxed.First(x => x.VideoQualityLabel == (quality.SelectedItem as ComboBoxItem).Content as string).Url.ToUri(); videoSource.Source = streamInfo.Muxed.First(x => x.VideoQualityLabel == (quality.SelectedItem as ComboBoxItem).Content as string).Url.ToUri();
@@ -612,6 +614,8 @@ namespace FoxTube
systemControls.PlaybackStatus = MediaPlaybackStatus.Closed; systemControls.PlaybackStatus = MediaPlaybackStatus.Closed;
break; break;
} }
SecretsVault.HistoryAdd(videoId, elapsed, total);
} }
private async void miniView_Click(object sender, RoutedEventArgs e) private async void miniView_Click(object sender, RoutedEventArgs e)
+1 -1
View File
@@ -11,7 +11,7 @@
<AssemblyName>FoxTube</AssemblyName> <AssemblyName>FoxTube</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage> <DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17134.0</TargetPlatformVersion> <TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion> <TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
+2 -1
View File
@@ -19,7 +19,8 @@
<ScrollViewer Name="scroll"> <ScrollViewer Name="scroll">
<local:VideoGrid/> <local:VideoGrid/>
</ScrollViewer> </ScrollViewer>
<CommandBar Grid.Row="1"> <CommandBar Grid.Row="1" DefaultLabelPosition="Right">
<AppBarButton LabelPosition="Default" Icon="Help" Label="Missing some stuff?" Name="help" Click="help_Click"/>
<AppBarButton Label="Open in browser" Icon="Globe" Name="toBrowser" Click="toBrowser_Click"/> <AppBarButton Label="Open in browser" Icon="Globe" Name="toBrowser" Click="toBrowser_Click"/>
</CommandBar> </CommandBar>
<foxtube:LoadingPage Visibility="Collapsed" Grid.RowSpan="2"/> <foxtube:LoadingPage Visibility="Collapsed" Grid.RowSpan="2"/>
+6 -1
View File
@@ -36,7 +36,7 @@ namespace FoxTube.Pages
loading.Refresh(); loading.Refresh();
list.Clear(); list.Clear();
SecretsVault.UserHistory.ForEach(i => list.Add(new VideoCard(i))); SecretsVault.UserHistory.ForEach(i => list.Add(new VideoCard(i.Id)));
loading.Close(); loading.Close();
} }
@@ -45,5 +45,10 @@ namespace FoxTube.Pages
{ {
await Launcher.LaunchUriAsync(new Uri("youtube.com/feed/history")); await Launcher.LaunchUriAsync(new Uri("youtube.com/feed/history"));
} }
private void help_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToDeveloper("local-history");
}
} }
} }
+26 -25
View File
@@ -33,47 +33,48 @@
</NavigationView.MenuItems> </NavigationView.MenuItems>
<NavigationView.PaneFooter> <NavigationView.PaneFooter>
<StackPanel> <NavigationViewList>
<Button Visibility="Visible" Name="feedback" Click="feedback_Click" Height="40" HorizontalAlignment="Stretch" Background="Transparent" HorizontalContentAlignment="Left"> <NavigationViewItem x:Uid="/Main/feedback" Name="feedback" Content="Give a feedback" Tapped="feedback_Click">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xED15;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem x:Uid="/Main/adsFree" Content="Remove ads" Visibility="Collapsed" Name="removeAds">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE14D;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Name="account" Tapped="openContext">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xED15;" FontSize="16" Margin="6,0,16,0"/> <FontIcon Glyph="&#xE8FA;" FontSize="16" Margin="0,0,16,0"/>
<TextBlock x:Uid="/Main/feedback" Text="Give a feedback"/>
</StackPanel>
</Button>
<Button Visibility="Collapsed" Name="removeAds" Height="40" HorizontalAlignment="Stretch" Background="Transparent" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE14D;" FontSize="16" Margin="6,0,16,0"/>
<TextBlock x:Uid="/Main/adsFree" Text="Remove ads"/>
</StackPanel>
</Button>
<Button Visibility="Visible" Name="account" Height="40" HorizontalAlignment="Stretch" Background="Transparent" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE8FA;" FontSize="16" Margin="6,0,16,0"/>
<TextBlock x:Uid="/Main/signIn" Text="Add account"/> <TextBlock x:Uid="/Main/signIn" Text="Add account"/>
</StackPanel> </StackPanel>
<Button.Flyout> <NavigationViewItem.ContextFlyout>
<MenuFlyout> <MenuFlyout>
<MenuFlyoutItem x:Uid="/Main/signEx" Text="Sign in with existing account" Name="signIn" Click="signIn_Click"/> <MenuFlyoutItem x:Uid="/Main/signEx" Text="Sign in with existing account" Name="signIn" Click="signIn_Click"/>
<MenuFlyoutItem x:Uid="/Main/signNew" Text="Create new Google account" Name="createAccount" Click="createAccount_Click"/> <MenuFlyoutItem x:Uid="/Main/signNew" Text="Create new Google account" Name="createAccount" Click="createAccount_Click"/>
</MenuFlyout> </MenuFlyout>
</Button.Flyout> </NavigationViewItem.ContextFlyout>
</Button> </NavigationViewItem>
<Button Visibility="Collapsed" Name="avatar" Height="40" HorizontalAlignment="Stretch" Background="Transparent" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal"> <NavigationViewItem Visibility="Collapsed" Name="avatar" Tapped="openContext" Padding="-5">
<PersonPicture Height="23" Margin="3,0,12,0"/> <StackPanel Orientation="Horizontal" Padding="5">
<PersonPicture Height="20" Margin="-5,0,15,0"/>
<TextBlock Name="myName" Text="My account"/> <TextBlock Name="myName" Text="My account"/>
</StackPanel> </StackPanel>
<Button.Flyout> <NavigationViewItem.ContextFlyout>
<MenuFlyout> <MenuFlyout>
<MenuFlyoutItem x:Uid="/Main/myChannelContext" Text="My channel" Name="myChannel" Click="myChannel_Click"/> <MenuFlyoutItem x:Uid="/Main/myChannelContext" Text="My channel" Name="myChannel" Click="myChannel_Click"/>
<MenuFlyoutSeparator/> <MenuFlyoutSeparator/>
<MenuFlyoutItem x:Uid="/Main/signOut" Text="Log out" Name="logout" Click="logout_Click"/> <MenuFlyoutItem x:Uid="/Main/signOut" Text="Log out" Name="logout" Click="logout_Click"/>
</MenuFlyout> </MenuFlyout>
</Button.Flyout> </NavigationViewItem.ContextFlyout>
</Button> </NavigationViewItem>
</StackPanel> </NavigationViewList>
</NavigationView.PaneFooter> </NavigationView.PaneFooter>
<NavigationView.AutoSuggestBox> <NavigationView.AutoSuggestBox>
+33 -9
View File
@@ -81,7 +81,7 @@ namespace FoxTube
try try
{ {
XmlDocument changelog = new XmlDocument(); XmlDocument changelog = new XmlDocument();
changelog.Load("http://foxgame.hol.es/foxtube-changelog.xml"); changelog.Load("http://foxgame-studio.000webhostapp.com/foxtube-changelog.xml");
XmlElement e = changelog["items"].ChildNodes[0] as XmlElement; XmlElement e = changelog["items"].ChildNodes[0] as XmlElement;
ToastNotificationManager.CreateToastNotifier().Show(FoxTube.Background.Notification.GetChangelogToast(e.GetAttribute("version"))); ToastNotificationManager.CreateToastNotifier().Show(FoxTube.Background.Notification.GetChangelogToast(e.GetAttribute("version")));
@@ -100,6 +100,11 @@ namespace FoxTube
Initialize(); Initialize();
} }
async void GetVideosFromToday()
{
}
public async void Initialize() public async void Initialize()
{ {
if (await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json") != null) if (await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json") != null)
@@ -130,7 +135,7 @@ namespace FoxTube
titleBar.ButtonBackgroundColor = Colors.Red; titleBar.ButtonBackgroundColor = Colors.Red;
titleBar.ButtonHoverBackgroundColor = Colors.IndianRed; titleBar.ButtonHoverBackgroundColor = Colors.IndianRed;
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed; titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
titleBar.ButtonInactiveBackgroundColor = Colors.DarkRed; titleBar.ButtonInactiveBackgroundColor = Colors.Black;
titleBar.ForegroundColor = Colors.White; titleBar.ForegroundColor = Colors.White;
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false; CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false;
@@ -141,18 +146,23 @@ namespace FoxTube
if ((string)args[0] == "add" && nav.MenuItems.Count < 19) if ((string)args[0] == "add" && nav.MenuItems.Count < 19)
{ {
Subscription s = args[1] as Subscription; Subscription s = args[1] as Subscription;
StackPanel panel = new StackPanel() { Orientation = Orientation.Horizontal }; StackPanel panel = new StackPanel()
{
Orientation = Orientation.Horizontal,
Padding = new Thickness(5)
};
panel.Children.Add(new PersonPicture() panel.Children.Add(new PersonPicture()
{ {
Height = 20, Height = 20,
Margin = new Thickness(0, 0, 13, 0), Margin = new Thickness(-5, 0, 15, 0),
ProfilePicture = new BitmapImage(new Uri(s.Snippet.Thumbnails.Medium.Url)) ProfilePicture = new BitmapImage(new Uri(s.Snippet.Thumbnails.Medium.Url))
}); });
panel.Children.Add(new TextBlock() { Text = s.Snippet.Title }); panel.Children.Add(new TextBlock() { Text = s.Snippet.Title });
nav.MenuItems.Add(new NavigationViewItem() nav.MenuItems.Add(new NavigationViewItem()
{ {
Content = panel, Content = panel,
Name = (nav.MenuItems.Count - 9).ToString() Name = (nav.MenuItems.Count - 9).ToString(),
Padding = new Thickness(-5)
}); });
} }
else if ((string)args[0] == "remove" && (int)args[1] < 10) else if ((string)args[0] == "remove" && (int)args[1] < 10)
@@ -190,18 +200,23 @@ namespace FoxTube
try try
{ {
Subscription s = SecretsVault.Subscriptions[k]; Subscription s = SecretsVault.Subscriptions[k];
StackPanel panel = new StackPanel() { Orientation = Orientation.Horizontal }; StackPanel panel = new StackPanel()
{
Orientation = Orientation.Horizontal,
Padding = new Thickness(5)
};
panel.Children.Add(new PersonPicture() panel.Children.Add(new PersonPicture()
{ {
Height = 20, Height = 20,
Margin = new Thickness(0, 0, 13, 0), Margin = new Thickness(-5, 0, 15, 0),
ProfilePicture = new BitmapImage(new Uri(s.Snippet.Thumbnails.Medium.Url)) ProfilePicture = new BitmapImage(new Uri(s.Snippet.Thumbnails.Medium.Url))
}); });
panel.Children.Add(new TextBlock() { Text = s.Snippet.Title }); panel.Children.Add(new TextBlock() { Text = s.Snippet.Title });
nav.MenuItems.Add(new NavigationViewItem() nav.MenuItems.Add(new NavigationViewItem()
{ {
Content = panel, Content = panel,
Name = k.ToString() Name = k.ToString(),
Padding = new Thickness(-5)
}); });
} }
catch { continue; } catch { continue; }
@@ -234,7 +249,7 @@ namespace FoxTube
GoToVideo((videoPlaceholder.Content as VideoPage).videoId); GoToVideo((videoPlaceholder.Content as VideoPage).videoId);
} }
private async void feedback_Click(object sender, RoutedEventArgs e) private async void feedback_Click(object sender, TappedRoutedEventArgs e)
{ {
await Launcher.LaunchUriAsync(new Uri("feedback-hub:")); await Launcher.LaunchUriAsync(new Uri("feedback-hub:"));
} }
@@ -465,6 +480,8 @@ namespace FoxTube
} }
private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
try
{ {
if (s == Sender.None) if (s == Sender.None)
{ {
@@ -494,6 +511,8 @@ namespace FoxTube
else else
s = Sender.None; s = Sender.None;
} }
catch { }
}
public void content_Navigated(object sender, NavigationEventArgs e) public void content_Navigated(object sender, NavigationEventArgs e)
{ {
@@ -681,5 +700,10 @@ namespace FoxTube
(videoPlaceholder.Content as VideoPage).player.KeyUpPressed(sender, e); (videoPlaceholder.Content as VideoPage).player.KeyUpPressed(sender, e);
} }
} }
private void openContext(object sender, TappedRoutedEventArgs e)
{
((NavigationViewItem)sender).ContextFlyout.ShowAt((NavigationViewItem)sender);
}
} }
} }
+2 -2
View File
@@ -40,14 +40,14 @@ namespace FoxTube.Pages.SettingsPages
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
doc.Load("http://foxgame.hol.es/foxtube-changelog.xml"); doc.Load("http://foxgame-studio.000webhostapp.com/foxtube-changelog.xml");
foreach (XmlElement e in doc["items"].ChildNodes) foreach (XmlElement e in doc["items"].ChildNodes)
items.Add(new InboxItem( items.Add(new InboxItem(
e.GetAttribute("version"), e.GetAttribute("version"),
e["content"].InnerText, e["content"].InnerText,
e.GetAttribute("time"))); e.GetAttribute("time")));
doc.Load("http://foxgame.hol.es/foxtube-messages.xml"); doc.Load("http://foxgame-studio.000webhostapp.com/foxtube-messages.xml");
foreach (XmlElement e in doc["posts"].ChildNodes) foreach (XmlElement e in doc["posts"].ChildNodes)
items.Add(new InboxItem( items.Add(new InboxItem(
e["header"].InnerText, e["header"].InnerText,
-2
View File
@@ -208,8 +208,6 @@ namespace FoxTube.Pages
} }
} }
subscribe.Visibility = Visibility.Visible; subscribe.Visibility = Visibility.Visible;
SecretsVault.HistoryAdd(videoId);
} }
else else
{ {
+2 -2
View File
@@ -117,13 +117,13 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="adsFree.Text" xml:space="preserve"> <data name="adsFree.Content" xml:space="preserve">
<value>Remove ads</value> <value>Remove ads</value>
</data> </data>
<data name="downloads.Content" xml:space="preserve"> <data name="downloads.Content" xml:space="preserve">
<value>Downloads</value> <value>Downloads</value>
</data> </data>
<data name="feedback.Text" xml:space="preserve"> <data name="feedback.Content" xml:space="preserve">
<value>Give a feedback</value> <value>Give a feedback</value>
</data> </data>
<data name="history.Content" xml:space="preserve"> <data name="history.Content" xml:space="preserve">
+2 -2
View File
@@ -117,13 +117,13 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="adsFree.Text" xml:space="preserve"> <data name="adsFree.Content" xml:space="preserve">
<value>Убрать рекламу</value> <value>Убрать рекламу</value>
</data> </data>
<data name="downloads.Content" xml:space="preserve"> <data name="downloads.Content" xml:space="preserve">
<value>Загрузки</value> <value>Загрузки</value>
</data> </data>
<data name="feedback.Text" xml:space="preserve"> <data name="feedback.Content" xml:space="preserve">
<value>Оставить отзыв</value> <value>Оставить отзыв</value>
</data> </data>
<data name="history.Content" xml:space="preserve"> <data name="history.Content" xml:space="preserve">