Development 110218
This commit is contained in:
+120
-9
@@ -1,11 +1,18 @@
|
||||
using System;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.ApplicationModel.Background;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.Globalization;
|
||||
using Windows.Storage;
|
||||
using Windows.System.Power;
|
||||
using Windows.UI.Notifications;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
@@ -94,12 +101,124 @@ namespace FoxTube
|
||||
}
|
||||
|
||||
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
|
||||
ActivateToastBackgoundTask();
|
||||
ActivateBackgoundTask();
|
||||
}
|
||||
|
||||
public async void ActivateToastBackgoundTask()
|
||||
{
|
||||
const string taskName = "FoxtubeToastBackground";
|
||||
if (BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals(taskName)))
|
||||
return;
|
||||
|
||||
var backgroundRequest = await BackgroundExecutionManager.RequestAccessAsync();
|
||||
var saverRequest = PowerManager.EnergySaverStatus;
|
||||
if (backgroundRequest == BackgroundAccessStatus.DeniedBySystemPolicy || backgroundRequest == BackgroundAccessStatus.DeniedByUser)
|
||||
return;
|
||||
|
||||
BackgroundTaskBuilder builder = new BackgroundTaskBuilder() { Name = taskName };
|
||||
builder.SetTrigger(new ToastNotificationActionTrigger());
|
||||
|
||||
BackgroundTaskRegistration registration = builder.Register();
|
||||
}
|
||||
|
||||
public async void ActivateBackgoundTask()
|
||||
{
|
||||
const string taskName = "FoxtubeBackgound";
|
||||
Debug.WriteLine($"Background task active: {BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals(taskName))}");
|
||||
if (BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals(taskName)))
|
||||
return;
|
||||
|
||||
var backgroundRequest = await BackgroundExecutionManager.RequestAccessAsync();
|
||||
var saverRequest = PowerManager.EnergySaverStatus;
|
||||
if (backgroundRequest == BackgroundAccessStatus.DeniedBySystemPolicy || backgroundRequest == BackgroundAccessStatus.DeniedByUser || saverRequest == EnergySaverStatus.On)
|
||||
return;
|
||||
|
||||
BackgroundTaskBuilder builder = new BackgroundTaskBuilder()
|
||||
{
|
||||
Name = taskName,
|
||||
IsNetworkRequested = true,
|
||||
TaskEntryPoint = "FoxTube.Background.BackgroundProcessor"
|
||||
};
|
||||
builder.SetTrigger(new TimeTrigger(15, false));
|
||||
|
||||
BackgroundTaskRegistration registration = builder.Register();
|
||||
Debug.WriteLine($"2. Background task active: {BackgroundTaskRegistration.AllTasks.Any(i => i.Value.Name.Equals(taskName))}");
|
||||
}
|
||||
|
||||
protected async override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
|
||||
{
|
||||
var deferral = args.TaskInstance.GetDeferral();
|
||||
base.OnBackgroundActivated(args);
|
||||
|
||||
if (args.TaskInstance.Task.Name == "FoxtubeToastBackground")
|
||||
{
|
||||
var details = args.TaskInstance.TriggerDetails as ToastNotificationActionTriggerDetail;
|
||||
if (details != null)
|
||||
{
|
||||
string[] arguments = details.Argument.Split('|');
|
||||
|
||||
switch(arguments[0])
|
||||
{
|
||||
case "dcancel":
|
||||
Debug.WriteLine("Cancel has been required");
|
||||
try { Methods.MainPage.Agent.Remove(arguments[1]); }
|
||||
catch { }
|
||||
break;
|
||||
case "later":
|
||||
try
|
||||
{
|
||||
if(!SecretsVault.IsAuthorized)
|
||||
SecretsVault.CheckAuthorization(false);
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
throw new Exception("Not authenticated");
|
||||
|
||||
PlaylistItem item = new PlaylistItem()
|
||||
{
|
||||
Snippet = new PlaylistItemSnippet()
|
||||
{
|
||||
ResourceId = new ResourceId()
|
||||
{
|
||||
Kind = "youtube#video",
|
||||
VideoId = arguments[1]
|
||||
},
|
||||
PlaylistId = "WL"
|
||||
}
|
||||
};
|
||||
|
||||
await SecretsVault.Service.PlaylistItems.Insert(item, "snippet").ExecuteAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deferral.Complete();
|
||||
}
|
||||
|
||||
protected override void OnActivated(IActivatedEventArgs e)
|
||||
{
|
||||
base.OnActivated(e);
|
||||
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
if (rootFrame == null)
|
||||
{
|
||||
rootFrame = new Frame();
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
if (rootFrame.Content == null)
|
||||
{
|
||||
rootFrame.Navigate(typeof(MainPage));
|
||||
}
|
||||
|
||||
if (e is ToastNotificationActivatedEventArgs)
|
||||
{
|
||||
string[] args = (e as ToastNotificationActivatedEventArgs).Argument.Split('|');
|
||||
@@ -114,17 +233,9 @@ namespace FoxTube
|
||||
Methods.MainPage.GoToVideo(args[1]);
|
||||
break;
|
||||
|
||||
case "dcancel":
|
||||
Methods.MainPage.Agent.Remove(args[1]);
|
||||
break;
|
||||
|
||||
case "channel":
|
||||
Methods.MainPage.GoToChannel(args[1]);
|
||||
break;
|
||||
|
||||
case "later":
|
||||
//Add to WL playlist
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace FoxTube.Controls
|
||||
{
|
||||
try
|
||||
{
|
||||
List<DownloadItemContainer> containers = JsonConvert.DeserializeObject<List<DownloadItemContainer>>(await FileIO.ReadTextAsync(await roaming.GetFileAsync("data.json")));
|
||||
List<DownloadItemContainer> containers = JsonConvert.DeserializeObject<List<DownloadItemContainer>>(await FileIO.ReadTextAsync(await roaming.GetFileAsync("downloads.json")));
|
||||
|
||||
foreach (DownloadItemContainer i in containers)
|
||||
try { items.Add(new DownloadItem(i)); }
|
||||
@@ -67,7 +67,7 @@ namespace FoxTube.Controls
|
||||
containers.Add(i.Container);
|
||||
|
||||
await FileIO.WriteTextAsync(
|
||||
await roaming.CreateFileAsync("data.json", CreationCollisionOption.ReplaceExisting),
|
||||
await roaming.CreateFileAsync("downloads.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(containers));
|
||||
}));
|
||||
dialog.Commands.Add(new UICommand("No"));
|
||||
|
||||
@@ -9,6 +9,7 @@ using Google.Apis.Auth.OAuth2.Flows;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using Newtonsoft.Json;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Popups;
|
||||
|
||||
@@ -149,8 +150,8 @@ namespace FoxTube
|
||||
Subscriptions.Remove(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static async void Authorize()
|
||||
|
||||
public static async void Authorize(bool retrieveSubs = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -164,65 +165,71 @@ namespace FoxTube
|
||||
"user",
|
||||
CancellationToken.None);
|
||||
|
||||
if (Credential != null)
|
||||
if (Credential == null || !retrieveSubs)
|
||||
return;
|
||||
|
||||
if (settings.Values["authorized"] == null)
|
||||
settings.Values.Add("authorized", true);
|
||||
else settings.Values["authorized"] = true;
|
||||
IsAuthorized = true;
|
||||
|
||||
var request = Service.Channels.List("snippet,contentDetails");
|
||||
request.Mine = true;
|
||||
UserChannel = (await request.ExecuteAsync()).Items[0];
|
||||
AccountId = UserChannel.Id;
|
||||
|
||||
PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet");
|
||||
playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchHistory;
|
||||
playlistRequest.MaxResults = 50;
|
||||
PlaylistItemListResponse playlistResponse = await playlistRequest.ExecuteAsync();
|
||||
UserHistory.Clear();
|
||||
foreach (PlaylistItem i in playlistResponse.Items)
|
||||
UserHistory.Add(i);
|
||||
|
||||
playlistRequest = Service.PlaylistItems.List("snippet");
|
||||
playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchLater;
|
||||
playlistRequest.MaxResults = 50;
|
||||
playlistResponse = await playlistRequest.ExecuteAsync();
|
||||
WatchLater.Clear();
|
||||
|
||||
foreach (PlaylistItem i in playlistResponse.Items)
|
||||
WatchLater.Add(i);
|
||||
|
||||
string nextToken = playlistResponse.NextPageToken;
|
||||
while (nextToken != null)
|
||||
{
|
||||
if (settings.Values["authorized"] == null)
|
||||
settings.Values.Add("authorized", true);
|
||||
else settings.Values["authorized"] = true;
|
||||
IsAuthorized = true;
|
||||
|
||||
var request = Service.Channels.List("snippet,contentDetails");
|
||||
request.Mine = true;
|
||||
UserChannel = (await request.ExecuteAsync()).Items[0];
|
||||
AccountId = UserChannel.Id;
|
||||
|
||||
PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet");
|
||||
playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchHistory;
|
||||
playlistRequest.MaxResults = 50;
|
||||
PlaylistItemListResponse playlistResponse = await playlistRequest.ExecuteAsync();
|
||||
UserHistory.Clear();
|
||||
foreach (PlaylistItem i in playlistResponse.Items)
|
||||
UserHistory.Add(i);
|
||||
|
||||
playlistRequest = Service.PlaylistItems.List("snippet");
|
||||
playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchLater;
|
||||
playlistRequest.MaxResults = 50;
|
||||
playlistRequest.PageToken = nextToken;
|
||||
playlistResponse = await playlistRequest.ExecuteAsync();
|
||||
WatchLater.Clear();
|
||||
|
||||
foreach (PlaylistItem i in playlistResponse.Items)
|
||||
WatchLater.Add(i);
|
||||
|
||||
string nextToken = playlistResponse.NextPageToken;
|
||||
while (nextToken != null)
|
||||
{
|
||||
playlistRequest.PageToken = nextToken;
|
||||
playlistResponse = await playlistRequest.ExecuteAsync();
|
||||
foreach (PlaylistItem i in playlistResponse.Items)
|
||||
WatchLater.Add(i);
|
||||
nextToken = playlistResponse.NextPageToken;
|
||||
}
|
||||
|
||||
nextToken = playlistResponse.NextPageToken;
|
||||
}
|
||||
SubscriptionsResource.ListRequest subRequest = Service.Subscriptions.List("snippet");
|
||||
subRequest.Mine = true;
|
||||
subRequest.MaxResults = 50;
|
||||
subRequest.Order = SubscriptionsResource.ListRequest.OrderEnum.Relevance;
|
||||
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
||||
Subscriptions.Clear();
|
||||
|
||||
SubscriptionsResource.ListRequest subRequest = Service.Subscriptions.List("snippet");
|
||||
subRequest.Mine = true;
|
||||
subRequest.MaxResults = 50;
|
||||
subRequest.Order = SubscriptionsResource.ListRequest.OrderEnum.Relevance;
|
||||
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
||||
Subscriptions.Clear();
|
||||
foreach (Subscription s in subResponse.Items)
|
||||
Subscriptions.Add(s);
|
||||
|
||||
nextToken = subResponse.NextPageToken;
|
||||
while (nextToken != null)
|
||||
{
|
||||
subRequest.PageToken = nextToken;
|
||||
subResponse = await subRequest.ExecuteAsync();
|
||||
foreach (Subscription s in subResponse.Items)
|
||||
Subscriptions.Add(s);
|
||||
|
||||
nextToken = subResponse.NextPageToken;
|
||||
while (nextToken != null)
|
||||
{
|
||||
subRequest.PageToken = nextToken;
|
||||
subResponse = await subRequest.ExecuteAsync();
|
||||
foreach (Subscription s in subResponse.Items)
|
||||
Subscriptions.Add(s);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
@@ -257,12 +264,12 @@ namespace FoxTube
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckAuthorization()
|
||||
public static void CheckAuthorization(bool retrieveSubs = true)
|
||||
{
|
||||
if (settings.Values["authorized"] == null || !(bool)settings.Values["authorized"])
|
||||
IsAuthorized = false;
|
||||
else
|
||||
Authorize();
|
||||
Authorize(retrieveSubs);
|
||||
}
|
||||
|
||||
public static bool AdsDisabled { get; private set; } = true;
|
||||
@@ -270,7 +277,7 @@ namespace FoxTube
|
||||
public static void CheckAddons()
|
||||
{
|
||||
//TO-DO: Check addons list
|
||||
bool purchased = true;
|
||||
bool purchased = false;
|
||||
|
||||
if(!purchased)
|
||||
{
|
||||
|
||||
@@ -2,14 +2,51 @@
|
||||
x:Class="FoxTube.Controls.Advert"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:FoxTube.Controls"
|
||||
xmlns:ad="using:Microsoft.Advertising.WinRT.UI"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="400">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup>
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="320"/>
|
||||
</VisualState.StateTriggers>
|
||||
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ad.Width" Value="320"/>
|
||||
<Setter Target="ad.Height" Value="50"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="640"/>
|
||||
</VisualState.StateTriggers>
|
||||
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ad.Width" Value="640"/>
|
||||
<Setter Target="ad.Height" Value="100"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState>
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="728"/>
|
||||
</VisualState.StateTriggers>
|
||||
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ad.Width" Value="728"/>
|
||||
<Setter Target="ad.Height" Value="90"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<ad:AdControl Name="ad" ApplicationId="{x:Bind AppId}"
|
||||
AdUnitId="{x:Bind AdUnitId}"
|
||||
Height="50"
|
||||
Width="300"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -19,9 +19,16 @@ namespace FoxTube.Controls
|
||||
{
|
||||
public sealed partial class Advert : UserControl
|
||||
{
|
||||
public string AdUnitId { get; set; } = "test";
|
||||
public string AppId => "3f83fe91-d6be-434d-a0ae-7351c5a997f1";
|
||||
public Advert()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
if (!SecretsVault.AdsDisabled)
|
||||
Visibility = Visibility.Visible;
|
||||
else
|
||||
Visibility = Visibility.Collapsed;
|
||||
SecretsVault.NotPurchased += () => Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,11 @@ namespace FoxTube.Controls
|
||||
progressBar.IsIndeterminate = true;
|
||||
cancel.IsEnabled = false;
|
||||
cts.Cancel();
|
||||
await Container.File.DeleteAsync();
|
||||
try
|
||||
{
|
||||
await Container.File.DeleteAsync();
|
||||
}
|
||||
catch { }
|
||||
Methods.MainPage.Agent.Remove(Container.Id);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,18 @@
|
||||
</uap:DefaultTile>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="red" />
|
||||
</uap:VisualElements>
|
||||
<Extensions>
|
||||
<Extension Category="windows.backgroundTasks" EntryPoint="FoxTube.Background.BackgroundProcessor">
|
||||
<BackgroundTasks>
|
||||
<Task Type="general" />
|
||||
<Task Type="systemEvent" />
|
||||
<Task Type="timer" />
|
||||
<Task Type="pushNotification" />
|
||||
<uap:Task Type="chatMessageNotification" />
|
||||
<uap:Task Type="mediaProcessing" />
|
||||
</BackgroundTasks>
|
||||
</Extension>
|
||||
</Extensions>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Grid Name="grid">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid Name="grid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="30"/>
|
||||
|
||||
@@ -43,6 +43,8 @@ namespace FoxTube.Pages
|
||||
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
grid.RowDefinitions[0].Height = new GridLength(0);
|
||||
else
|
||||
grid.RowDefinitions[0].Height = GridLength.Auto;
|
||||
|
||||
counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount);
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ using System.Net;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.Networking.Connectivity;
|
||||
using Windows.UI.Core;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
@@ -74,7 +76,7 @@ namespace FoxTube
|
||||
if (settings.Values["ver"] == null)
|
||||
settings.Values.Add("ver", $"{ver.Major}.{ver.Minor}");
|
||||
|
||||
//if((string)settings.Values["ver"] != $"{ver.Major}.{ver.Minor}")
|
||||
if((string)settings.Values["ver"] != $"{ver.Major}.{ver.Minor}")
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -93,6 +95,16 @@ namespace FoxTube
|
||||
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
|
||||
SecretsVault.CheckAuthorization();
|
||||
SetTitleBar();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public async void Initialize()
|
||||
{
|
||||
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };
|
||||
await FileIO.WriteTextAsync(
|
||||
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(notificationsSettings));
|
||||
Debug.WriteLine(ApplicationData.Current.RoamingFolder.Path);
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
@@ -227,7 +239,8 @@ namespace FoxTube
|
||||
}
|
||||
|
||||
nav.SelectedItem = toHome;
|
||||
content.Navigate(typeof(Home));
|
||||
if(content.Content is Home)
|
||||
content.Navigate(typeof(Home));
|
||||
|
||||
if (videoPlaceholder.Content != null)
|
||||
GoToVideo((videoPlaceholder.Content as VideoPage).videoId);
|
||||
@@ -274,13 +287,12 @@ namespace FoxTube
|
||||
|
||||
public async void GoToVideo(string id, string playlistId = null)
|
||||
{
|
||||
Debug.WriteLine($"Video id: {id}; Playlist id: {playlistId}");
|
||||
bool cancel = false;
|
||||
try
|
||||
{
|
||||
var connection = NetworkInformation.GetInternetConnectionProfile().GetConnectionCost();
|
||||
if ((bool)settings.Values["moblieWarning"] && (connection.NetworkCostType == NetworkCostType.Fixed || connection.NetworkCostType == NetworkCostType.Variable))
|
||||
{
|
||||
bool cancel = false;
|
||||
MessageDialog dialog = new MessageDialog("You are on metered connection now. Additional charges may apply. Do you want to continue?")
|
||||
{
|
||||
DefaultCommandIndex = 2,
|
||||
@@ -290,16 +302,40 @@ namespace FoxTube
|
||||
dialog.Commands.Add(new UICommand("No", (command) => cancel = true));
|
||||
dialog.Commands.Add(new UICommand("Add to 'Watch later' playlist", (command) =>
|
||||
{
|
||||
//TO-DO: Adding video to "Watch later"
|
||||
try
|
||||
{
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
SecretsVault.CheckAuthorization(false);
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
throw new Exception("Not authenticated");
|
||||
|
||||
PlaylistItem item = new PlaylistItem()
|
||||
{
|
||||
Snippet = new PlaylistItemSnippet()
|
||||
{
|
||||
ResourceId = new ResourceId()
|
||||
{
|
||||
Kind = "youtube#video",
|
||||
VideoId = id
|
||||
},
|
||||
PlaylistId = "WL"
|
||||
}
|
||||
};
|
||||
|
||||
SecretsVault.Service.PlaylistItems.Insert(item, "snippet").Execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
}
|
||||
cancel = true;
|
||||
}));
|
||||
await dialog.ShowAsync();
|
||||
|
||||
if (cancel)
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
if (cancel)
|
||||
return;
|
||||
|
||||
nav.IsPaneOpen = false;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace FoxTube
|
||||
public sealed partial class Settings : Page
|
||||
{
|
||||
bool inboxLoaded = false;
|
||||
string inboxId = null;
|
||||
public Settings()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
@@ -40,9 +41,9 @@ namespace FoxTube
|
||||
{
|
||||
if ((e.Parameter as string).Contains("inbox") || (e.Parameter as string).Contains("changelog"))
|
||||
{
|
||||
pivot.SelectedIndex = 2;
|
||||
if ((string)e.Parameter != "inbox" && (string)e.Parameter != "changelog")
|
||||
((pivot.SelectedItem as PivotItem).Content as Inbox).Open(e.Parameter as string);
|
||||
inboxId = e.Parameter as string;
|
||||
pivot.SelectedIndex = 2;
|
||||
}
|
||||
else
|
||||
switch(e.Parameter as string)
|
||||
@@ -63,6 +64,11 @@ namespace FoxTube
|
||||
{
|
||||
(((pivot.Items[2] as PivotItem).Content as ScrollViewer).Content as Inbox).LoadItems();
|
||||
inboxLoaded = true;
|
||||
if(inboxId != null)
|
||||
{
|
||||
(((pivot.Items[2] as PivotItem).Content as ScrollViewer).Content as Inbox).Open(inboxId as string);
|
||||
inboxId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
@@ -90,9 +91,13 @@ namespace FoxTube.Pages.SettingsPages
|
||||
settings.Values["videoAutoplay"] = autoplay.IsOn;
|
||||
}
|
||||
|
||||
private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
|
||||
private async void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
settings.Values["newVideoNotification"] = newVideo.IsOn;
|
||||
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };
|
||||
await FileIO.WriteTextAsync(
|
||||
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(notificationsSettings));
|
||||
}
|
||||
|
||||
private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
@@ -135,9 +140,13 @@ namespace FoxTube.Pages.SettingsPages
|
||||
CoreApplication.Exit();
|
||||
}
|
||||
|
||||
private void devNews_Toggled(object sender, RoutedEventArgs e)
|
||||
private async void devNews_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
settings.Values["devnews"] = devNews.IsOn;
|
||||
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };
|
||||
await FileIO.WriteTextAsync(
|
||||
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(notificationsSettings));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
xmlns:local="using:FoxTube"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:ui="using:Microsoft.Advertising.WinRT.UI"
|
||||
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:controls="using:FoxTube.Controls"
|
||||
x:Name="root"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<controls:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None" Grid.Row="1"/>
|
||||
<controls:Advert/>
|
||||
<ui:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None" Grid.Row="1"/>
|
||||
<TextBlock Name="empty" Text="Ø" FontSize="200" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.RowSpan="2"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
xmlns:pages="using:FoxTube.Pages"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:ui="using:Microsoft.Advertising.WinRT.UI"
|
||||
xmlns:controls1="using:FoxTube.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
|
||||
@@ -106,7 +107,47 @@
|
||||
<MenuFlyout x:Name="downloadSelector"/>
|
||||
</AppBarButton.Flyout>
|
||||
</AppBarButton>
|
||||
<AppBarButton Label="Add to" Icon="Add" IsEnabled="False"/>
|
||||
<AppBarButton Name="addTo" Label="Add to" Icon="Add">
|
||||
<AppBarButton.Flyout>
|
||||
<Flyout>
|
||||
<ScrollViewer Margin="-12" MaxHeight="300">
|
||||
<NavigationViewList Width="200" IsMultiSelectCheckBoxEnabled="True" SelectionMode="Multiple">
|
||||
<NavigationViewItem Content="Watch later">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="New playlist">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItemHeader Content="Other playlists"/>
|
||||
<NavigationViewItem Content="My playlist">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="Cats">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="Dogs">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
<NavigationViewItem Content="Another playlist">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
</NavigationViewList>
|
||||
</ScrollViewer>
|
||||
</Flyout>
|
||||
</AppBarButton.Flyout>
|
||||
</AppBarButton>
|
||||
<AppBarButton Name="refresh" Click="refresh_Click" Icon="Refresh" Label="Refresh page"/>
|
||||
<AppBarButton Name="share" Click="share_Click" Icon="Share" Label="Share"/>
|
||||
<AppBarButton Name="openBrowser" Click="openBrowser_Click" Icon="Globe" Label="Open in browser"/>
|
||||
@@ -116,7 +157,10 @@
|
||||
<Pivot Grid.Row="1" Name="pivot" SelectedIndex="0" IsHeaderItemsCarouselEnabled="False">
|
||||
<PivotItem Header="Suggestions">
|
||||
<ScrollViewer>
|
||||
<StackPanel Name="relatedVideos"/>
|
||||
<StackPanel>
|
||||
<controls1:Advert/>
|
||||
<StackPanel Name="relatedVideos"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</PivotItem>
|
||||
<PivotItem Header="Comments" Name="commentsPlaceholder">
|
||||
|
||||
@@ -209,6 +209,12 @@ namespace FoxTube.Pages
|
||||
}
|
||||
subscribe.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
download.Visibility = Visibility.Collapsed;
|
||||
addTo.Visibility = Visibility.Collapsed;
|
||||
subscribe.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
ChannelsResource.ListRequest channelRequest = SecretsVault.Service.Channels.List("snippet, statistics");
|
||||
channelRequest.Id = item.Snippet.ChannelId;
|
||||
|
||||
Reference in New Issue
Block a user