Archived
1
0

Optimizing, debugging, decorating

This commit is contained in:
Michael Gordeev
2019-02-08 12:50:43 +03:00
parent 9548be15f3
commit cc49cf9966
34 changed files with 681 additions and 730 deletions
+2
View File
@@ -5,5 +5,7 @@
xmlns:local="using:FoxTube"> xmlns:local="using:FoxTube">
<Application.Resources> <Application.Resources>
<Color x:Key="SystemAccentColor">Red</Color> <Color x:Key="SystemAccentColor">Red</Color>
<Style TargetType="Button" BasedOn="{StaticResource ButtonRevealStyle}"/>
<Style TargetType="ListViewItem" BasedOn="{StaticResource ListViewItemRevealStyle}"/>
</Application.Resources> </Application.Resources>
</Application> </Application>
+32 -25
View File
@@ -4,7 +4,9 @@ using Microsoft.AppCenter.Analytics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Xml;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation; using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Background; using Windows.ApplicationModel.Background;
@@ -19,15 +21,8 @@ using Windows.UI.Xaml.Navigation;
namespace FoxTube namespace FoxTube
{ {
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application sealed partial class App : Application
{ {
/// <summary>
/// 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>
public App() public App()
{ {
SettingsStorage.LoadData(); SettingsStorage.LoadData();
@@ -41,20 +36,44 @@ namespace FoxTube
RequestedTheme = ApplicationTheme.Dark; RequestedTheme = ApplicationTheme.Dark;
break; break;
} }
ApplicationLanguages.PrimaryLanguageOverride = SettingsStorage.Language; ApplicationLanguages.PrimaryLanguageOverride = SettingsStorage.Language;
CheckVersion();
InitializeComponent(); InitializeComponent();
Suspending += OnSuspending; Suspending += OnSuspending;
UnhandledException += UnhandledError; UnhandledException += UnhandledError;
AppCenter.Start("45774462-9ea7-438a-96fc-03982666f39e", typeof(Analytics)); AppCenter.Start("45774462-9ea7-438a-96fc-03982666f39e", typeof(Analytics));
AppCenter.SetCountryCode(SettingsStorage.Region); AppCenter.SetCountryCode(SettingsStorage.Region);
} }
/// <summary> /// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points /// Comparing current version with last recorded version. If doesn't match, poping up changelog notification
/// will be used such as when the application is launched to open a specific file.
/// </summary> /// </summary>
/// <param name="e">Details about the launch request and process.</param> public async void CheckVersion()
{
PackageVersion ver = Package.Current.Id.Version;
if (SettingsStorage.Version != $"{ver.Major}.{ver.Minor}")
{
try
{
XmlDocument changelog = new XmlDocument();
StorageFile file = await (await Package.Current.InstalledLocation.GetFolderAsync(@"Assets\Data")).GetFileAsync("Patchnotes.xml");
changelog.Load(await file.OpenStreamForReadAsync());
XmlElement e = changelog["items"].ChildNodes[0] as XmlElement;
ToastNotificationManager.CreateToastNotifier().Show(FoxTube.Background.Notification.GetChangelogToast(e.GetAttribute("version")));
SettingsStorage.Version = $"{ver.Major}.{ver.Minor}";
}
catch
{
Debug.WriteLine("Unable to retrieve changelog");
}
}
}
protected override void OnLaunched(LaunchActivatedEventArgs e) protected override void OnLaunched(LaunchActivatedEventArgs e)
{ {
// Do not repeat app initialization when the Window already has content, // Do not repeat app initialization when the Window already has content,
@@ -97,7 +116,6 @@ namespace FoxTube
return; return;
var backgroundRequest = await BackgroundExecutionManager.RequestAccessAsync(); var backgroundRequest = await BackgroundExecutionManager.RequestAccessAsync();
var saverRequest = PowerManager.EnergySaverStatus;
if (backgroundRequest == BackgroundAccessStatus.DeniedBySystemPolicy || backgroundRequest == BackgroundAccessStatus.DeniedByUser) if (backgroundRequest == BackgroundAccessStatus.DeniedBySystemPolicy || backgroundRequest == BackgroundAccessStatus.DeniedByUser)
return; return;
@@ -226,30 +244,19 @@ namespace FoxTube
} }
} }
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e) void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{ {
throw new Exception("Failed to load Page " + e.SourcePageType.FullName); throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
} }
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e) private void OnSuspending(object sender, SuspendingEventArgs e)
{ {
var deferral = e.SuspendingOperation.GetDeferral(); var deferral = e.SuspendingOperation.GetDeferral();
SettingsStorage.ExportSettings(); SettingsStorage.SaveData();
DownloadAgent.QuitPrompt(); DownloadAgent.QuitPrompt();
deferral.Complete(); deferral.Complete();
} }
private void UnhandledError(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) private void UnhandledError(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{ {
Analytics.TrackEvent("The app crashed", new Dictionary<string, string>() Analytics.TrackEvent("The app crashed", new Dictionary<string, string>()
+1
View File
@@ -9,6 +9,7 @@ using FoxTube.Controls;
namespace FoxTube namespace FoxTube
{ {
// TODO: Refactor DownloadAgent
public static class DownloadAgent public static class DownloadAgent
{ {
public static List<DownloadItem> items = new List<DownloadItem>(); public static List<DownloadItem> items = new List<DownloadItem>();
+11 -8
View File
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
@@ -31,7 +30,6 @@ namespace FoxTube
private static ResourceLoader resources = ResourceLoader.GetForCurrentView("Methods"); private static ResourceLoader resources = ResourceLoader.GetForCurrentView("Methods");
public static CommentsPage CommentsPage { get; set; } public static CommentsPage CommentsPage { get; set; }
public static bool NeedToResponse { get; set; } = false;
public static MainPage MainPage public static MainPage MainPage
{ {
get { return (Window.Current.Content as Frame).Content as MainPage; } get { return (Window.Current.Content as Frame).Content as MainPage; }
@@ -47,6 +45,15 @@ namespace FoxTube
return new Uri(url); return new Uri(url);
} }
public static void Try(Action action)
{
try
{
action();
}
catch { }
}
public static string GetChars(this string str, int count) public static string GetChars(this string str, int count)
{ {
try try
@@ -316,9 +323,7 @@ namespace FoxTube
{ {
List<string> list = new List<string>(); List<string> list = new List<string>();
HttpClient client = new HttpClient(); string output = await SecretsVault.HttpClient.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=HL&hl={SettingsStorage.RelevanceLanguage}");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", SecretsVault.Credential.Token.AccessToken);
string output = await client.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=HL&hl={SettingsStorage.RelevanceLanguage}");
dynamic raw = JsonConvert.DeserializeObject(output); dynamic raw = JsonConvert.DeserializeObject(output);
foreach (dynamic i in raw.video) foreach (dynamic i in raw.video)
@@ -331,9 +336,7 @@ namespace FoxTube
{ {
List<string> list = new List<string>(); List<string> list = new List<string>();
HttpClient client = new HttpClient(); string output = await SecretsVault.HttpClient.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=WL&hl={SettingsStorage.RelevanceLanguage}");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", SecretsVault.Credential.Token.AccessToken);
string output = await client.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=WL&hl={SettingsStorage.RelevanceLanguage}");
dynamic raw = JsonConvert.DeserializeObject(output); dynamic raw = JsonConvert.DeserializeObject(output);
foreach (dynamic i in raw.video) foreach (dynamic i in raw.video)
+39 -7
View File
@@ -9,6 +9,7 @@ using Google.Apis.YouTube.v3.Data;
using Newtonsoft.Json; using Newtonsoft.Json;
using Windows.Storage; using Windows.Storage;
using Windows.Services.Store; using Windows.Services.Store;
using System.Net.Http;
namespace FoxTube namespace FoxTube
{ {
@@ -37,18 +38,21 @@ namespace FoxTube
ApplicationName = "FoxTube" ApplicationName = "FoxTube"
}; };
public static YouTubeService Service => IsAuthorized ? new YouTubeService(Initializer) : NoAuthService; public static YouTubeService Service => IsAuthorized ? new YouTubeService(Initializer) : NoAuthService;
public static HttpClient HttpClient { get; } = new HttpClient();
public static string AppId => true ? "d25517cb-12d4-4699-8bdc-52040c712cab" : "9ncqqxjtdlfh"; public static string AppId => true ? "d25517cb-12d4-4699-8bdc-52040c712cab" : "9ncqqxjtdlfh";
public static string AdUnitId => true ? "test" : "1100037769"; public static string AdUnitId => true ? "test" : "1100037769";
public static bool AdsDisabled { get; private set; } = true; public static bool AdsDisabled { get; private set; } = true;
//User info //User info
public static bool IsAuthorized => Credential != null; public static bool IsAuthorized => Credential != null;
public static UserCredential Credential { get; set; } private static UserCredential Credential { get; set; }
public static string AccountId => UserChannel?.Id; public static string AccountId => UserChannel?.Id;
public static Channel UserChannel { get; private set; } public static Channel UserChannel { get; private set; }
public static List<Subscription> Subscriptions { get; } = new List<Subscription>(); public static List<Subscription> Subscriptions { get; } = new List<Subscription>();
public static List<string> History { get; set; } = new List<string>();
public static List<string> WatchLater { get; set; } = new List<string>();
#endregion #endregion
#region Methods #region Methods
@@ -69,7 +73,7 @@ namespace FoxTube
try { await Service.Subscriptions.Delete(s.Id).ExecuteAsync(); } try { await Service.Subscriptions.Delete(s.Id).ExecuteAsync(); }
catch { return true; } catch { return true; }
SubscriptionsChanged?.Invoke(null, "remove", Subscriptions.IndexOf(s)); SubscriptionsChanged?.Invoke(null, "remove", s);
Subscriptions.Remove(s); Subscriptions.Remove(s);
return false; return false;
} }
@@ -96,6 +100,16 @@ namespace FoxTube
} }
} }
/// <summary>
/// Sets up **SecretsVault**
/// </summary>
public static void Initialize()
{
CheckAuthorization();
// TODO: Reactivate addons initialization
//CheckAddons();
}
/// <summary> /// <summary>
/// Prompts to add an Youtube account and retrieves its info when successful /// Prompts to add an Youtube account and retrieves its info when successful
/// </summary> /// </summary>
@@ -123,9 +137,13 @@ namespace FoxTube
goto InvokeEvent; goto InvokeEvent;
SettingsStorage.HasAccount = true; SettingsStorage.HasAccount = true;
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Credential.Token.AccessToken);
#endregion #endregion
#region Retrieving user's data #region Retrieving user's data
WatchLater = await Methods.GetLater();
History = await Methods.GetHistory();
var request = Service.Channels.List("snippet,contentDetails"); var request = Service.Channels.List("snippet,contentDetails");
request.Mine = true; request.Mine = true;
UserChannel = (await request.ExecuteAsync()).Items[0]; UserChannel = (await request.ExecuteAsync()).Items[0];
@@ -183,6 +201,11 @@ namespace FoxTube
Credential = null; Credential = null;
AuthorizationStateChanged?.Invoke(args: false); AuthorizationStateChanged?.Invoke(args: false);
SettingsStorage.HasAccount = false; SettingsStorage.HasAccount = false;
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync(
"background.json", CreationCollisionOption.ReplaceExisting)
, "");
} }
} }
@@ -190,11 +213,18 @@ namespace FoxTube
/// Checks if any user has already been logged in. If has, calls *Authorize()* to retrieve his info /// Checks if any user has already been logged in. If has, calls *Authorize()* to retrieve his info
/// </summary> /// </summary>
/// <param name="retrieveSubs">Loads user's subscriptions if true</param> /// <param name="retrieveSubs">Loads user's subscriptions if true</param>
public static void CheckAuthorization(bool retrieveSubs = true) public static async void CheckAuthorization(bool retrieveSubs = true)
{ {
if (SettingsStorage.HasAccount) if (SettingsStorage.HasAccount)
Authorize(retrieveSubs); Authorize(retrieveSubs);
else AuthorizationStateChanged.Invoke(args: false); else
{
AuthorizationStateChanged.Invoke(args: false);
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync(
"background.json", CreationCollisionOption.ReplaceExisting),
"");
}
} }
/// <summary> /// <summary>
@@ -205,9 +235,11 @@ namespace FoxTube
try try
{ {
StoreContext store = StoreContext.GetDefault(); StoreContext store = StoreContext.GetDefault();
StoreProductQueryResult requset = await store.GetAssociatedStoreProductsAsync(new[] { "Consumable", "Durable", "UnmanagedConsumable" }); StoreProductQueryResult requset = await store.GetAssociatedStoreProductsAsync(new[] { "Durable" });
Dictionary<string, StoreProduct> l = new Dictionary<string, StoreProduct>();
requset.Products.ForEach(i => l.Add(i.Key, i.Value));
if (!requset.Products["foxtube-adsremove"].IsInUserCollection) if (!requset.Products["9NP1QK556625"].IsInUserCollection)
{ {
AdsDisabled = false; AdsDisabled = false;
Purchased?.Invoke(args:false); Purchased?.Invoke(args:false);
@@ -219,7 +251,7 @@ namespace FoxTube
public static async void GetAdblock() public static async void GetAdblock()
{ {
StoreContext store = StoreContext.GetDefault(); StoreContext store = StoreContext.GetDefault();
StorePurchaseResult request = await store.RequestPurchaseAsync("foxtube-adsremove"); StorePurchaseResult request = await store.RequestPurchaseAsync("9NP1QK556625");
switch (request.Status) switch (request.Status)
{ {
+60 -96
View File
@@ -9,126 +9,146 @@ namespace FoxTube
{ {
public enum MatureState { Blocked, Allowed, AllowedOnce } public enum MatureState { Blocked, Allowed, AllowedOnce }
public class SettingsContainer
{
public string videoQuality = "remember";
public string rememberedQuality = "1080p";
public bool videoNotifications = true;
public bool devNotifications = true;
public bool checkConnection = true;
public bool autoplay = true;
public int volume = 100;
public string language = (new[] { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" }).Contains(CultureInfo.InstalledUICulture.TwoLetterISOLanguageName) ? "ru-RU" : "en-US";
public string relevanceLanguage = (new[] { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" }).Contains(CultureInfo.InstalledUICulture.TwoLetterISOLanguageName) ? "ru" : "en";
public string region = (new[] { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" }).Contains(CultureInfo.InstalledUICulture.TwoLetterISOLanguageName) ? "ru" : "us";
public int safeSearch = 0;
public bool hasAccount = false;
public int theme = 2;
}
public static class SettingsStorage public static class SettingsStorage
{ {
public static string VideoQuality public static string VideoQuality
{ {
get { return (string)settings[0]; } get { return Container.videoQuality; }
set set
{ {
settings[0] = value; Container.videoQuality = value;
SaveData(); SaveData();
} }
} }
public static string RememberedQuality public static string RememberedQuality
{ {
get { return (string)settings[1]; } get { return Container.rememberedQuality; }
set set
{ {
settings[1] = value; Container.rememberedQuality = value;
SaveData(); SaveData();
} }
} }
public static bool VideoNotifications public static bool VideoNotifications
{ {
get { return (bool)settings[2]; } get { return Container.videoNotifications; }
set set
{ {
settings[2] = value; Container.videoNotifications = value;
SaveData(); SaveData();
} }
} }
public static bool DevNotifications public static bool DevNotifications
{ {
get { return (bool)settings[3]; } get { return Container.devNotifications; }
set set
{ {
settings[3] = value; Container.devNotifications = value;
SaveData(); SaveData();
} }
} }
public static bool CheckConnection public static bool CheckConnection
{ {
get { return (bool)settings[4]; } get { return Container.checkConnection; }
set set
{ {
settings[4] = value; Container.checkConnection = value;
SaveData(); SaveData();
} }
} }
public static bool Autoplay public static bool Autoplay
{ {
get { return (bool)settings[5]; } get { return Container.autoplay; }
set set
{ {
settings[5] = value; Container.autoplay = value;
SaveData(); SaveData();
} }
} }
public static int Volume public static int Volume
{ {
get { return Convert.ToInt32(settings[6]); } get { return Container.volume; }
set set
{ {
settings[6] = value; Container.volume = value;
SaveData(); SaveData();
} }
} }
public static string Language public static string Language
{ {
get { return (string)settings[7]; } get { return Container.language; }
set set
{ {
settings[7] = value; Container.language = value;
SaveData(); SaveData();
} }
} }
public static string RelevanceLanguage public static string RelevanceLanguage
{ {
get { return (string)settings[8]; } get { return Container.relevanceLanguage; }
set set
{ {
settings[8] = value; Container.relevanceLanguage = value;
SaveData(); SaveData();
} }
} }
public static string Region public static string Region
{ {
get { return (string)settings[9]; } get { return Container.region; }
set set
{ {
settings[9] = value; Container.region = value;
SaveData(); SaveData();
} }
} }
public static int SafeSearch public static int SafeSearch
{ {
get { return Convert.ToInt32(settings[10]); } get { return Container.safeSearch; }
set set
{ {
settings[10] = value; Container.safeSearch = value;
SaveData();
}
}
public static int Theme
{
get { return Convert.ToInt32(settings[11]); }
set
{
settings[11] = value;
SaveData(); SaveData();
} }
} }
public static bool HasAccount public static bool HasAccount
{ {
get { return (bool)settings[12]; } get { return Container.hasAccount; }
set set
{ {
settings[12] = value; Container.hasAccount = value;
SaveData();
}
}
public static int Theme
{
get { return Container.theme; }
set
{
Container.theme = value;
SaveData(); SaveData();
} }
} }
@@ -169,80 +189,24 @@ namespace FoxTube
//Settings storage //Settings storage
private static readonly ApplicationDataContainer storage = ApplicationData.Current.RoamingSettings; private static readonly ApplicationDataContainer storage = ApplicationData.Current.RoamingSettings;
private static SettingsContainer Container;
//Predefined preferences
private static object[] settings = new object[]
{
"remember",
"1080p",
true,
true,
true,
true,
100,
(new[] { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" }).Contains(CultureInfo.InstalledUICulture.TwoLetterISOLanguageName) ? "ru-RU" : "en-US",
(new[] { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" }).Contains(CultureInfo.InstalledUICulture.TwoLetterISOLanguageName) ? "ru" : "en",
(new[] { "ua", "ru", "by", "kz", "kg", "md", "lv", "ee" }).Contains(CultureInfo.InstalledUICulture.TwoLetterISOLanguageName) ? "ru" : "US",
0,
2,
false
};
public static void LoadData() public static void LoadData()
{ {
/*if(true && (storage.Values["forceUpdate"] == null || storage.Values["forceUpdate"].ToString() != Version))
{
SaveData();
storage.Values["forceUpdate"] = Version;
return;
}*/
try try
{ {
object[] saved = JsonConvert.DeserializeObject<object[]>(storage.Values["settings"] as string); Container = JsonConvert.DeserializeObject<SettingsContainer>(storage.Values["settings"] as string);
if (settings.Length > saved.Length) }
catch
{ {
if (saved[0] is string) Container = new SettingsContainer();
settings[0] = saved;
if (saved[1] is string)
settings[1] = saved;
if (saved[2] is bool)
settings[2] = saved;
if (saved[3] is bool)
settings[3] = saved;
if (saved[4] is bool)
settings[4] = saved;
if (saved[5] is bool)
settings[5] = saved;
if (saved[6] is int)
settings[6] = saved;
if (saved[7] is string)
settings[7] = saved;
if (saved[8] is string)
settings[8] = saved;
if (saved[9] is string)
settings[9] = saved;
if (saved[10] is int)
settings[10] = saved;
if (saved[11] is int)
settings[11] = saved;
if (saved[12] is bool)
settings[12] = saved;
SaveData(); SaveData();
} }
else settings = saved;
}
catch (ArgumentNullException) { }
} }
public static void SaveData() public static void SaveData()
{ {
storage.Values["settings"] = JsonConvert.SerializeObject(settings); storage.Values["settings"] = JsonConvert.SerializeObject(Container);
ExportSettings(); ExportSettings();
} }
+1 -1
View File
@@ -15,7 +15,7 @@ namespace FoxTube.Controls
/// <summary> /// <summary>
/// Channel item card /// Channel item card
/// </summary> /// </summary>
public sealed partial class ChannelCard : UserControl public sealed partial class ChannelCard : UserControl, IItemCard
{ {
ResourceLoader resources = ResourceLoader.GetForCurrentView("Cards"); ResourceLoader resources = ResourceLoader.GetForCurrentView("Cards");
+1 -1
View File
@@ -12,7 +12,7 @@ namespace FoxTube.Controls
/// <summary> /// <summary>
/// Playlist card control /// Playlist card control
/// </summary> /// </summary>
public sealed partial class PlaylistCard : Page public sealed partial class PlaylistCard : Page, IItemCard
{ {
Playlist item; Playlist item;
public string playlistId; public string playlistId;
+2 -2
View File
@@ -11,8 +11,8 @@
d:DesignHeight="290" d:DesignHeight="290"
d:DesignWidth="384"> d:DesignWidth="384">
<Button Padding="0" Background="Transparent" Click="Button_Click"> <Button Padding="0" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}" Click="Button_Click">
<Grid Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}"> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="75"/> <RowDefinition Height="75"/>
+8 -2
View File
@@ -13,7 +13,7 @@ namespace FoxTube.Controls
/// <summary> /// <summary>
/// Video item card /// Video item card
/// </summary> /// </summary>
public sealed partial class VideoCard : UserControl public sealed partial class VideoCard : UserControl, IItemCard
{ {
ResourceLoader resources = ResourceLoader.GetForCurrentView("Cards"); ResourceLoader resources = ResourceLoader.GetForCurrentView("Cards");
@@ -34,6 +34,7 @@ namespace FoxTube.Controls
public async void Initialize(string id, string playlist = null) public async void Initialize(string id, string playlist = null)
{ {
try {
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails"); VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails");
request.Id = id; request.Id = id;
VideoListResponse response = await request.ExecuteAsync(); VideoListResponse response = await request.ExecuteAsync();
@@ -53,7 +54,7 @@ namespace FoxTube.Controls
info.Text = item.LiveStreamingDetails.ActualStartTime.Value.ToString(); info.Text = item.LiveStreamingDetails.ActualStartTime.Value.ToString();
liveTag.Visibility = Visibility.Visible; liveTag.Visibility = Visibility.Visible;
} }
else if(item.Snippet.LiveBroadcastContent == "upcoming") else if (item.Snippet.LiveBroadcastContent == "upcoming")
{ {
views.Text = ""; views.Text = "";
if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && item.LiveStreamingDetails.ScheduledEndTime.HasValue) if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && item.LiveStreamingDetails.ScheduledEndTime.HasValue)
@@ -89,6 +90,11 @@ namespace FoxTube.Controls
leftOn.Value = SecretsVault.UserHistory.Find(x => x.Id == videoId).LeftOn; leftOn.Value = SecretsVault.UserHistory.Find(x => x.Id == videoId).LeftOn;
}*/ }*/
} }
catch
{
Visibility = Visibility.Collapsed;
}
}
public void Button_Click(object sender, RoutedEventArgs e) public void Button_Click(object sender, RoutedEventArgs e)
{ {
+20 -4
View File
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls1="using:FoxTube.Controls" xmlns:controls1="using:FoxTube.Controls"
xmlns:Windows10version1809="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="1080" d:DesignHeight="1080"
d:DesignWidth="1920" d:DesignWidth="1920"
@@ -19,12 +20,18 @@
<controls1:LiveCaptions Player="{x:Bind controller}" Visibility="Collapsed"/> <controls1:LiveCaptions Player="{x:Bind controller}" Visibility="Collapsed"/>
<Grid Name="controls" Visibility="Visible"> <Grid Name="controls" Visibility="Visible">
<Windows10version1809:Grid.OpacityTransition>
<Windows10version1809:ScalarTransition/>
</Windows10version1809:Grid.OpacityTransition>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Name="header" Height="50" Background="#7F000000"> <Grid Name="header" Height="50">
<Grid.Background>
<AcrylicBrush TintColor="#CC000000" TintOpacity="0.6"/>
</Grid.Background>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition/> <ColumnDefinition/>
@@ -60,7 +67,10 @@
<Grid Grid.Row="1" Name="playPauseArea" Tapped="playPauseArea_Tapped" DoubleTapped="playPauseArea_DoubleTapped" Background="Black" Opacity=".0001"/> <Grid Grid.Row="1" Name="playPauseArea" Tapped="playPauseArea_Tapped" DoubleTapped="playPauseArea_DoubleTapped" Background="Black" Opacity=".0001"/>
<Grid Name="touchCentral" Background="#7F000000" Visibility="Collapsed" Grid.Row="1"> <Grid Name="touchCentral" Visibility="Collapsed" Grid.Row="1">
<Grid.Background>
<AcrylicBrush TintColor="#CC000000" TintOpacity="0.1"/>
</Grid.Background>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button VerticalAlignment="Center" Content="&#xED3C;" FontFamily="Segoe MDL2 Assets" Background="Transparent" FontSize="40" Foreground="WhiteSmoke" Name="touchBack10" Click="back10_Click"/> <Button VerticalAlignment="Center" Content="&#xED3C;" FontFamily="Segoe MDL2 Assets" Background="Transparent" FontSize="40" Foreground="WhiteSmoke" Name="touchBack10" Click="back10_Click"/>
<Button VerticalAlignment="Center" Content="&#xE102;" FontFamily="Segoe MDL2 Assets" Background="Transparent" FontSize="100" Foreground="WhiteSmoke" Name="touchPlay" Click="play_Click"/> <Button VerticalAlignment="Center" Content="&#xE102;" FontFamily="Segoe MDL2 Assets" Background="Transparent" FontSize="100" Foreground="WhiteSmoke" Name="touchPlay" Click="play_Click"/>
@@ -89,7 +99,10 @@
<ProgressBar VerticalAlignment="Bottom" Foreground="Red" Name="seekIndicator" Visibility="Collapsed"/> <ProgressBar VerticalAlignment="Bottom" Foreground="Red" Name="seekIndicator" Visibility="Collapsed"/>
</Grid> </Grid>
<StackPanel Name="schedulePanel" Visibility="Collapsed" VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.Row="1" BorderBrush="Black" BorderThickness="2" Background="#7E000000" Padding="10" Margin="0,25" Orientation="Horizontal"> <StackPanel Name="schedulePanel" Visibility="Collapsed" VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.Row="1" BorderBrush="Black" BorderThickness="2" Padding="10" Margin="0,25" Orientation="Horizontal">
<StackPanel.Background>
<AcrylicBrush TintColor="#CC000000" TintOpacity="0.6"/>
</StackPanel.Background>
<FontIcon Glyph="&#xE704;" FontSize="30" Margin="0,0,10,0" VerticalAlignment="Top"/> <FontIcon Glyph="&#xE704;" FontSize="30" Margin="0,0,10,0" VerticalAlignment="Top"/>
<StackPanel> <StackPanel>
<TextBlock FontWeight="Bold" Text="Stream hasn't started yet"/> <TextBlock FontWeight="Bold" Text="Stream hasn't started yet"/>
@@ -102,7 +115,10 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<Grid Grid.Row="2" Height="50" Name="mainControls" Background="#7F000000"> <Grid Grid.Row="2" Height="50" Name="mainControls">
<Grid.Background>
<AcrylicBrush TintColor="#CC000000" TintOpacity="0.6"/>
</Grid.Background>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
+23 -9
View File
@@ -24,6 +24,8 @@ using FoxTube.Controls;
using Windows.System; using Windows.System;
using Windows.Media.Core; using Windows.Media.Core;
using Windows.Media.Playback; using Windows.Media.Playback;
using System.Net.Http;
using System.Diagnostics;
namespace FoxTube namespace FoxTube
{ {
@@ -34,6 +36,7 @@ namespace FoxTube
public string videoId; public string videoId;
public Video item; public Video item;
public string avatar; public string avatar;
public bool incognito = false;
public PlayerLayout layout = PlayerLayout.Normal; public PlayerLayout layout = PlayerLayout.Normal;
public bool pointerCaptured = false; public bool pointerCaptured = false;
@@ -56,7 +59,7 @@ namespace FoxTube
IReadOnlyList<ClosedCaptionTrackInfo> ccInfo; IReadOnlyList<ClosedCaptionTrackInfo> ccInfo;
MediaStreamInfoSet streamInfo; MediaStreamInfoSet streamInfo;
DispatcherTimer timer = new DispatcherTimer() readonly DispatcherTimer timer = new DispatcherTimer()
{ {
Interval = TimeSpan.FromSeconds(1) Interval = TimeSpan.FromSeconds(1)
}; };
@@ -73,13 +76,14 @@ namespace FoxTube
InitializeComponent(); InitializeComponent();
} }
public void Initialize(Video meta, string channelAvatar) public void Initialize(Video meta, string channelAvatar, bool privateMode = false)
{ {
Visibility = Visibility.Collapsed; Visibility = Visibility.Collapsed;
item = meta; item = meta;
avatar = channelAvatar; avatar = channelAvatar;
videoId = item.Id; videoId = item.Id;
incognito = privateMode;
if (item.ContentDetails.ContentRating != null) if (item.ContentDetails.ContentRating != null)
{ {
@@ -111,6 +115,10 @@ namespace FoxTube
else else
LoadUpcoming(); LoadUpcoming();
if (!incognito)
Debug.WriteLine("TODO: history entry creation");
// TODO: Create history entry
Visibility = Visibility.Visible; Visibility = Visibility.Visible;
} }
@@ -174,8 +182,10 @@ namespace FoxTube
title.Text = item.Snippet.Title; title.Text = item.Snippet.Title;
channelName.Text = item.Snippet.ChannelTitle; channelName.Text = item.Snippet.ChannelTitle;
ctrlsFadeTimer = new DispatcherTimer(); ctrlsFadeTimer = new DispatcherTimer
ctrlsFadeTimer.Interval = TimeSpan.FromSeconds(5); {
Interval = TimeSpan.FromSeconds(5)
};
ctrlsFadeTimer.Tick += ControlsFade; ctrlsFadeTimer.Tick += ControlsFade;
} }
@@ -334,7 +344,8 @@ namespace FoxTube
if (seekCaptured) if (seekCaptured)
return; return;
controls.Visibility = Visibility.Collapsed; controls.Opacity = 0;
//controls.Visibility = Visibility.Collapsed;
if (layout != PlayerLayout.Minimized) if (layout != PlayerLayout.Minimized)
touchCentral.Visibility = Visibility.Collapsed; touchCentral.Visibility = Visibility.Collapsed;
if (pointerCaptured) if (pointerCaptured)
@@ -354,7 +365,8 @@ namespace FoxTube
if (ctrlsFadeTimer == null) if (ctrlsFadeTimer == null)
return; return;
controls.Visibility = Visibility.Visible; controls.Opacity = 1;
//controls.Visibility = Visibility.Visible;
Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 0); Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 0);
ctrlsFadeTimer.Start(); ctrlsFadeTimer.Start();
} }
@@ -473,9 +485,11 @@ namespace FoxTube
{ {
if (audioPlayer == null) if (audioPlayer == null)
{ {
audioPlayer = new MediaPlayer(); audioPlayer = new MediaPlayer
audioPlayer.TimelineController = controller; {
audioPlayer.Volume = volume.Value * .01; TimelineController = controller,
Volume = volume.Value * .01
};
audioSource.SetMediaPlayer(audioPlayer); audioSource.SetMediaPlayer(audioPlayer);
} }
+4 -1
View File
@@ -12,7 +12,7 @@
<DefaultLanguage>en-US</DefaultLanguage> <DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion> <TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion> <TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@@ -420,6 +420,9 @@
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls"> <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>5.0.0</Version> <Version>5.0.0</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.0.181018003.1</Version>
</PackageReference>
<PackageReference Include="runtime.win10-arm64.runtime.native.System.IO.Compression"> <PackageReference Include="runtime.win10-arm64.runtime.native.System.IO.Compression">
<Version>4.3.2</Version> <Version>4.3.2</Version>
</PackageReference> </PackageReference>
+2 -1
View File
@@ -18,7 +18,8 @@
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<AutoSuggestBox Grid.ColumnSpan="2" Text="https://youtube.com/" QueryIcon="Forward" QuerySubmitted="Adress_QuerySubmitted" Name="adress"/> <AutoSuggestBox Grid.ColumnSpan="2" Text="https://youtube.com/" QueryIcon="Forward" QuerySubmitted="Adress_QuerySubmitted" Name="adress" Margin="60,0,0,0"/>
<Button Content="POST" Click="Button_Click"/>
<ScrollViewer Grid.Row="1"> <ScrollViewer Grid.Row="1">
<TextBlock TextWrapping="Wrap" Name="code" IsTextSelectionEnabled="True"/> <TextBlock TextWrapping="Wrap" Name="code" IsTextSelectionEnabled="True"/>
</ScrollViewer> </ScrollViewer>
+10 -2
View File
@@ -34,8 +34,7 @@ namespace FoxTube.Pages
public async void Initialize() public async void Initialize()
{ {
HttpClient client = new HttpClient(); SecretsVault.HttpClient.DefaultRequestHeaders.Referrer = "https://youtube.com/".ToUri();
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", SecretsVault.Credential.Token.AccessToken);
string response = await SecretsVault.Service.HttpClient.GetStringAsync(adress.Text); string response = await SecretsVault.Service.HttpClient.GetStringAsync(adress.Text);
code.Text = response; code.Text = response;
view.NavigateToString(response); view.NavigateToString(response);
@@ -45,5 +44,14 @@ namespace FoxTube.Pages
{ {
Initialize(); Initialize();
} }
private async void Button_Click(object sender, RoutedEventArgs e)
{
/*HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", SecretsVault.Credential.Token.AccessToken);
//string response = await SecretsVault.Service.HttpClient.Po(adress.Text);
code.Text = response;
view.NavigateToString(response);*/
}
} }
} }
+2 -4
View File
@@ -72,8 +72,6 @@ namespace FoxTube.Pages
try try
{ {
channelId = id; channelId = id;
if (Methods.NeedToResponse)
Methods.MainPage.Content_Navigated(this, null);
ChannelsResource.ListRequest request = SecretsVault.Service.Channels.List("snippet,statistics,brandingSettings"); ChannelsResource.ListRequest request = SecretsVault.Service.Channels.List("snippet,statistics,brandingSettings");
request.Id = id; request.Id = id;
@@ -104,7 +102,7 @@ namespace FoxTube.Pages
videoRequest.ChannelId = id; videoRequest.ChannelId = id;
videoRequest.Type = "video"; videoRequest.Type = "video";
videoRequest.Order = SearchResource.ListRequest.OrderEnum.Date; videoRequest.Order = SearchResource.ListRequest.OrderEnum.Date;
videoRequest.MaxResults = 48; videoRequest.MaxResults = 25;
SearchListResponse response = await videoRequest.ExecuteAsync(); SearchListResponse response = await videoRequest.ExecuteAsync();
@@ -159,7 +157,7 @@ namespace FoxTube.Pages
playlistRequest.ChannelId = channelId; playlistRequest.ChannelId = channelId;
playlistRequest.Order = SearchResource.ListRequest.OrderEnum.Date; playlistRequest.Order = SearchResource.ListRequest.OrderEnum.Date;
playlistRequest.Type = "playlist"; playlistRequest.Type = "playlist";
playlistRequest.MaxResults = 48; playlistRequest.MaxResults = 25;
SearchListResponse response = await playlistRequest.ExecuteAsync(); SearchListResponse response = await playlistRequest.ExecuteAsync();
+6 -4
View File
@@ -34,6 +34,8 @@ namespace FoxTube.Pages
list = stack.Children[0] as VideoGrid; list = stack.Children[0] as VideoGrid;
more = stack.Children[1] as ShowMore; more = stack.Children[1] as ShowMore;
loading.RefreshPage += Refresh_Click;
if (!string.IsNullOrWhiteSpace(e.Parameter.ToString())) if (!string.IsNullOrWhiteSpace(e.Parameter.ToString()))
id = e.Parameter.ToString(); id = e.Parameter.ToString();
@@ -46,13 +48,13 @@ namespace FoxTube.Pages
{ {
loading.Refresh(); loading.Refresh();
entries = id == "HL" ? await Methods.GetHistory() : await Methods.GetLater(); entries = id == "HL" ? SecretsVault.History = await Methods.GetHistory() : SecretsVault.WatchLater = await Methods.GetLater();
for (int k = 0; k < 50 && k < entries.Count; k++) for (int k = 0; k < 25 && k < entries.Count; k++)
list.Add(new VideoCard(entries[k])); list.Add(new VideoCard(entries[k]));
if (list.Count >= entries.Count) if (list.Count >= entries.Count)
more.Complete(true); more.Visibility = Visibility.Collapsed;
loading.Close(); loading.Close();
} }
@@ -85,7 +87,7 @@ namespace FoxTube.Pages
private void ShowMore_Clicked() private void ShowMore_Clicked()
{ {
for (int k = 50 * page++; k < 50 * page; k++) for (int k = 25 * page++; k < 25 * page; k++)
list.Add(new VideoCard(entries[k])); list.Add(new VideoCard(entries[k]));
if (list.Count >= entries.Count) if (list.Count >= entries.Count)
+4 -1
View File
@@ -18,7 +18,10 @@
<Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged"> <Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged">
<PivotItem x:Uid="/Home/recommended" Header="Recommended" Name="recommended"> <PivotItem x:Uid="/Home/recommended" Header="Recommended" Name="recommended">
<ScrollViewer> <ScrollViewer>
<StackPanel/> <StackPanel>
<pages:VideoGrid/>
<controls:ShowMore Clicked="RecMore_Clicked"/>
</StackPanel>
</ScrollViewer> </ScrollViewer>
</PivotItem> </PivotItem>
<PivotItem x:Uid="/Home/trending" Header="Trending" Name="trending"> <PivotItem x:Uid="/Home/trending" Header="Trending" Name="trending">
+37 -14
View File
@@ -6,6 +6,9 @@ using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using FoxTube.Controls; using FoxTube.Controls;
using FoxTube.Pages; using FoxTube.Pages;
using System.Net.Http;
using System.Xml;
using System.Text.RegularExpressions;
namespace FoxTube namespace FoxTube
{ {
@@ -15,14 +18,14 @@ namespace FoxTube
public sealed partial class Home : Page public sealed partial class Home : Page
{ {
// TODO: Refactor home page // TODO: Refactor home page
private bool trendLoaded = false; private bool trendLoaded = false, recLoaded = false;
VideoGrid trendGrid; VideoGrid trendGrid, recGrid;
ShowMore trendMore; ShowMore trendMore, recMore;
LoadingPage loading; LoadingPage loading;
string trendToken; string trendToken;
Dictionary<string, string> subsTokens = new Dictionary<string, string>(); List<string> homeList = new List<string>();
public Home() public Home()
{ {
@@ -31,6 +34,9 @@ namespace FoxTube
trendGrid = ((trending.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid; trendGrid = ((trending.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
trendMore = ((trending.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore; trendMore = ((trending.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
recGrid = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
recMore = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
loading = grid.Children[2] as LoadingPage; loading = grid.Children[2] as LoadingPage;
Initialize(); Initialize();
@@ -73,9 +79,9 @@ namespace FoxTube
public void Initialize() public void Initialize()
{ {
/*if(SecretsVault.IsAuthorized) if(SecretsVault.IsAuthorized)
LoadRecommendations(); LoadRecommendations();
else*/ else
{ {
pivot.Items.Remove(recommended); pivot.Items.Remove(recommended);
pivot.Items.Remove(subscriptions); pivot.Items.Remove(subscriptions);
@@ -87,7 +93,7 @@ namespace FoxTube
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
loading.Close(); loading.Close();
if (pivot.SelectedItem == recommended) if (pivot.SelectedItem == recommended && !recLoaded)
LoadRecommendations(); LoadRecommendations();
else if (pivot.SelectedItem == trending && !trendLoaded) else if (pivot.SelectedItem == trending && !trendLoaded)
LoadTrending(); LoadTrending();
@@ -101,7 +107,7 @@ namespace FoxTube
{ {
loading.Refresh(); loading.Refresh();
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id"); VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
request.MaxResults = 48; request.MaxResults = 25;
request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular; request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
request.RegionCode = SettingsStorage.Region; request.RegionCode = SettingsStorage.Region;
@@ -121,7 +127,7 @@ namespace FoxTube
loading.Close(); loading.Close();
trendLoaded = true; trendLoaded = true;
} }
catch (System.Net.Http.HttpRequestException) catch (HttpRequestException)
{ {
trendLoaded = false; trendLoaded = false;
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
@@ -133,14 +139,26 @@ namespace FoxTube
} }
} }
void LoadRecommendations() async void LoadRecommendations()
{ {
try try
{ {
loading.Refresh(); loading.Refresh();
throw new NotImplementedException("This page has not implemented yet."); //throw new NotImplementedException("This page has not implemented yet.");
HttpResponseMessage r = await SecretsVault.HttpClient.GetAsync("https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=WL");
string response = await SecretsVault.HttpClient.GetStringAsync("https://youtube.com/");
foreach (Match match in Regex.Matches(response, @"\bdata-context-item-id=(\S*)\b", RegexOptions.IgnoreCase))
homeList.Add(match.Value.Split('"')[1]);
for (int k = 0; k < 25 && k < homeList.Count; k++)
recGrid.Add(new VideoCard(homeList[k]));
loading.Close();
recLoaded = true;
} }
catch (System.Net.Http.HttpRequestException) catch (HttpRequestException)
{ {
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
@@ -155,9 +173,9 @@ namespace FoxTube
try try
{ {
loading.Refresh(); loading.Refresh();
throw new NotImplementedException("This page has not implemented yet."); throw new NotImplementedException("This page isn't not implemented yet.");
} }
catch (System.Net.Http.HttpRequestException) catch (HttpRequestException)
{ {
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
@@ -166,5 +184,10 @@ namespace FoxTube
loading.Error(e.GetType().ToString(), e.Message); loading.Error(e.GetType().ToString(), e.Message);
} }
} }
private void RecMore_Clicked()
{
}
} }
} }
+1
View File
@@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Windows10version1809="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+44 -7
View File
@@ -3,14 +3,42 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Windows10version1809="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)"
xmlns:Windows10version1803="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 6)" xmlns:Windows10version1803="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 6)"
mc:Ignorable="d" mc:Ignorable="d"
SizeChanged="Page_SizeChanged" SizeChanged="Page_SizeChanged"
PreviewKeyUp="Page_PreviewKeyUp"> PreviewKeyUp="Page_PreviewKeyUp">
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<NavigationView Header="Home" SelectedItem="toHome" Windows10version1803:BackRequested="Nav_BackRequested" Windows10version1803:PaneTitle="FoxTube" OpenPaneLength="300" Name="nav" SelectionChanged="Nav_SelectionChanged"> <Windows10version1809:Grid.BackgroundTransition>
<BrushTransition/>
</Windows10version1809:Grid.BackgroundTransition>
<Border x:Name="AppTitleBar"
IsHitTestVisible="True"
VerticalAlignment="Top"
Background="Transparent"
Canvas.ZIndex="1"
Margin="12, 8">
<TextBlock x:Name="AppTitle"
Text="FoxTube"
VerticalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}" />
</Border>
<NavigationView Header="History" SelectedItem="toHome" Windows10version1803:BackRequested="Nav_BackRequested" Windows10version1803:PaneClosing="Nav_PaneChanged" Windows10version1803:PaneOpening="Nav_PaneChanged" Windows10version1803:PaneTitle="FoxTube" OpenPaneLength="300" Name="nav" SelectionChanged="Nav_SelectionChanged">
<NavigationView.MenuItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Padding="5" Margin="-5,0,0,0" Tag="{Binding Snippet.ResourceId.ChannelId}">
<PersonPicture Height="20" ProfilePicture="{Binding Snippet.Thumbnails.Medium.Url}" Margin="-5,0,15,0"/>
<TextBlock Text="{Binding Snippet.Title}"/>
</StackPanel>
</DataTemplate>
</NavigationView.MenuItemTemplate>
<NavigationView.MenuItems> <NavigationView.MenuItems>
<NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/> <NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/>
@@ -30,7 +58,7 @@
<NavigationView.PaneFooter> <NavigationView.PaneFooter>
<NavigationViewList> <NavigationViewList>
<NavigationViewItem Name="openWeb" Tapped="Web_Tapped" Icon="Globe" Content="Browser" Visibility="Collapsed"/> <NavigationViewItem Name="openWeb" Tapped="Web_Tapped" Icon="Globe" Content="Browser" Visibility="Visible"/>
<NavigationViewItem x:Uid="/Main/feedback" Name="feedback" Content="Give a feedback" Tapped="Feedback_Click"> <NavigationViewItem x:Uid="/Main/feedback" Name="feedback" Content="Give a feedback" Tapped="Feedback_Click">
<NavigationViewItem.Icon> <NavigationViewItem.Icon>
<FontIcon Glyph="&#xED15;"/> <FontIcon Glyph="&#xED15;"/>
@@ -64,11 +92,20 @@
</StackPanel> </StackPanel>
<NavigationViewItem.ContextFlyout> <NavigationViewItem.ContextFlyout>
<MenuFlyout> <Flyout>
<MenuFlyoutItem x:Uid="/Main/myChannelContext" Text="My channel" Name="myChannel" Click="MyChannel_Click"/> <Grid>
<MenuFlyoutSeparator/> <Grid.ColumnDefinitions>
<MenuFlyoutItem x:Uid="/Main/signOut" Text="Log out" Name="logout" Click="Logout_Click"/> <ColumnDefinition Width="auto"/>
</MenuFlyout> <ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Width="50" Name="avatarFlyout" VerticalAlignment="Top"/>
<StackPanel Grid.Column="1" Margin="5">
<TextBlock Name="myNameFlyout"/>
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" Name="myEmail"/>
<HyperlinkButton x:Uid="/Main/signOut" Content="Log out" Click="Logout_Click"/>
</StackPanel>
</Grid>
</Flyout>
</NavigationViewItem.ContextFlyout> </NavigationViewItem.ContextFlyout>
</NavigationViewItem> </NavigationViewItem>
</NavigationViewList> </NavigationViewList>
+175 -358
View File
@@ -37,11 +37,11 @@ namespace FoxTube
// TODO: Refactor main page // TODO: Refactor main page
Sender s = Sender.None; Sender s = Sender.None;
readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Main"); readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Main");
Dictionary<Type, Action> headers;
public MainPage() public MainPage()
{ {
InitializeComponent(); InitializeComponent();
SetTitleBar();
CheckVersion();
SecretsVault.AuthorizationStateChanged += AuthorizationStateChanged; SecretsVault.AuthorizationStateChanged += AuthorizationStateChanged;
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged; SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
@@ -50,36 +50,25 @@ namespace FoxTube
removeAds.Visibility = (e[0] as bool?).Value ? Visibility.Collapsed : Visibility.Visible; removeAds.Visibility = (e[0] as bool?).Value ? Visibility.Collapsed : Visibility.Visible;
content.Navigate(typeof(Home)); content.Navigate(typeof(Home));
}; };
SecretsVault.CheckAuthorization(); SecretsVault.Initialize();
SecretsVault.CheckAddons();
SetTitleBar(); headers = new Dictionary<Type, Action>()
}
/// <summary>
/// Comparing current version with last recorded version. If doesn't match, poping up changelog notification
/// </summary>
public async void CheckVersion()
{ {
PackageVersion ver = Package.Current.Id.Version; { typeof(Settings), () => nav.Header = resources.GetString("/Main/settings/Content") },
if (SettingsStorage.Version != $"{ver.Major}.{ver.Minor}") { typeof(ChannelPage), () => nav.Header = resources.GetString("/Main/channel") },
{ typeof(PlaylistPage), () => nav.Header = resources.GetString("/Main/playlist") },
{ typeof(Search), () => nav.Header = resources.GetString("/Main/searchPlaceholder/PlaceholderText") },
{ typeof(Subscriptions), () => nav.Header = resources.GetString("/Main/subscriptions/Content") },
{ typeof(History), () =>
{ {
try if((content.Content as History).id == "HL")
{ nav.Header = resources.GetString("/Main/history/Content");
XmlDocument changelog = new XmlDocument(); else
StorageFile file = await (await Package.Current.InstalledLocation.GetFolderAsync(@"Assets\Data")).GetFileAsync("Patchnotes.xml"); nav.Header = resources.GetString("/Main/later/Content");
changelog.Load(await file.OpenStreamForReadAsync()); } },
XmlElement e = changelog["items"].ChildNodes[0] as XmlElement; { typeof(Home), () => nav.Header = resources.GetString("/Main/home/Content") },
{ typeof(Downloads), () => nav.Header = resources.GetString("/Main/downloads/Content") }
ToastNotificationManager.CreateToastNotifier().Show(FoxTube.Background.Notification.GetChangelogToast(e.GetAttribute("version"))); };
SettingsStorage.Version = $"{ver.Major}.{ver.Minor}";
}
catch
{
Debug.WriteLine("Unable to retrieve changelog");
}
}
} }
public Video GetCurrentItem() public Video GetCurrentItem()
@@ -98,87 +87,59 @@ namespace FoxTube
{ {
var titleBar = ApplicationView.GetForCurrentView().TitleBar; var titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.BackgroundColor = Colors.Red; titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonBackgroundColor = Colors.Red;
titleBar.ButtonHoverBackgroundColor = Colors.IndianRed; titleBar.ButtonHoverBackgroundColor = Colors.IndianRed;
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed; titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
titleBar.ButtonInactiveBackgroundColor = Colors.Black; titleBar.ButtonInactiveBackgroundColor = Colors.Gray;
titleBar.ForegroundColor = Colors.White;
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false; if(Application.Current.RequestedTheme == ApplicationTheme.Dark)
titleBar.ForegroundColor = Colors.White;
else
titleBar.ForegroundColor = Colors.Black;
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
} }
/// <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) private void SecretsVault_SubscriptionsChanged(object sender, params object[] args)
{ {
if ((string)args[0] == "add" && nav.MenuItems.Count < 19) switch(args[0] as string)
{ {
subsHeader.Visibility = Visibility.Visible; case "add":
if (nav.MenuItems.Count >= 19)
nav.MenuItems.Add(args[1] as Subscription);
break;
Subscription s = args[1] as Subscription; case "remove":
StackPanel panel = new StackPanel() NavigationViewItem item = nav.MenuItems.Find(i => ((i as NavigationViewItem).Content as StackPanel).Tag.ToString() == (args[1] as Subscription).Snippet.ResourceId.ChannelId) as NavigationViewItem;
{ if (item == null)
Orientation = Orientation.Horizontal, break;
Padding = new Thickness(5) else
}; nav.MenuItems.Remove(item);
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)
});
}
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)
});
}
}
}
if (SecretsVault.Subscriptions.Count >= 10)
nav.MenuItems.Add(SecretsVault.Subscriptions[9]);
break;
}
}
private async void AuthorizationStateChanged(object sender, params object[] e) private async void AuthorizationStateChanged(object sender, params object[] e)
{ {
if(e[0] as bool? == true) switch(e[0] as bool?)
{ {
case true:
account.Visibility = Visibility.Collapsed; account.Visibility = Visibility.Collapsed;
try try
{ {
Userinfoplus info = await new Oauth2Service(SecretsVault.Initializer).Userinfo.Get().ExecuteAsync(); Userinfoplus info = await new Oauth2Service(SecretsVault.Initializer).Userinfo.Get().ExecuteAsync();
myName.Text = info.Name; myName.Text = myNameFlyout.Text = info.Name;
((avatar.Content as StackPanel).Children[0] as PersonPicture).ProfilePicture = new BitmapImage(new Uri(info.Picture)); if (string.IsNullOrWhiteSpace(info.Email))
myEmail.Visibility = Visibility.Collapsed;
else
myEmail.Text = info.Email;
avatarFlyout.ProfilePicture = new BitmapImage(info.Picture.ToUri());
((avatar.Content as StackPanel).Children[0] as PersonPicture).ProfilePicture = avatarFlyout.ProfilePicture;
} }
catch { } catch { }
avatar.Visibility = Visibility.Visible; avatar.Visibility = Visibility.Visible;
@@ -193,34 +154,11 @@ namespace FoxTube
if (SecretsVault.Subscriptions.Count > 0) if (SecretsVault.Subscriptions.Count > 0)
{ {
subsHeader.Visibility = Visibility.Visible; subsHeader.Visibility = Visibility.Visible;
for(int k = 0; k < SecretsVault.Subscriptions.Count && k < 10; k++) for (int k = 0; k < SecretsVault.Subscriptions.Count && k < 10; k++)
try nav.MenuItems.Add(SecretsVault.Subscriptions[k]);
{
Subscription s = SecretsVault.Subscriptions[k];
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 = k.ToString(),
Padding = new Thickness(-5)
});
} }
catch { continue; } break;
} case false:
}
else if (e[0] as bool? == false)
{
for (int k = nav.MenuItems.Count - 1; k > 8; k--) for (int k = nav.MenuItems.Count - 1; k > 8; k--)
nav.MenuItems.RemoveAt(k); nav.MenuItems.RemoveAt(k);
@@ -236,9 +174,8 @@ namespace FoxTube
subsHeader.Visibility = Visibility.Collapsed; subsHeader.Visibility = Visibility.Collapsed;
subsHeader.Visibility = Visibility.Collapsed; subsHeader.Visibility = Visibility.Collapsed;
} break;
else default:
{
MessageDialog dialog = new MessageDialog(resources.GetString("/Main/connectErrContent"), resources.GetString("/Main/connectErrHeader")); MessageDialog dialog = new MessageDialog(resources.GetString("/Main/connectErrContent"), resources.GetString("/Main/connectErrHeader"));
dialog.Commands.Add(new UICommand(resources.GetString("/Main/tryAgain"), (command) => dialog.Commands.Add(new UICommand(resources.GetString("/Main/tryAgain"), (command) =>
@@ -254,6 +191,7 @@ namespace FoxTube
dialog.DefaultCommandIndex = 0; dialog.DefaultCommandIndex = 0;
await dialog.ShowAsync(); await dialog.ShowAsync();
break;
} }
if(e[0] as bool? != null) if(e[0] as bool? != null)
@@ -262,7 +200,7 @@ namespace FoxTube
content.Navigate(typeof(Home)); content.Navigate(typeof(Home));
if (videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
GoToVideo((videoPlaceholder.Content as VideoPage).videoId); GoToVideo((videoPlaceholder.Content as VideoPage).videoId, (videoPlaceholder.Content as VideoPage).playlistId);
} }
private async void Feedback_Click(object sender, TappedRoutedEventArgs e) private async void Feedback_Click(object sender, TappedRoutedEventArgs e)
@@ -280,11 +218,6 @@ namespace FoxTube
SecretsVault.Authorize(); SecretsVault.Authorize();
} }
private void MyChannel_Click(object sender, RoutedEventArgs e)
{
GoToChannel(SecretsVault.AccountId);
}
private void Logout_Click(object sender, RoutedEventArgs e) private void Logout_Click(object sender, RoutedEventArgs e)
{ {
SecretsVault.Deauthenticate(); SecretsVault.Deauthenticate();
@@ -308,11 +241,12 @@ namespace FoxTube
public async void GoToVideo(string id, string playlistId = null) public async void GoToVideo(string id, string playlistId = null)
{ {
bool cancel = false; if (SettingsStorage.CheckConnection)
try try
{ {
var connection = NetworkInformation.GetInternetConnectionProfile().GetConnectionCost(); bool cancel = false;
if (SettingsStorage.CheckConnection && (connection.NetworkCostType == NetworkCostType.Fixed || connection.NetworkCostType == NetworkCostType.Variable)) ConnectionCost connection = NetworkInformation.GetInternetConnectionProfile().GetConnectionCost();
if (connection.NetworkCostType == NetworkCostType.Fixed || connection.NetworkCostType == NetworkCostType.Variable)
{ {
MessageDialog dialog = new MessageDialog(resources.GetString("/Main/metered")) MessageDialog dialog = new MessageDialog(resources.GetString("/Main/metered"))
{ {
@@ -321,7 +255,7 @@ namespace FoxTube
}; };
dialog.Commands.Add(new UICommand(resources.GetString("/Main/yes"))); dialog.Commands.Add(new UICommand(resources.GetString("/Main/yes")));
dialog.Commands.Add(new UICommand(resources.GetString("/Main/no"), (command) => cancel = true)); dialog.Commands.Add(new UICommand(resources.GetString("/Main/no"), (command) => cancel = true));
if(SecretsVault.IsAuthorized) if (SecretsVault.IsAuthorized)
dialog.Commands.Add(new UICommand(resources.GetString("/Main/addLater"), (command) => dialog.Commands.Add(new UICommand(resources.GetString("/Main/addLater"), (command) =>
{ {
try try
@@ -349,20 +283,20 @@ namespace FoxTube
})); }));
await dialog.ShowAsync(); await dialog.ShowAsync();
if (cancel)
return;
} }
} }
catch { } catch { }
if (cancel)
return;
if (videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
(videoPlaceholder.Content as VideoPage).player.close_Click(this, null); (videoPlaceholder.Content as VideoPage).player.close_Click(this, null);
videoPlaceholder.Content = null; nav.ExpandedModeThresholdWidth = short.MaxValue;
Fullscreen(false); nav.IsPaneOpen = false;
videoPlaceholder.Navigate(typeof(VideoPage), new string[2] { id, playlistId }); videoPlaceholder.Navigate(typeof(VideoPage), new string[2] { id, playlistId });
MaximizeVideo();
} }
public void GoToDeveloper(string id) public void GoToDeveloper(string id)
@@ -388,16 +322,13 @@ namespace FoxTube
public void MinimizeAsInitializer() public void MinimizeAsInitializer()
{ {
if(videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
{ return;
if ((videoPlaceholder.Content as VideoPage).loading.State != LoadingState.Loaded) if ((videoPlaceholder.Content as VideoPage).loading.State != LoadingState.Loaded)
CloseVideo(); CloseVideo();
else else
{ Methods.Try(() => (videoPlaceholder.Content as VideoPage).player.minimize_Click(this, null));
try { (videoPlaceholder.Content as VideoPage).player.minimize_Click(this, null); }
catch { }
}
}
} }
public void MinimizeVideo() public void MinimizeVideo()
@@ -413,18 +344,13 @@ namespace FoxTube
else else
nav.IsBackEnabled = false; nav.IsBackEnabled = false;
Dictionary<Type, Action> switchCase = new Dictionary<Type, Action>() SetNavigationMenu();
{
{ typeof(Settings), () => nav.Header = resources.GetString("/Main/settings/Content") },
{ typeof(ChannelPage), () => nav.Header = resources.GetString("/Main/channel") },
{ typeof(PlaylistPage), () => nav.Header = resources.GetString("/Main/playlist") },
{ typeof(Search), () => nav.Header = resources.GetString("/Main/searchPlaceholder/PlaceholderText") },
{ typeof(Subscriptions), () => nav.Header = resources.GetString("/Main/subscriptions/Content") },
{ typeof(History), () => nav.Header = resources.GetString("/Main/history/Content") },
{ typeof(Home), () => nav.Header = resources.GetString("/Main/home/Content") },
{ typeof(Downloads), () => nav.Header = resources.GetString("/Main/downloads/Content") }
};
Methods.Try(headers[content.SourcePageType]);
}
void SetNavigationMenu()
{
if (content.SourcePageType == typeof(Home) || content.SourcePageType == typeof(Settings) || content.SourcePageType == typeof(Subscriptions)) if (content.SourcePageType == typeof(Home) || content.SourcePageType == typeof(Settings) || content.SourcePageType == typeof(Subscriptions))
{ {
nav.ExpandedModeThresholdWidth = 1008; nav.ExpandedModeThresholdWidth = 1008;
@@ -433,9 +359,6 @@ namespace FoxTube
} }
else else
nav.ExpandedModeThresholdWidth = short.MaxValue; nav.ExpandedModeThresholdWidth = short.MaxValue;
try { switchCase[content.SourcePageType](); }
catch { }
} }
public void MaximizeVideo() public void MaximizeVideo()
@@ -446,15 +369,14 @@ namespace FoxTube
videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch; videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch;
videoPlaceholder.Margin = new Thickness(0); videoPlaceholder.Margin = new Thickness(0);
nav.IsBackEnabled = true;
if (videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
{ return;
nav.IsBackEnabled = true;
nav.Header = resources.GetString("/Main/video"); nav.Header = resources.GetString("/Main/video");
nav.ExpandedModeThresholdWidth = short.MaxValue; nav.ExpandedModeThresholdWidth = short.MaxValue;
nav.IsPaneOpen = false; nav.IsPaneOpen = false;
} }
}
public void Fullscreen(bool on) public void Fullscreen(bool on)
{ {
@@ -462,37 +384,23 @@ namespace FoxTube
{ {
nav.CompactModeThresholdWidth = short.MaxValue; nav.CompactModeThresholdWidth = short.MaxValue;
nav.ExpandedModeThresholdWidth = short.MaxValue; nav.ExpandedModeThresholdWidth = short.MaxValue;
try try { nav.IsPaneVisible = false; }
{ catch { nav.CompactPaneLength = 0; }
nav.IsPaneVisible = false;
}
catch
{
nav.CompactPaneLength = 0;
nav.OpenPaneLength = 0;
}
nav.Margin = new Thickness(0, -45, 0, 0); nav.Margin = new Thickness(0, -45, 0, 0);
} }
else else
{ {
nav.CompactModeThresholdWidth = 641; nav.CompactModeThresholdWidth = 641;
if(videoPlaceholder.Content == null) if (videoPlaceholder.Content == null)
nav.ExpandedModeThresholdWidth = 1008; SetNavigationMenu();
try { nav.IsPaneVisible = true; }
catch { nav.CompactPaneLength = new NavigationView().CompactPaneLength; }
nav.Margin = new Thickness(0); nav.Margin = new Thickness(0);
try
{
nav.IsPaneVisible = true;
}
catch
{
nav.CompactPaneLength = new NavigationView().CompactPaneLength;
nav.OpenPaneLength = new NavigationView().OpenPaneLength; ;
}
if (videoPlaceholder.Content != null && nav.IsPaneOpen) if (videoPlaceholder.Content != null && nav.IsPaneOpen)
nav.IsPaneOpen = false; nav.IsPaneOpen = false;
SetTitleBar();
} }
nav.UpdateLayout();
} }
public void CloseVideo() public void CloseVideo()
@@ -535,43 +443,16 @@ namespace FoxTube
search.ItemsSource = suggestions; search.ItemsSource = suggestions;
} }
catch (WebException) catch { search.ItemsSource = new List<string>(); }
{
search.ItemsSource = new List<string>();
}
} }
} }
private void Nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) void SetNavigationItem(object item)
{ {
Debug.WriteLine("Menu selection changed");
try try
{ {
if (s == Sender.None) if (nav.SelectedItem != item)
{ nav.SelectedItem = item;
s = Sender.Menu;
if (args.IsSettingsSelected)
content.Navigate(typeof(Settings));
else
{
if (args.SelectedItem == toHome)
content.Navigate(typeof(Home));
else if (args.SelectedItem == toHistory)
content.Navigate(typeof(History), "HL");
else if (args.SelectedItem == toLiked)
content.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes);
else if (args.SelectedItem == toLater)
content.Navigate(typeof(History), "WL");
else if (args.SelectedItem == toSubscriptions)
content.Navigate(typeof(Subscriptions));
else if (args.SelectedItem == toDownloads)
content.Navigate(typeof(Downloads));
else if (args.SelectedItem == toChannel)
content.Navigate(typeof(ChannelPage), SecretsVault.UserChannel.Id);
else
content.Navigate(typeof(ChannelPage), SecretsVault.Subscriptions[Convert.ToInt32((args.SelectedItem as NavigationViewItem).Name)].Snippet.ResourceId.ChannelId);
}
}
else else
s = Sender.None; s = Sender.None;
} }
@@ -580,145 +461,48 @@ namespace FoxTube
public void Content_Navigated(object sender, NavigationEventArgs e) public void Content_Navigated(object sender, NavigationEventArgs e)
{ {
Dictionary<Type, Action> switchCase = new Dictionary<Type, Action>() Methods.Try(headers[e.SourcePageType]);
{
{ typeof(Settings), () => nav.Header = resources.GetString("/Main/settings/Content") },
{ typeof(ChannelPage), () => nav.Header = resources.GetString("/Main/channel") },
{ typeof(PlaylistPage), () => nav.Header = resources.GetString("/Main/playlist") },
{ typeof(Search), () => nav.Header = resources.GetString("/Main/searchPlaceholder/PlaceholderText") },
{ typeof(Subscriptions), () => nav.Header = resources.GetString("/Main/subscriptions/Content") },
{ typeof(History), () =>
{
if((content.Content as History).id == "HL")
nav.Header = resources.GetString("/Main/history/Content");
else
nav.Header = resources.GetString("/Main/later/Content");
} },
{ typeof(Home), () => nav.Header = resources.GetString("/Main/home/Content") },
{ typeof(Downloads), () => nav.Header = resources.GetString("/Main/downloads/Content") }
};
try { switchCase[e.SourcePageType](); }
catch { }
if (s == Sender.None) if (s == Sender.None)
{ {
s = Sender.Frame; s = Sender.Frame;
Dictionary<Type, Action> navCase = new Dictionary<Type, Action>() if (e.SourcePageType == typeof(Settings))
SetNavigationItem(nav.SettingsItem);
else if (e.SourcePageType == typeof(Subscriptions))
SetNavigationItem(toSubscriptions);
else if (e.SourcePageType == typeof(Downloads))
SetNavigationItem(toDownloads);
else if (e.SourcePageType == typeof(Home))
SetNavigationItem(toHome);
else if (e.SourcePageType == typeof(Search))
SetNavigationItem(null);
else if(e.SourcePageType == typeof(ChannelPage) && SecretsVault.IsAuthorized)
{ {
{ typeof(Settings), () => if (e.Parameter.ToString() == SecretsVault.AccountId)
{ SetNavigationItem(toChannel);
if(nav.SelectedItem != nav.SettingsItem) else if (nav.MenuItems.Contains(SecretsVault.Subscriptions.Find(i => i.Snippet.ResourceId.ChannelId == e.Parameter.ToString())))
nav.SelectedItem = nav.SettingsItem; SetNavigationItem(SecretsVault.Subscriptions.Find(i => i.Snippet.ResourceId.ChannelId == e.Parameter.ToString()));
else else
s = Sender.None; SetNavigationItem(null);
} },
{ typeof(ChannelPage), () =>
{
if(sender.GetType() != typeof(ChannelPage))
{
Methods.NeedToResponse = true;
s = Sender.None;
return;
} }
Methods.NeedToResponse = false; else if(e.SourcePageType == typeof(History))
if(SecretsVault.IsAuthorized)
{ {
if((content.Content as ChannelPage).channelId == SecretsVault.UserChannel.Id) if (e.Parameter.ToString() == "HL")
{ {
if(nav.SelectedItem != toChannel) SetNavigationItem(toHistory);
nav.SelectedItem = toChannel; nav.Header = resources.GetString("/Main/history/Content");
else
s = Sender.None;
} }
else else
{ {
bool found = false; SetNavigationItem(toLater);
for(int k = 0; k < SecretsVault.Subscriptions.Count && k < 10; k++) nav.Header = resources.GetString("/Main/later/Content");
if(SecretsVault.Subscriptions[k].Snippet.ResourceId.ChannelId == (content.Content as ChannelPage).channelId)
{
if(nav.SelectedItem != nav.MenuItems[k + 9])
nav.SelectedItem = nav.MenuItems[k + 9];
else
s = Sender.None;
found = true;
break;
}
if(!found)
nav.SelectedItem = null;
} }
} }
else else if(e.SourcePageType == typeof(PlaylistPage))
nav.SelectedItem = null;
} },
{ typeof(PlaylistPage), () =>
{ {
if(sender.GetType() != typeof(PlaylistPage)) if (e.Parameter.ToString() == SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes)
{ SetNavigationItem(toLiked);
Methods.NeedToResponse = true;
s = Sender.None;
return;
}
Methods.NeedToResponse = false;
if((content.Content as PlaylistPage).playlistId == SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes)
{
if(nav.SelectedItem != toLiked)
nav.SelectedItem = toLiked;
else
s = Sender.None;
}
else
nav.SelectedItem = null;
} },
{ typeof(Search), () => nav.SelectedItem = null },
{typeof(Subscriptions), () =>
{
if(nav.SelectedItem != toSubscriptions)
nav.SelectedItem = toSubscriptions;
else
s = Sender.None;
} },
{ typeof(History), () =>
{
if((content.Content as History).id == "HL")
{
if(nav.SelectedItem != toHistory)
nav.SelectedItem = toHistory;
else
s = Sender.None;
}
else
{
if(nav.SelectedItem != toLater)
nav.SelectedItem = toLater;
else
s = Sender.None;
}
} },
{ typeof(Home), () =>
{
if(nav.SelectedItem != toHome)
nav.SelectedItem = toHome;
else
s = Sender.None;
} },
{ typeof(Downloads), () =>
{
if(nav.SelectedItem != toDownloads)
nav.SelectedItem = toDownloads;
else
s = Sender.None;
} }
};
try { navCase[content.SourcePageType](); }
catch
{
nav.SelectedItem = null;
} }
} }
else else
@@ -729,32 +513,12 @@ namespace FoxTube
else else
nav.IsBackEnabled = false; nav.IsBackEnabled = false;
if (content.SourcePageType == typeof(Home) || content.SourcePageType == typeof(Settings) || content.SourcePageType == typeof(Subscriptions)) SetNavigationMenu();
{
nav.ExpandedModeThresholdWidth = 1008;
if (nav.DisplayMode == NavigationViewDisplayMode.Expanded)
nav.IsPaneOpen = true;
}
else
nav.ExpandedModeThresholdWidth = short.MaxValue;
if (videoPlaceholder.Content != null && videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch) if (videoPlaceholder.Content != null && videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer(); MinimizeAsInitializer();
} }
private void Nav_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
{
if (videoPlaceholder.Content != null)
{
if ((videoPlaceholder.Content as VideoPage).loading.State != LoadingState.Loaded)
CloseVideo();
else if (videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer();
}
else
content.GoBack();
}
private void Page_PreviewKeyUp(object sender, KeyRoutedEventArgs e) private void Page_PreviewKeyUp(object sender, KeyRoutedEventArgs e)
{ {
if(videoPlaceholder.Content != null && FocusManager.GetFocusedElement().GetType() != typeof(TextBox)) if(videoPlaceholder.Content != null && FocusManager.GetFocusedElement().GetType() != typeof(TextBox))
@@ -778,5 +542,58 @@ namespace FoxTube
{ {
content.Navigate(typeof(Browser)); content.Navigate(typeof(Browser));
} }
private void Nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
try
{
if (s == Sender.None)
{
s = Sender.Menu;
if (args.IsSettingsSelected)
content.Navigate(typeof(Settings));
else
{
if (args.SelectedItem == toHome)
content.Navigate(typeof(Home));
else if (args.SelectedItem == toHistory)
content.Navigate(typeof(History), "HL");
else if (args.SelectedItem == toLiked)
content.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes);
else if (args.SelectedItem == toLater)
content.Navigate(typeof(History), "WL");
else if (args.SelectedItem == toSubscriptions)
content.Navigate(typeof(Subscriptions));
else if (args.SelectedItem == toDownloads)
content.Navigate(typeof(Downloads));
else if (args.SelectedItem == toChannel)
content.Navigate(typeof(ChannelPage), SecretsVault.UserChannel.Id);
else
content.Navigate(typeof(ChannelPage), (args.SelectedItem as Subscription).Snippet.ResourceId.ChannelId);
}
}
else
s = Sender.None;
}
catch { }
}
private void Nav_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
{
if (videoPlaceholder.Content != null)
{
if ((videoPlaceholder.Content as VideoPage).loading.State != LoadingState.Loaded)
CloseVideo();
else if (videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer();
}
else
content.GoBack();
}
private void Nav_PaneChanged(NavigationView sender, object args)
{
AppTitleBar.Visibility = nav.IsPaneOpen? Visibility.Visible : Visibility.Collapsed;
}
} }
} }
-2
View File
@@ -51,8 +51,6 @@ namespace FoxTube.Pages
try try
{ {
playlistId = id; playlistId = id;
if (Methods.NeedToResponse)
Methods.MainPage.Content_Navigated(this, null);
PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet,contentDetails"); PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet,contentDetails");
request.Id = id; request.Id = id;
+1 -3
View File
@@ -27,9 +27,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel> <StackPanel>
<TextBlock x:Uid="/About/aboutHeader" Text="About us and this app" FontSize="28"/> <TextBlock Text="FoxTube" FontSize="28"/>
<TextBlock Text="FoxTube" FontSize="24"/>
<TextBlock Name="version" Text="[currentVersion]" FontSize="14" Foreground="Gray" Margin="0,-5,0,10"/> <TextBlock Name="version" Text="[currentVersion]" FontSize="14" Foreground="Gray" Margin="0,-5,0,10"/>
<TextBlock x:Uid="/About/developed" TextWrapping="WrapWholeWords" Text="Developed by Michael Gordeev (also known as XFox)" Margin="0,0,0,10"/> <TextBlock x:Uid="/About/developed" TextWrapping="WrapWholeWords" Text="Developed by Michael Gordeev (also known as XFox)" Margin="0,0,0,10"/>
+3 -3
View File
@@ -10,11 +10,11 @@ namespace FoxTube.Pages.SettingsPages
/// </summary> /// </summary>
public sealed partial class About : Page public sealed partial class About : Page
{ {
PackageVersion ver = Package.Current.Id.Version;
public About() public About()
{ {
this.InitializeComponent(); InitializeComponent();
version.Text = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); PackageVersion ver = Package.Current.Id.Version;
version.Text = $"{ver.Major}.{ver.Minor}.{ver.Build}";
} }
private async void Button_Click(object sender, RoutedEventArgs e) private async void Button_Click(object sender, RoutedEventArgs e)
+7 -7
View File
@@ -7,6 +7,7 @@ using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using YoutubeExplode.Models.MediaStreams; using YoutubeExplode.Models.MediaStreams;
using System; using System;
using Windows.Globalization;
namespace FoxTube.Pages.SettingsPages namespace FoxTube.Pages.SettingsPages
{ {
@@ -80,7 +81,7 @@ namespace FoxTube.Pages.SettingsPages
{ {
if (SettingsStorage.Language == (language.SelectedItem as ComboBoxItem).Tag.ToString()) if (SettingsStorage.Language == (language.SelectedItem as ComboBoxItem).Tag.ToString())
return; return;
ApplicationLanguages.PrimaryLanguageOverride = (language.SelectedItem as ComboBoxItem).Tag.ToString();
SettingsStorage.Language = (language.SelectedItem as ComboBoxItem).Tag.ToString(); SettingsStorage.Language = (language.SelectedItem as ComboBoxItem).Tag.ToString();
restartNote.Visibility = Visibility.Visible; restartNote.Visibility = Visibility.Visible;
} }
@@ -125,21 +126,20 @@ namespace FoxTube.Pages.SettingsPages
if (sender == light && SettingsStorage.Theme != 0) if (sender == light && SettingsStorage.Theme != 0)
{ {
SettingsStorage.Theme = 0; SettingsStorage.Theme = 0;
Methods.MainPage.RequestedTheme = ElementTheme.Light; Application.Current.RequestedTheme = ApplicationTheme.Light;
} }
else if (sender == dark && SettingsStorage.Theme != 1) else if (sender == dark && SettingsStorage.Theme != 1)
{ {
SettingsStorage.Theme = 1; SettingsStorage.Theme = 1;
Methods.MainPage.RequestedTheme = ElementTheme.Dark; Application.Current.RequestedTheme = ApplicationTheme.Dark;
} }
else if (sender == system && SettingsStorage.Theme != 2) else if (sender == system && SettingsStorage.Theme != 2)
{ {
SettingsStorage.Theme = 2; SettingsStorage.Theme = 2;
Color uiTheme = new Windows.UI.ViewManagement.UISettings().GetColorValue(Windows.UI.ViewManagement.UIColorType.Background); if (new Windows.UI.ViewManagement.UISettings().GetColorValue(Windows.UI.ViewManagement.UIColorType.Background) == Colors.Black)
if (uiTheme == Colors.Black) Application.Current.RequestedTheme = ApplicationTheme.Dark;
Methods.MainPage.RequestedTheme = ElementTheme.Dark;
else else
Methods.MainPage.RequestedTheme = ElementTheme.Light; Application.Current.RequestedTheme = ApplicationTheme.Light;
} }
Methods.MainPage.SetTitleBar(); Methods.MainPage.SetTitleBar();
} }
+11 -12
View File
@@ -59,20 +59,19 @@
<ComboBoxItem x:Uid="/Inbox/messages" Content="Messages"/> <ComboBoxItem x:Uid="/Inbox/messages" Content="Messages"/>
<ComboBoxItem x:Uid="/Inbox/changelogs" Content="Patch notes"/> <ComboBoxItem x:Uid="/Inbox/changelogs" Content="Patch notes"/>
</ComboBox> </ComboBox>
<ListBox Name="list" SelectionChanged="list_SelectionChanged" Background="Transparent"> <ListView Name="list" SelectionChanged="list_SelectionChanged" Background="Transparent">
<ListBox.ItemContainerStyle> <ListView.ItemContainerStyle>
<Style TargetType="ListBoxItem"> <Style TargetType="ListViewItem">
<Setter Property="Padding" Value="10"/> <Setter Property="Padding" Value="10"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style> </Style>
</ListBox.ItemContainerStyle> </ListView.ItemContainerStyle>
<ListBox.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid> <Grid Margin="0, 10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition Width="2*"/> <ColumnDefinition Width="2*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid Margin="0,0,10,0"> <Grid Margin="0,0,10,0">
<Ellipse Fill="Red" Height="40" Width="40"/> <Ellipse Fill="Red" Height="40" Width="40"/>
@@ -81,12 +80,12 @@
<StackPanel Grid.Column="1"> <StackPanel Grid.Column="1">
<TextBlock FontWeight="Bold" Text="{Binding Path=Title}" MaxLines="1" TextWrapping="Wrap"/> <TextBlock FontWeight="Bold" Text="{Binding Path=Title}" MaxLines="1" TextWrapping="Wrap"/>
<TextBlock Opacity=".5" Text="{Binding Path=Subtitle}"/> <TextBlock Opacity=".5" Text="{Binding Path=Subtitle}"/>
<TextBlock Opacity=".5" FontSize="13" Text="{Binding Path=TimeStamp}" TextWrapping="WrapWholeWords"/>
</StackPanel> </StackPanel>
<TextBlock Opacity=".5" FontSize="13" Text="{Binding Path=TimeStamp}" Grid.Column="2" TextWrapping="WrapWholeWords"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListView.ItemTemplate>
</ListBox> </ListView>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
@@ -99,8 +98,8 @@
<Button Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xE106;" Width="50" Height="50" Name="close" Click="close_Click"/> <Button Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xE106;" Width="50" Height="50" Name="close" Click="close_Click"/>
<Grid Grid.Column="1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="block"> <Grid Grid.Column="1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="block">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7EA;" FontSize="70" Foreground="Gray" Margin="10"/> <TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7EA;" FontSize="50" Foreground="Gray" Margin="10"/>
<TextBlock x:Uid="/Inbox/select" Text="Select item from list" FontSize="30" VerticalAlignment="Center" TextWrapping="WrapWholeWords" Foreground="Gray"/> <TextBlock x:Uid="/Inbox/select" Text="Select item from list" FontSize="24" VerticalAlignment="Center" TextWrapping="WrapWholeWords" Foreground="Gray"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid> </Grid>
@@ -6,7 +6,6 @@ using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using FoxTube.Classes; using FoxTube.Classes;
using Windows.Storage; using Windows.Storage;
using System.Diagnostics;
using System.Xml; using System.Xml;
namespace FoxTube.Pages.SettingsPages namespace FoxTube.Pages.SettingsPages
@@ -88,7 +87,6 @@ namespace FoxTube.Pages.SettingsPages
{ {
grid.ColumnDefinitions[0].Width = new GridLength(0); grid.ColumnDefinitions[0].Width = new GridLength(0);
grid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);
Debug.WriteLine("Opened");
} }
} }
} }
@@ -115,7 +113,6 @@ namespace FoxTube.Pages.SettingsPages
{ {
grid.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
grid.ColumnDefinitions[1].Width = new GridLength(0); grid.ColumnDefinitions[1].Width = new GridLength(0);
Debug.WriteLine("Closed");
} }
} }
+1 -1
View File
@@ -21,7 +21,7 @@
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<PersonPicture Height="50" HorizontalAlignment="Left" ProfilePicture="{Binding Path=Snippet.Thumbnails.Medium.Url}"/> <PersonPicture Height="50" HorizontalAlignment="Left" ProfilePicture="{Binding Path=Snippet.Thumbnails.Medium.Url}"/>
<TextBlock Grid.Column="1" TextWrapping="Wrap" VerticalAlignment="Center" Text="{Binding Path=Snippet.Title}"/> <TextBlock Grid.Column="1" TextWrapping="Wrap" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Text="{Binding Path=Snippet.Title}"/>
</Grid> </Grid>
</Button> </Button>
</DataTemplate> </DataTemplate>
+7 -1
View File
@@ -15,7 +15,13 @@
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<controls:Advert/> <controls:Advert/>
<ui:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None" Grid.Row="1"/> <ui:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None" Grid.Row="1">
<ui:AdaptiveGridView.ItemContainerTransitions>
<TransitionCollection>
<EntranceThemeTransition IsStaggeringEnabled="True"/>
</TransitionCollection>
</ui:AdaptiveGridView.ItemContainerTransitions>
</ui:AdaptiveGridView>
<TextBlock Name="empty" Text="&#xD8;" FontSize="200" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.RowSpan="2"/> <TextBlock Name="empty" Text="&#xD8;" FontSize="200" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.RowSpan="2"/>
</Grid> </Grid>
</Page> </Page>
+10 -1
View File
@@ -1,8 +1,17 @@
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
namespace FoxTube
{
public interface IItemCard
{
}
}
namespace FoxTube.Pages namespace FoxTube.Pages
{ {
/// <summary> /// <summary>
/// Items cards container /// Items cards container
/// </summary> /// </summary>
@@ -15,7 +24,7 @@ namespace FoxTube.Pages
InitializeComponent(); InitializeComponent();
} }
public void Add(UIElement card) public void Add(IItemCard card)
{ {
list.Items.Add(card); list.Items.Add(card);
/*if (list.Items.Count % 10 == 0) /*if (list.Items.Count % 10 == 0)
+11 -5
View File
@@ -55,6 +55,10 @@
<TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/> <TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/>
<ProgressBar Name="rating" Background="Green" Foreground="Red"/> <ProgressBar Name="rating" Background="Green" Foreground="Red"/>
<Grid> <Grid>
<TextBlock Foreground="Gray" Text="[dislikes]" Name="dislikes"/>
<TextBlock HorizontalAlignment="Right" Foreground="Gray" Text="[likes]" Name="likes"/>
</Grid>
<Grid BorderBrush="{StaticResource SystemControlBackgroundListMediumRevealBorderBrush}">
<FontIcon Foreground="Gray" <FontIcon Foreground="Gray"
HorizontalAlignment="Left" HorizontalAlignment="Left"
FontSize="40" FontSize="40"
@@ -67,10 +71,6 @@
Name="like" Tapped="like_Click" Name="like" Tapped="like_Click"
Glyph="&#xE19F;"/> Glyph="&#xE19F;"/>
</Grid> </Grid>
<Grid>
<TextBlock Foreground="Gray" Text="[dislikes]" Name="dislikes"/>
<TextBlock HorizontalAlignment="Right" Foreground="Gray" Text="[likes]" Name="likes"/>
</Grid>
</StackPanel> </StackPanel>
</Grid> </Grid>
<TextBlock Name="description" Text="[Description]" IsTextSelectionEnabled="True" TextWrapping="WrapWholeWords"/> <TextBlock Name="description" Text="[Description]" IsTextSelectionEnabled="True" TextWrapping="WrapWholeWords"/>
@@ -138,7 +138,13 @@
<ScrollViewer> <ScrollViewer>
<StackPanel> <StackPanel>
<controls1:Advert/> <controls1:Advert/>
<StackPanel Name="relatedVideos"/> <StackPanel Name="relatedVideos">
<StackPanel.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition IsStaggeringEnabled="True"/>
</TransitionCollection>
</StackPanel.ChildrenTransitions>
</StackPanel>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
</PivotItem> </PivotItem>
+1 -1
View File
@@ -186,7 +186,7 @@
<data name="signNew.Text" xml:space="preserve"> <data name="signNew.Text" xml:space="preserve">
<value>Create new Google account</value> <value>Create new Google account</value>
</data> </data>
<data name="signOut.Text" xml:space="preserve"> <data name="signOut.Content" xml:space="preserve">
<value>Log out</value> <value>Log out</value>
</data> </data>
<data name="subscriptions.Content" xml:space="preserve"> <data name="subscriptions.Content" xml:space="preserve">
+1 -1
View File
@@ -186,7 +186,7 @@
<data name="signNew.Text" xml:space="preserve"> <data name="signNew.Text" xml:space="preserve">
<value>Создать новый аккаунт Google</value> <value>Создать новый аккаунт Google</value>
</data> </data>
<data name="signOut.Text" xml:space="preserve"> <data name="signOut.Content" xml:space="preserve">
<value>Выйти</value> <value>Выйти</value>
</data> </data>
<data name="subscriptions.Content" xml:space="preserve"> <data name="subscriptions.Content" xml:space="preserve">