Everything is fucked up
This commit is contained in:
+51
-76
@@ -1,8 +1,6 @@
|
||||
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;
|
||||
@@ -27,36 +25,23 @@ namespace FoxTube
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
public App()
|
||||
{
|
||||
try
|
||||
SettingsStorage.LoadData();
|
||||
|
||||
switch (SettingsStorage.Theme)
|
||||
{
|
||||
switch((int)settings.Values["themeMode"])
|
||||
{
|
||||
case 0:
|
||||
RequestedTheme = ApplicationTheme.Light;
|
||||
break;
|
||||
case 1:
|
||||
RequestedTheme = ApplicationTheme.Dark;
|
||||
break;
|
||||
}
|
||||
} catch { }
|
||||
try
|
||||
{
|
||||
if (settings.Values["language"] == null)
|
||||
{
|
||||
List<string> cultures = new List<string>() { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" };
|
||||
if (cultures.Contains(CultureInfo.InstalledUICulture.ThreeLetterISOLanguageName))
|
||||
settings.Values.Add("language", "ru-RU");
|
||||
else
|
||||
settings.Values.Add("language", "en-US");
|
||||
}
|
||||
ApplicationLanguages.PrimaryLanguageOverride = (string)settings.Values["language"];
|
||||
case 0:
|
||||
RequestedTheme = ApplicationTheme.Light;
|
||||
break;
|
||||
case 1:
|
||||
RequestedTheme = ApplicationTheme.Dark;
|
||||
break;
|
||||
}
|
||||
catch { }
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
|
||||
ApplicationLanguages.PrimaryLanguageOverride = SettingsStorage.Language;
|
||||
InitializeComponent();
|
||||
Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,6 +83,9 @@ namespace FoxTube
|
||||
ActivateBackgoundTask();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes background task for processing toast notifications' clicks
|
||||
/// </summary>
|
||||
public async void ActivateToastBackgoundTask()
|
||||
{
|
||||
const string taskName = "FoxtubeToastBackground";
|
||||
@@ -115,10 +103,12 @@ namespace FoxTube
|
||||
BackgroundTaskRegistration registration = builder.Register();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes background task for checking user's subscriptions and poping toast notifications when new video is uploaded
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
@@ -136,7 +126,6 @@ namespace FoxTube
|
||||
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)
|
||||
@@ -144,47 +133,43 @@ namespace FoxTube
|
||||
var deferral = args.TaskInstance.GetDeferral();
|
||||
base.OnBackgroundActivated(args);
|
||||
|
||||
if (args.TaskInstance.Task.Name == "FoxtubeToastBackground")
|
||||
if (args.TaskInstance.Task.Name == "FoxtubeToastBackground" && args.TaskInstance.TriggerDetails is ToastNotificationActionTriggerDetail details)
|
||||
{
|
||||
var details = args.TaskInstance.TriggerDetails as ToastNotificationActionTriggerDetail;
|
||||
if (details != null)
|
||||
string[] arguments = details.Argument.Split('|');
|
||||
|
||||
switch (arguments[0])
|
||||
{
|
||||
string[] arguments = details.Argument.Split('|');
|
||||
case "later":
|
||||
try
|
||||
{
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
SecretsVault.CheckAuthorization(false);
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
throw new Exception("Not authenticated");
|
||||
|
||||
switch(arguments[0])
|
||||
{
|
||||
case "later":
|
||||
try
|
||||
PlaylistItem item = new PlaylistItem()
|
||||
{
|
||||
if(!SecretsVault.IsAuthorized)
|
||||
SecretsVault.CheckAuthorization(false);
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
throw new Exception("Not authenticated");
|
||||
|
||||
PlaylistItem item = new PlaylistItem()
|
||||
Snippet = new PlaylistItemSnippet()
|
||||
{
|
||||
Snippet = new PlaylistItemSnippet()
|
||||
ResourceId = new ResourceId()
|
||||
{
|
||||
ResourceId = new ResourceId()
|
||||
{
|
||||
Kind = "youtube#video",
|
||||
VideoId = arguments[1]
|
||||
},
|
||||
PlaylistId = "WL"
|
||||
}
|
||||
};
|
||||
Kind = "youtube#video",
|
||||
VideoId = arguments[1]
|
||||
},
|
||||
PlaylistId = "WL"
|
||||
}
|
||||
};
|
||||
|
||||
await SecretsVault.Service.PlaylistItems.Insert(item, "snippet").ExecuteAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
}
|
||||
break;
|
||||
case "download":
|
||||
await Launcher.LaunchFileAsync(await StorageFile.GetFileFromPathAsync(arguments[1]));
|
||||
break;
|
||||
}
|
||||
await SecretsVault.Service.PlaylistItems.Insert(item, "snippet").ExecuteAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
}
|
||||
break;
|
||||
case "download":
|
||||
await Launcher.LaunchFileAsync(await StorageFile.GetFileFromPathAsync(arguments[1]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +195,8 @@ namespace FoxTube
|
||||
rootFrame.Navigate(typeof(MainPage));
|
||||
}
|
||||
|
||||
Window.Current.Activate();
|
||||
|
||||
if (e is ToastNotificationActivatedEventArgs)
|
||||
{
|
||||
string[] args = (e as ToastNotificationActivatedEventArgs).Argument.Split('|');
|
||||
@@ -235,8 +222,6 @@ namespace FoxTube
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Window.Current.Activate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,16 +244,6 @@ namespace FoxTube
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
|
||||
//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
|
||||
DownloadAgent.QuitPrompt();
|
||||
deferral.Complete();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Google.Apis.YouTube.v3.SearchResource.ListRequest;
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
public delegate void Event();
|
||||
|
||||
public delegate void ObjectEventHandler(object sender, params object[] args);
|
||||
public delegate void ObjectEventHandler(object sender = null, params object[] args);
|
||||
|
||||
public class SearchParameters
|
||||
{
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
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;
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
@@ -20,7 +15,7 @@ namespace FoxTube
|
||||
{
|
||||
#region Properties
|
||||
//Events
|
||||
public static event Event AuthorizationStateChanged;
|
||||
public static event ObjectEventHandler AuthorizationStateChanged;
|
||||
public static event ObjectEventHandler SubscriptionsChanged;
|
||||
public static event Event NotPurchased; //Rising when app finds out that it's not a PRO version
|
||||
|
||||
@@ -71,7 +66,7 @@ namespace FoxTube
|
||||
try { await Service.Subscriptions.Delete(s.Id).ExecuteAsync(); }
|
||||
catch { return true; }
|
||||
|
||||
SubscriptionsChanged.Invoke(null, "remove", Subscriptions.IndexOf(s));
|
||||
SubscriptionsChanged?.Invoke(null, "remove", Subscriptions.IndexOf(s));
|
||||
Subscriptions.Remove(s);
|
||||
return false;
|
||||
}
|
||||
@@ -93,7 +88,7 @@ namespace FoxTube
|
||||
if (s == null)
|
||||
return false;
|
||||
Subscriptions.Add(s);
|
||||
SubscriptionsChanged.Invoke(null, "add", s);
|
||||
SubscriptionsChanged?.Invoke(null, "add", s);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -101,84 +96,32 @@ namespace FoxTube
|
||||
/// <summary>
|
||||
/// Prompts to add an Youtube account and retrieves its info when successful
|
||||
/// </summary>
|
||||
/// <param name="retrieveSubs"></param>
|
||||
/// <param name="retrieveSubs">Loads user's subscriptions if true</param>
|
||||
public static async void Authorize(bool retrieveSubs = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region Retrieving user's credential
|
||||
Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
|
||||
Secrets,
|
||||
new[]
|
||||
{
|
||||
Google.Apis.Oauth2.v2.Oauth2Service.Scope.UserinfoProfile,
|
||||
YouTubeService.Scope.YoutubeForceSsl
|
||||
Google.Apis.Oauth2.v2.Oauth2Service.Scope.UserinfoProfile,
|
||||
YouTubeService.Scope.YoutubeForceSsl
|
||||
},
|
||||
"user",
|
||||
CancellationToken.None);
|
||||
|
||||
if (Credential == null || !retrieveSubs)
|
||||
return;
|
||||
goto InvokeEvent;
|
||||
|
||||
if (settings.Values["authorized"] == null)
|
||||
settings.Values.Add("authorized", true);
|
||||
else settings.Values["authorized"] = true;
|
||||
SettingsStorage.HasAccount = true;
|
||||
#endregion
|
||||
|
||||
#region Retrieving user's data
|
||||
var request = Service.Channels.List("snippet,contentDetails");
|
||||
request.Mine = true;
|
||||
UserChannel = (await request.ExecuteAsync()).Items[0];
|
||||
|
||||
/*try
|
||||
{
|
||||
await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json");
|
||||
UserHistory = JsonConvert.DeserializeObject<List<HistoryItem>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json")));
|
||||
}
|
||||
catch
|
||||
{
|
||||
await FileIO.WriteTextAsync(
|
||||
await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(new List<HistoryItem>()));
|
||||
UserHistory = new List<HistoryItem>();
|
||||
}
|
||||
try
|
||||
{
|
||||
await ApplicationData.Current.RoamingFolder.GetFileAsync("watchlater.json");
|
||||
WatchLater = JsonConvert.DeserializeObject<List<string>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("watchlater.json")));
|
||||
}
|
||||
catch
|
||||
{
|
||||
await FileIO.WriteTextAsync(
|
||||
await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(new List<string>()));
|
||||
WatchLater = new List<string>();
|
||||
}*/
|
||||
|
||||
/*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)
|
||||
{
|
||||
playlistRequest.PageToken = nextToken;
|
||||
playlistResponse = await playlistRequest.ExecuteAsync();
|
||||
foreach (PlaylistItem i in playlistResponse.Items)
|
||||
WatchLater.Add(i);
|
||||
|
||||
nextToken = playlistResponse.NextPageToken;
|
||||
}*/
|
||||
|
||||
SubscriptionsResource.ListRequest subRequest = Service.Subscriptions.List("snippet");
|
||||
subRequest.Mine = true;
|
||||
@@ -197,31 +140,23 @@ namespace FoxTube
|
||||
nextToken = subResponse.NextPageToken;
|
||||
|
||||
} while (!string.IsNullOrWhiteSpace(nextToken));
|
||||
#endregion
|
||||
|
||||
//Saving user's subscriptions for background task
|
||||
SaveSubscriptions();
|
||||
|
||||
InvokeEvent:
|
||||
AuthorizationStateChanged?.Invoke(args: IsAuthorized);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageDialog dialog = new MessageDialog("We were unabled to retrieve your account information due to weak internet connection or Google servers' problems. PLease, try again later", "Failed to connect");
|
||||
|
||||
dialog.Commands.Add(new UICommand("Try again", (command) =>
|
||||
{
|
||||
Authorize();
|
||||
}));
|
||||
dialog.Commands.Add(new UICommand("Quit", (command) =>
|
||||
{
|
||||
Methods.CloseApp();
|
||||
}));
|
||||
dialog.Commands.Add(new UICommand("Close"));
|
||||
|
||||
await dialog.ShowAsync();
|
||||
|
||||
IsAuthorized = false;
|
||||
AuthorizationStateChanged?.Invoke(args: null);
|
||||
}
|
||||
|
||||
AuthorizationStateChanged.Invoke(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves user's subscriptions keypairs (channel ID: avatar URL) into "background.json" file for concurrent background processing
|
||||
/// </summary>
|
||||
public static async void SaveSubscriptions()
|
||||
{
|
||||
Dictionary<string, string> subs = new Dictionary<string, string>();
|
||||
@@ -231,36 +166,44 @@ namespace FoxTube
|
||||
JsonConvert.SerializeObject(subs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deauthenticates current user
|
||||
/// </summary>
|
||||
public static async void Deauthenticate()
|
||||
{
|
||||
if(await Credential.RevokeTokenAsync(CancellationToken.None))
|
||||
{
|
||||
Credential = null;
|
||||
AuthorizationStateChanged.Invoke();
|
||||
settings.Values["authorized"] = false;
|
||||
AuthorizationStateChanged?.Invoke(args: false);
|
||||
SettingsStorage.HasAccount = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any user has already been logged in. If has, calls *Authorize()* to retrieve his info
|
||||
/// </summary>
|
||||
/// <param name="retrieveSubs">Loads user's subscriptions if true</param>
|
||||
public static void CheckAuthorization(bool retrieveSubs = true)
|
||||
{
|
||||
if (settings.Values["authorized"] != null && (bool)settings.Values["authorized"])
|
||||
if (SettingsStorage.HasAccount)
|
||||
Authorize(retrieveSubs);
|
||||
else AuthorizationStateChanged.Invoke(args: false);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Connects to MS Store and checks if user has bought ad-free
|
||||
/// </summary>
|
||||
public static void CheckAddons()
|
||||
{
|
||||
//TO-DO: Check addons list
|
||||
//TODO: Check addons list
|
||||
bool purchased = true;
|
||||
|
||||
if(!purchased)
|
||||
{
|
||||
AdsDisabled = false;
|
||||
if(NotPurchased != null)
|
||||
NotPurchased.Invoke();
|
||||
NotPurchased?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace FoxTube.Classes
|
||||
namespace FoxTube
|
||||
{
|
||||
public static class SettingsStorage
|
||||
{
|
||||
@@ -129,6 +129,7 @@ namespace FoxTube.Classes
|
||||
if (storage.Values["ver"] == null)
|
||||
{
|
||||
PackageVersion ver = Package.Current.Id.Version;
|
||||
storage.Values["version"] = $"{ver.Major}.{ver.Minor}";
|
||||
return $"{ver.Major}.{ver.Minor}";
|
||||
}
|
||||
else return (string)storage.Values["version"];
|
||||
@@ -140,7 +141,7 @@ namespace FoxTube.Classes
|
||||
}
|
||||
|
||||
//Settings storage
|
||||
private static ApplicationDataContainer storage = ApplicationData.Current.LocalSettings;
|
||||
private static readonly ApplicationDataContainer storage = ApplicationData.Current.LocalSettings;
|
||||
|
||||
//Predefined preferences
|
||||
private static object[] settings = new object[]
|
||||
@@ -169,12 +170,17 @@ namespace FoxTube.Classes
|
||||
{
|
||||
settings = JsonConvert.DeserializeObject<object[]>(storage.Values["settings"] as string);
|
||||
}
|
||||
catch (NullReferenceException) { }
|
||||
catch (ArgumentNullException) { }
|
||||
}
|
||||
|
||||
public static void SaveData()
|
||||
public static async void SaveData()
|
||||
{
|
||||
storage.Values["settings"] = JsonConvert.SerializeObject(settings);
|
||||
|
||||
bool[] notificationsSettings = new[] { VideoNotifications, DevNotifications };
|
||||
await FileIO.WriteTextAsync(
|
||||
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
|
||||
JsonConvert.SerializeObject(notificationsSettings));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<UserControl
|
||||
x:Class="FoxTube.Controls.ChannelCardWide"
|
||||
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"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="150">
|
||||
|
||||
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2" VerticalAlignment="Stretch" Click="Button_Click">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="125"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<PersonPicture Name="avatar" Width="125"/>
|
||||
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Name="channelName" Text="IGP" FontSize="18"/>
|
||||
<StackPanel Name="liveTag" Margin="5,0,0,0" BorderBrush="Red" BorderThickness="2" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed">
|
||||
<TextBlock Text=" " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/>
|
||||
<TextBlock Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontWeight="Bold"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<TextBlock Name="subscribers" Text="120,452 subscribers" Foreground="Gray"/>
|
||||
<TextBlock Name="videoCount" Foreground="Gray" Text="563,000 videos"/>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" Name="subscriptionPane">
|
||||
<ToggleButton Grid.Column="2" Height="40" Width="200" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
|
||||
<ToggleButton Grid.Column="3" Height="40" Width="40" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
|
||||
namespace FoxTube.Controls
|
||||
{
|
||||
public sealed partial class ChannelCardWide : UserControl
|
||||
{
|
||||
string channelId;
|
||||
public ChannelCardWide(string id, string live)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Initialize(id, live);
|
||||
}
|
||||
|
||||
public async void Initialize(string id, string live)
|
||||
{
|
||||
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
||||
ApplicationName = this.GetType().ToString()
|
||||
});
|
||||
|
||||
ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics");
|
||||
request.Id = id;
|
||||
ChannelListResponse response = await request.ExecuteAsync();
|
||||
|
||||
var item = response.Items[0];
|
||||
|
||||
channelId = id;
|
||||
|
||||
channelName.Text = item.Snippet.Title;
|
||||
subscribers.Text = string.Format("{0} subscribers", item.Statistics.SubscriberCount);
|
||||
videoCount.Text = string.Format("{0} videos", item.Statistics.VideoCount);
|
||||
|
||||
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||
if (live == "live")
|
||||
liveTag.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Methods.MainPage.GoToChannel(channelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,8 @@ using Google.Apis.YouTube.v3.Data;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Notifications;
|
||||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FoxTube.Controls
|
||||
@@ -26,25 +24,24 @@ namespace FoxTube.Controls
|
||||
public StorageFile file;
|
||||
public bool InProgress { get; set; } = false;
|
||||
|
||||
YoutubeClient client = new YoutubeClient();
|
||||
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
readonly YoutubeClient client = new YoutubeClient();
|
||||
readonly CancellationTokenSource cts = new CancellationTokenSource();
|
||||
CancellationToken token;
|
||||
Progress<double> progress = new Progress<double>();
|
||||
NotificationData data = new NotificationData();
|
||||
readonly Progress<double> progress = new Progress<double>();
|
||||
private readonly NotificationData data = new NotificationData();
|
||||
|
||||
DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) };
|
||||
double percentage;
|
||||
|
||||
public DownloadItem(MediaStreamInfo info, Video meta, string q)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
Download(info, meta, q);
|
||||
}
|
||||
|
||||
public DownloadItem(DownloadItemContainer container)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
Container = container;
|
||||
Initialize();
|
||||
|
||||
@@ -1,42 +1,29 @@
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
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.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace FoxTube.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// Playlist card control
|
||||
/// </summary>
|
||||
public sealed partial class PlaylistCard : Page
|
||||
{
|
||||
Playlist item;
|
||||
string playlistId;
|
||||
public string playlistId;
|
||||
|
||||
public PlaylistCard(string id)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
Initialize(id);
|
||||
}
|
||||
|
||||
public async void Initialize(string id)
|
||||
{
|
||||
PlaylistsResource.ListRequest request = SecretsVault.NoAuthService.Playlists.List("snippet,contentDetails");
|
||||
PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet,contentDetails");
|
||||
request.Id = id;
|
||||
PlaylistListResponse response = await request.ExecuteAsync();
|
||||
|
||||
@@ -48,7 +35,7 @@ namespace FoxTube.Controls
|
||||
counter.Text = item.ContentDetails.ItemCount.ToString();
|
||||
date.Text = Methods.GetAgo(item.Snippet.PublishedAt.Value);
|
||||
|
||||
ChannelsResource.ListRequest r = SecretsVault.NoAuthService.Channels.List("snippet");
|
||||
ChannelsResource.ListRequest r = SecretsVault.Service.Channels.List("snippet");
|
||||
r.Id = item.Snippet.ChannelId;
|
||||
|
||||
try
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<UserControl
|
||||
x:Class="FoxTube.PlaylistCardWide"
|
||||
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"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="175">
|
||||
|
||||
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Grid>
|
||||
<Image Name="thumbnail" Source="/Assets/videoThumbSample.png"/>
|
||||
<Grid HorizontalAlignment="Right" Width="100">
|
||||
<Grid.Background>
|
||||
<AcrylicBrush TintColor="#7F000000" BackgroundSource="Backdrop" AlwaysUseFallback="False" TintOpacity="1" Opacity="0.97"/>
|
||||
</Grid.Background>
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<TextBlock HorizontalAlignment="Center" FontFamily="Segoe MDL2 Assets" Foreground="White" Text="" FontSize="30"/>
|
||||
<TextBlock Foreground="White" Text="[N/A]" HorizontalAlignment="Center" FontSize="20" Name="thumbCount"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Margin="10" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="75"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Name="title" TextWrapping="WrapWholeWords" Text="[Title]" FontSize="20" MaxLines="2"/>
|
||||
<TextBlock Name="info" Text="[Published at] | [Video count]" Foreground="Gray"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" Name="authorData">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="75"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<PersonPicture Name="avatar" Width="75" HorizontalAlignment="Left"/>
|
||||
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center">
|
||||
<TextBlock Name="channelName" Text="[Channel name]" FontSize="18"/>
|
||||
<TextBlock Name="channelSubs" Text="[Subscribers]" Foreground="Gray"/>
|
||||
<HyperlinkButton Name="channelLink" Content="Go to channel" Padding="0" Click="channelLink_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -1,74 +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.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Google.Apis.Util.Store;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
public sealed partial class PlaylistCardWide : UserControl
|
||||
{
|
||||
public string playlistId;
|
||||
Playlist item;
|
||||
public PlaylistCardWide(string id, bool hideAuthor = false)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Initialize(id, hideAuthor);
|
||||
}
|
||||
|
||||
public async void Initialize(string id, bool hideAuthor)
|
||||
{
|
||||
PlaylistsResource.ListRequest request = SecretsVault.NoAuthService.Playlists.List("snippet,contentDetails");
|
||||
request.Id = id;
|
||||
PlaylistListResponse response = await request.ExecuteAsync();
|
||||
|
||||
item = response.Items[0];
|
||||
|
||||
playlistId = id;
|
||||
|
||||
title.Text = item.Snippet.Title;
|
||||
info.Text = string.Format("{0} | {1} videos", item.Snippet.PublishedAt, item.ContentDetails.ItemCount);
|
||||
thumbCount.Text = item.ContentDetails.ItemCount.ToString();
|
||||
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||
|
||||
if (hideAuthor)
|
||||
authorData.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
{
|
||||
var request1 = SecretsVault.NoAuthService.Channels.List("snippet,contentDetails,statistics");
|
||||
request1.Id = item.Snippet.ChannelId;
|
||||
ChannelListResponse response1 = await request1.ExecuteAsync();
|
||||
|
||||
var item1 = response1.Items[0];
|
||||
|
||||
avatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url));
|
||||
channelName.Text = item1.Snippet.Title;
|
||||
channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount);
|
||||
}
|
||||
}
|
||||
|
||||
private void channelLink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Methods.MainPage.GoToChannel(item.Snippet.ChannelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<UserControl
|
||||
x:Class="FoxTube.VideoCardWide"
|
||||
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"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="175">
|
||||
|
||||
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2" Click="Button_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Grid>
|
||||
<Image Name="thumbnail" Source="Assets/videoThumbSample.png"/>
|
||||
<Grid Background="#7FFFFFFF" Name="watched" Visibility="Collapsed">
|
||||
<StackPanel Margin="5" Background="WhiteSmoke" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="5,2,5,2" BorderBrush="Gray" BorderThickness="1">
|
||||
<TextBlock Text="Watched" Foreground="Gray" FontSize="12"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Margin="10" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="75"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Name="title" TextWrapping="WrapWholeWords" Text="[Title]" FontSize="20" MaxLines="2"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Name="info" Text="[Duration] | [Published at] | [views]" Foreground="Gray"/>
|
||||
<StackPanel Name="liveTag" Margin="5,0,0,0" BorderBrush="Red" BorderThickness="2" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed">
|
||||
<TextBlock Text=" " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/>
|
||||
<TextBlock Name="liveContent" Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontWeight="Bold"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<!--<TextBlock MaxLines="4" Foreground="Gray" Margin="0,5,0,0" Text="Bendy and the Ink Machine: Chapter 4 Gameplay Part 1 - The Most Horrific Thing Yet! Bertrum Boss Fight! - Welcome back to Bendy and the Ink Machine! Today in Bendy and the Ink Machine, we check out Chapter 4, the latest and most terrifying chapter yet! We discover new secrets and find a man alive...kind of. Let's play Bendy and the Ink Machine Chapter 4!"/>-->
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" Name="authorData">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="75"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<PersonPicture Name="avatar" Width="75" HorizontalAlignment="Left"/>
|
||||
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center">
|
||||
<TextBlock Name="channelName" Text="[Channel name]" FontSize="18"/>
|
||||
<TextBlock Name="channelSubs" Text="[Subscribers]" Foreground="Gray"/>
|
||||
<HyperlinkButton Name="channelLink" Content="Go to channel" Padding="0" Click="channelLink_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -1,112 +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.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Google.Apis.Util.Store;
|
||||
using System.Xml;
|
||||
using Windows.System;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
public sealed partial class VideoCardWide : UserControl
|
||||
{
|
||||
public string videoId;
|
||||
Google.Apis.YouTube.v3.Data.Video item;
|
||||
|
||||
bool embed = false;
|
||||
public VideoCardWide(string id)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Initialize(id);
|
||||
}
|
||||
|
||||
public async void Initialize(string id)
|
||||
{
|
||||
YouTubeService ytService = SecretsVault.NoAuthService;
|
||||
|
||||
VideosResource.ListRequest request = ytService.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails");
|
||||
request.Id = id;
|
||||
VideoListResponse response = await request.ExecuteAsync();
|
||||
|
||||
item = response.Items[0];
|
||||
|
||||
videoId = id;
|
||||
|
||||
title.Text = item.Snippet.Title;
|
||||
|
||||
string duration;
|
||||
if (item.ContentDetails.Duration != null || item.ContentDetails.Duration != "")
|
||||
{
|
||||
TimeSpan ts = XmlConvert.ToTimeSpan(item.ContentDetails.Duration);
|
||||
duration = string.Format("{0}{1:00}:{2:00} | ", ts.Hours == 0 ? "" : ts.Hours + ":", ts.Minutes, ts.Seconds);
|
||||
}
|
||||
else duration = string.Empty;
|
||||
|
||||
info.Text = string.Format("{0}{1} | {2}", duration, Methods.GetAgo(item.Snippet.PublishedAt.Value), (item.LiveStreamingDetails != null && item.LiveStreamingDetails.ConcurrentViewers.HasValue) ? item.LiveStreamingDetails.ConcurrentViewers + " viewers" : item.Statistics.ViewCount + " views");
|
||||
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
|
||||
if (item.Snippet.LiveBroadcastContent == "live")
|
||||
{
|
||||
embed = true;
|
||||
liveTag.Visibility = Visibility.Visible;
|
||||
}
|
||||
else if(item.Snippet.LiveBroadcastContent == "upcoming")
|
||||
{
|
||||
embed = true;
|
||||
TimeSpan span;
|
||||
if (item.LiveStreamingDetails.ScheduledStartTime != null && (item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now).Value.TotalMilliseconds > 0)
|
||||
{
|
||||
span = (TimeSpan)(item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now);
|
||||
liveContent.Text = "Goes live in " + string.Format("{0}{1:00}:{2:00}:{3:00}", span.Days != 0 ? span.Days + ":" : "", span.Hours, span.Minutes, span.Seconds);
|
||||
}
|
||||
else
|
||||
liveContent.Text = "Upcoming";
|
||||
liveTag.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
var request1 = ytService.Channels.List("snippet,contentDetails,statistics");
|
||||
request1.Id = item.Snippet.ChannelId;
|
||||
ChannelListResponse response1 = await request1.ExecuteAsync();
|
||||
|
||||
var item1 = response1.Items[0];
|
||||
|
||||
avatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url));
|
||||
channelName.Text = item1.Snippet.Title;
|
||||
channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount);
|
||||
|
||||
//if (SecretsVault.UserHistory.Contains(item.Id))
|
||||
//watched.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void channelLink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Methods.MainPage.GoToChannel(item.Snippet.ChannelId);
|
||||
}
|
||||
|
||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (embed)
|
||||
await Launcher.LaunchUriAsync(new Uri(string.Format("https://www.youtube.com/watch?v={0}", videoId)));
|
||||
else
|
||||
Methods.MainPage.GoToVideo(videoId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,9 +127,6 @@
|
||||
<Compile Include="Pages\ChannelPage.xaml.cs">
|
||||
<DependentUpon>ChannelPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ChannelCardWide.xaml.cs">
|
||||
<DependentUpon>ChannelCardWide.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\CommentsPage.xaml.cs">
|
||||
<DependentUpon>CommentsPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -157,9 +154,6 @@
|
||||
<Compile Include="Pages\MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\PlaylistCardWide.xaml.cs">
|
||||
<DependentUpon>PlaylistCardWide.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\PlaylistPage.xaml.cs">
|
||||
<DependentUpon>PlaylistPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -174,18 +168,12 @@
|
||||
<Compile Include="Pages\Settings.xaml.cs">
|
||||
<DependentUpon>Settings.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\SettingsPages\Translate.xaml.cs">
|
||||
<DependentUpon>Translate.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\VideoPage.xaml.cs">
|
||||
<DependentUpon>VideoPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\VideoCard.xaml.cs">
|
||||
<DependentUpon>VideoCard.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\VideoCardWide.xaml.cs">
|
||||
<DependentUpon>VideoCardWide.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\VideoGrid.xaml.cs">
|
||||
<DependentUpon>VideoGrid.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -313,10 +301,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\ChannelCardWide.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Pages\CommentsPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -353,10 +337,6 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Controls\PlaylistCardWide.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Pages\PlaylistPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -369,10 +349,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Pages\SettingsPages\Translate.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Pages\Subscriptions.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -385,10 +361,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\VideoCardWide.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Pages\VideoGrid.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -2,12 +2,8 @@
|
||||
x:Class="FoxTube.MainPage"
|
||||
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"
|
||||
xmlns:ads="using:Microsoft.Advertising.WinRT.UI"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:pages="using:FoxTube.Pages"
|
||||
xmlns:Windows10version1803="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 6)"
|
||||
mc:Ignorable="d"
|
||||
SizeChanged="Page_SizeChanged"
|
||||
|
||||
+107
-76
@@ -9,47 +9,36 @@ using Windows.UI.Xaml.Navigation;
|
||||
using System.Diagnostics;
|
||||
using Windows.UI.Notifications;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.Storage;
|
||||
using System.Xml;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using System.Globalization;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.System;
|
||||
using Google.Apis.Oauth2.v2;
|
||||
using Google.Apis.Oauth2.v2.Data;
|
||||
using FoxTube.Controls;
|
||||
using FoxTube.Pages;
|
||||
using Windows.ApplicationModel;
|
||||
using System.Net;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.Networking.Connectivity;
|
||||
using Windows.UI.Core;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Google.Apis.YouTube.v3;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
|
||||
public enum Sender { Menu, Frame, None }
|
||||
|
||||
/// <summary>
|
||||
/// Main app's layout
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
Sender s = Sender.None;
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
//Comparing current version with last recorded version. If doesn't match, poping up changelog notification
|
||||
PackageVersion ver = Package.Current.Id.Version;
|
||||
if (settings.Values["ver"] == null)
|
||||
settings.Values.Add("ver", $"{ver.Major}.{ver.Minor}");
|
||||
|
||||
if((string)settings.Values["ver"] != $"{ver.Major}.{ver.Minor}")
|
||||
if(SettingsStorage.Version != $"{ver.Major}.{ver.Minor}")
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -59,9 +48,12 @@ namespace FoxTube
|
||||
|
||||
ToastNotificationManager.CreateToastNotifier().Show(FoxTube.Background.Notification.GetChangelogToast(e.GetAttribute("version")));
|
||||
|
||||
settings.Values["ver"] = $"{ver.Major}.{ver.Minor}";
|
||||
SettingsStorage.Version = $"{ver.Major}.{ver.Minor}";
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Unable to retrieve changelog");
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
SecretsVault.AuthorizationStateChanged += AuthorizationStateChanged;
|
||||
@@ -73,20 +65,6 @@ namespace FoxTube
|
||||
DownloadAgent.Initialize();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
public Video GetCurrentItem()
|
||||
@@ -109,10 +87,17 @@ namespace FoxTube
|
||||
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when subscriptions are edited to edit menu
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
private void SecretsVault_SubscriptionsChanged(object sender, params object[] args)
|
||||
{
|
||||
if ((string)args[0] == "add" && nav.MenuItems.Count < 19)
|
||||
{
|
||||
subsHeader.Visibility = Visibility.Visible;
|
||||
|
||||
Subscription s = args[1] as Subscription;
|
||||
StackPanel panel = new StackPanel()
|
||||
{
|
||||
@@ -134,12 +119,37 @@ namespace FoxTube
|
||||
});
|
||||
}
|
||||
else if ((string)args[0] == "remove" && (int)args[1] < 10)
|
||||
{
|
||||
nav.MenuItems.RemoveAt((int)args[1] + 9);
|
||||
if(SecretsVault.Subscriptions.Count >= 10)
|
||||
{
|
||||
Subscription s = SecretsVault.Subscriptions[9];
|
||||
StackPanel panel = new StackPanel()
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
Padding = new Thickness(5)
|
||||
};
|
||||
panel.Children.Add(new PersonPicture()
|
||||
{
|
||||
Height = 20,
|
||||
Margin = new Thickness(-5, 0, 15, 0),
|
||||
ProfilePicture = new BitmapImage(new Uri(s.Snippet.Thumbnails.Medium.Url))
|
||||
});
|
||||
panel.Children.Add(new TextBlock() { Text = s.Snippet.Title });
|
||||
nav.MenuItems.Add(new NavigationViewItem()
|
||||
{
|
||||
Content = panel,
|
||||
Name = (nav.MenuItems.Count - 9).ToString(),
|
||||
Padding = new Thickness(-5)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void AuthorizationStateChanged()
|
||||
|
||||
private async void AuthorizationStateChanged(object sender, params object[] e)
|
||||
{
|
||||
if(SecretsVault.IsAuthorized)
|
||||
if(e[0] as bool? == true)
|
||||
{
|
||||
account.Visibility = Visibility.Collapsed;
|
||||
try
|
||||
@@ -158,7 +168,6 @@ namespace FoxTube
|
||||
toHistory.Visibility = Visibility.Visible;
|
||||
toLiked.Visibility = Visibility.Visible;
|
||||
toLater.Visibility = Visibility.Visible;
|
||||
subsHeader.Visibility = Visibility.Visible;
|
||||
|
||||
if (SecretsVault.Subscriptions.Count > 0)
|
||||
{
|
||||
@@ -189,7 +198,7 @@ namespace FoxTube
|
||||
catch { continue; }
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (e[0] as bool? == false)
|
||||
{
|
||||
account.Visibility = Visibility.Visible;
|
||||
avatar.Visibility = Visibility.Collapsed;
|
||||
@@ -206,6 +215,25 @@ namespace FoxTube
|
||||
for(int k = 9; k < nav.MenuItems.Count; k++)
|
||||
nav.MenuItems.RemoveAt(k);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageDialog dialog = new MessageDialog("We were unabled to retrieve your account information due to weak internet connection or Google servers' problems. PLease, try again later", "Failed to connect");
|
||||
|
||||
dialog.Commands.Add(new UICommand("Try again", (command) =>
|
||||
{
|
||||
SecretsVault.Authorize();
|
||||
}));
|
||||
dialog.Commands.Add(new UICommand("Quit", (command) =>
|
||||
{
|
||||
Methods.CloseApp();
|
||||
}));
|
||||
dialog.Commands.Add(new UICommand("Close"));
|
||||
|
||||
dialog.CancelCommandIndex = 1;
|
||||
dialog.DefaultCommandIndex = 0;
|
||||
|
||||
await dialog.ShowAsync();
|
||||
}
|
||||
|
||||
content.Navigate(typeof(Home));
|
||||
|
||||
@@ -241,14 +269,11 @@ namespace FoxTube
|
||||
public void GoToSearch(SearchParameters args)
|
||||
{
|
||||
nav.IsPaneOpen = false;
|
||||
MinimizeAsInitializer();
|
||||
content.Navigate(typeof(Search), args);
|
||||
}
|
||||
|
||||
public void GoToChannel(string id)
|
||||
{
|
||||
Debug.WriteLine($"Channel id: {id}");
|
||||
MinimizeAsInitializer();
|
||||
content.Navigate(typeof(ChannelPage), id);
|
||||
}
|
||||
|
||||
@@ -258,7 +283,7 @@ namespace FoxTube
|
||||
try
|
||||
{
|
||||
var connection = NetworkInformation.GetInternetConnectionProfile().GetConnectionCost();
|
||||
if ((bool)settings.Values["moblieWarning"] && (connection.NetworkCostType == NetworkCostType.Fixed || connection.NetworkCostType == NetworkCostType.Variable))
|
||||
if (SettingsStorage.CheckConnection && (connection.NetworkCostType == NetworkCostType.Fixed || connection.NetworkCostType == NetworkCostType.Variable))
|
||||
{
|
||||
MessageDialog dialog = new MessageDialog("You are on metered connection now. Additional charges may apply. Do you want to continue?")
|
||||
{
|
||||
@@ -267,36 +292,33 @@ namespace FoxTube
|
||||
};
|
||||
dialog.Commands.Add(new UICommand("Yes"));
|
||||
dialog.Commands.Add(new UICommand("No", (command) => cancel = true));
|
||||
dialog.Commands.Add(new UICommand("Add to 'Watch later' playlist", (command) =>
|
||||
{
|
||||
try
|
||||
if(SecretsVault.IsAuthorized)
|
||||
dialog.Commands.Add(new UICommand("Add to 'Watch later' playlist", (command) =>
|
||||
{
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
SecretsVault.CheckAuthorization(false);
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
throw new Exception("Not authenticated");
|
||||
|
||||
PlaylistItem item = new PlaylistItem()
|
||||
try
|
||||
{
|
||||
Snippet = new PlaylistItemSnippet()
|
||||
PlaylistItem item = new PlaylistItem()
|
||||
{
|
||||
ResourceId = new ResourceId()
|
||||
Snippet = new PlaylistItemSnippet()
|
||||
{
|
||||
Kind = "youtube#video",
|
||||
VideoId = id
|
||||
},
|
||||
PlaylistId = "WL"
|
||||
}
|
||||
};
|
||||
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;
|
||||
}));
|
||||
|
||||
SecretsVault.Service.PlaylistItems.Insert(item, "snippet").Execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
}
|
||||
cancel = true;
|
||||
}));
|
||||
await dialog.ShowAsync();
|
||||
}
|
||||
}
|
||||
@@ -309,18 +331,16 @@ namespace FoxTube
|
||||
Fullscreen(false);
|
||||
|
||||
videoPlaceholder.Navigate(typeof(VideoPage), new string[2] { id, playlistId });
|
||||
nav.Header = "Video";
|
||||
}
|
||||
|
||||
public void GoToDeveloper(string id)
|
||||
{
|
||||
MinimizeAsInitializer();
|
||||
content.Navigate(typeof(Settings), $"inbox&{id}");
|
||||
}
|
||||
|
||||
public void GoToPlaylist(string id)
|
||||
{
|
||||
Debug.WriteLine($"Playlist id: {id}");
|
||||
MinimizeAsInitializer();
|
||||
content.Navigate(typeof(PlaylistPage), id);
|
||||
}
|
||||
|
||||
@@ -361,6 +381,21 @@ namespace FoxTube
|
||||
nav.IsBackEnabled = true;
|
||||
else
|
||||
nav.IsBackEnabled = false;
|
||||
|
||||
Dictionary<Type, Action> switchCase = new Dictionary<Type, Action>()
|
||||
{
|
||||
{ typeof(Settings), () => nav.Header = "Settings" },
|
||||
{ typeof(ChannelPage), () => nav.Header = "Channel" },
|
||||
{ typeof(PlaylistPage), () => nav.Header = "Playlist" },
|
||||
{ typeof(Search), () => nav.Header = "Search" },
|
||||
{ typeof(Subscriptions), () => nav.Header = "Subscriptions" },
|
||||
{ typeof(History), () => nav.Header = "History" },
|
||||
{ typeof(Home), () => nav.Header = "Home" },
|
||||
{ typeof(Downloads), () => nav.Header = "Downloads" }
|
||||
};
|
||||
|
||||
try { switchCase[content.SourcePageType](); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
public void MaximizeVideo()
|
||||
@@ -372,6 +407,9 @@ namespace FoxTube
|
||||
videoPlaceholder.Margin = new Thickness(0);
|
||||
|
||||
nav.IsBackEnabled = true;
|
||||
|
||||
if (videoPlaceholder.Content != null)
|
||||
nav.Header = "Video";
|
||||
}
|
||||
|
||||
public void Fullscreen(bool on)
|
||||
@@ -640,11 +678,6 @@ namespace FoxTube
|
||||
MinimizeAsInitializer();
|
||||
}
|
||||
|
||||
private void toChannel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GoToChannel(SecretsVault.UserChannel.Id);
|
||||
}
|
||||
|
||||
private void nav_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
|
||||
{
|
||||
if (videoPlaceholder.Content != null)
|
||||
@@ -653,8 +686,6 @@ namespace FoxTube
|
||||
CloseVideo();
|
||||
else if (videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
|
||||
MinimizeAsInitializer();
|
||||
else
|
||||
content.GoBack();
|
||||
}
|
||||
else
|
||||
content.GoBack();
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<Page
|
||||
x:Class="FoxTube.Pages.SettingsPages.Translate"
|
||||
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}">
|
||||
<StackPanel Orientation="Vertical" Margin="10">
|
||||
<TextBlock Text="Help us translate this app" FontSize="28"/>
|
||||
<TextBlock TextWrapping="WrapWholeWords" Text="You can help us make this app even better by contributing to its development by translating this app. You can choose a brand new language to translate or edit mistakes in existing translations." Margin="0,0,0,10"/>
|
||||
<StackPanel BorderThickness="2" BorderBrush="OrangeRed" MaxWidth="500" HorizontalAlignment="Left" Margin="0,0,0,10" Padding="0,0,0,3">
|
||||
<TextBlock Foreground="OrangeRed" FontWeight="SemiBold" TextWrapping="WrapWholeWords" Text="Attention! This tool is used to help us to provide our app to more people from other countries. Please, don't send not done language packs. Thanks in advance ;)" Margin="5"/>
|
||||
</StackPanel>
|
||||
<TextBlock Text="It's quite simple:" Margin="0,0,0,10"/>
|
||||
|
||||
<ComboBox Header="1. Choose language you want to translate" PlaceholderText="Choose language..." Name="LangList" Margin="0,0,0,10" MinWidth="350" SelectionChanged="LangList_SelectionChanged"/>
|
||||
|
||||
<TextBlock Text="2. Import language pack file to your PC" Margin="0,0,0,10"/>
|
||||
|
||||
<Button Content="Export to PC (.xml)" Margin="0,0,0,10" Name="export" Click="export_Click" IsEnabled="False"/>
|
||||
|
||||
<TextBlock TextWrapping="WrapWholeWords" Text="3. Open file with any text editor you want (Notepad, Wordpad, Notepad++, VS Code, etc.)" Margin="0,0,0,10"/>
|
||||
<TextBlock TextWrapping="WrapWholeWords" Text="4. Edit file by translating nececcary words and sentences" Margin="0,0,0,10"/>
|
||||
<TextBlock Text="5. Upload final package to our servers" Margin="0,0,0,10"/>
|
||||
|
||||
<StackPanel Name="submitNotification" Visibility="Collapsed" BorderThickness="2" BorderBrush="OrangeRed" Width="350" HorizontalAlignment="Left" Margin="0,0,0,10" Padding="0,0,0,3">
|
||||
<TextBlock Foreground="OrangeRed" FontWeight="SemiBold" Text="Attention! Once you submitted this language pack you won't be able to contribute to the language anymore. Think twice before continuing" TextWrapping="WrapWholeWords" Margin="5"/>
|
||||
</StackPanel>
|
||||
<Button Content="Choose file to upload" Margin="-1,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Top" Name="upload" IsEnabled="False" Click="upload_Click"/>
|
||||
<ProgressBar Width="250" HorizontalAlignment="Left" IsIndeterminate="True" Name="uploadingProgress" Visibility="Collapsed"/>
|
||||
<TextBlock TextWrapping="WrapWholeWords" Text="It takes about 2-3 weeks to process new language pack and include it to the next update" Margin="0,0,0,10"/>
|
||||
<TextBlock Text="Thank you for your help 😚"/>
|
||||
<TextBlock Text="Best wishes,"/>
|
||||
<TextBlock Text=" XFox"/>
|
||||
<StackPanel Orientation="Horizontal" BorderBrush="Green" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="greenResult">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" FontSize="40" Foreground="Green" Margin="5"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Your language pack 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="denied">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" FontSize="40" Foreground="OrangeRed" Margin="5"/>
|
||||
<StackPanel>
|
||||
<TextBlock Text="You have already contributed to this language" Foreground="OrangeRed" FontWeight="Bold" FontSize="20"/>
|
||||
<TextBlock Text="To prevent spaming our mailbox we allow our users to contribute to each language only 1 time" Foreground="OrangeRed"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
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.Pickers;
|
||||
using Windows.Storage;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using Windows.UI.Popups;
|
||||
|
||||
// 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 Translate : Page
|
||||
{
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
int selectedLanguage;
|
||||
public Translate()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
|
||||
LangList.Items.Add(culture.DisplayName);
|
||||
}
|
||||
|
||||
private async void export_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FileSavePicker picker = new FileSavePicker();
|
||||
picker.CommitButtonText = "Export";
|
||||
picker.DefaultFileExtension = ".xml";
|
||||
picker.SuggestedFileName = "foxtube_langpack_" + CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage];
|
||||
picker.SuggestedStartLocation = PickerLocationId.Desktop;
|
||||
picker.FileTypeChoices.Add("Language pack scheme", new List<string>() { ".xml" });
|
||||
|
||||
StorageFile file = await picker.PickSaveFileAsync();
|
||||
if(file != null)
|
||||
await FileIO.WriteTextAsync(file, GetPackage(selectedLanguage));
|
||||
}
|
||||
|
||||
private void LangList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
selectedLanguage = LangList.SelectedIndex;
|
||||
|
||||
greenResult.Visibility = Visibility.Collapsed;
|
||||
denied.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (settings.Values[CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage] + "_sent"] == null)
|
||||
{
|
||||
export.IsEnabled = true;
|
||||
upload.IsEnabled = true;
|
||||
submitNotification.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
export.IsEnabled = false;
|
||||
upload.IsEnabled = false;
|
||||
denied.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
private async void upload_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FileOpenPicker picker = new FileOpenPicker()
|
||||
{
|
||||
CommitButtonText = "Upload",
|
||||
SuggestedStartLocation = PickerLocationId.Desktop
|
||||
};
|
||||
picker.FileTypeFilter.Clear();
|
||||
picker.FileTypeFilter.Add(".xml");
|
||||
|
||||
StorageFile file = await picker.PickSingleFileAsync();
|
||||
if (file != null)
|
||||
{
|
||||
MailMessage msg = new MailMessage();
|
||||
msg.To.Add("foxgameofficial+foxtube@gmail.com");
|
||||
msg.From = new MailAddress("foxgameofficial+foxtube@gmail.com");
|
||||
msg.Subject = "FoxTube language pack contribution";
|
||||
msg.Body = string.Format("Language: {0}\nLanguage code: {1}", CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage].EnglishName, CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage]);
|
||||
msg.Attachments.Add(new Attachment(file.Path));
|
||||
|
||||
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
|
||||
client.EnableSsl = true;
|
||||
client.Credentials = SecretsVault.EmailCredential;
|
||||
|
||||
upload.IsEnabled = false;
|
||||
export.IsEnabled = false;
|
||||
uploadingProgress.Visibility = Visibility.Visible;
|
||||
try
|
||||
{
|
||||
client.Send(msg);
|
||||
greenResult.Visibility = Visibility.Visible;
|
||||
submitNotification.Visibility = Visibility.Collapsed;
|
||||
settings.Values.Add(CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage] + "_sent", true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageDialog message = new MessageDialog("We were 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();
|
||||
export.IsEnabled = true;
|
||||
upload.IsEnabled = true;
|
||||
}
|
||||
uploadingProgress.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetPackage(int cultureIndex)
|
||||
{
|
||||
return "langpack";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,6 @@ using FoxTube.Controls;
|
||||
using YoutubeExplode.Models.MediaStreams;
|
||||
using YoutubeExplode;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace FoxTube.Pages
|
||||
{
|
||||
public enum Rating { None, Like, Dislike }
|
||||
@@ -42,7 +40,7 @@ namespace FoxTube.Pages
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// Video page
|
||||
/// </summary>
|
||||
public sealed partial class VideoPage : Page
|
||||
{
|
||||
@@ -175,7 +173,7 @@ namespace FoxTube.Pages
|
||||
license.Text = "Standard YouTube License";
|
||||
else license.Text = "Creative Commons Attribution license (reuse allowed)";
|
||||
|
||||
VideoCategoriesResource.ListRequest categoryRequest = SecretsVault.NoAuthService.VideoCategories.List("snippet");
|
||||
VideoCategoriesResource.ListRequest categoryRequest = SecretsVault.Service.VideoCategories.List("snippet");
|
||||
categoryRequest.Id = item.Snippet.CategoryId;
|
||||
category.Text = (await categoryRequest.ExecuteAsync()).Items[0].Snippet.Title;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user