Archived
1
0

Well, I'm depressing so no message. Just accept your faith

This commit is contained in:
Michael Gordeev
2019-03-26 12:16:56 +03:00
parent 34e33d3f0e
commit 854b0c88b1
81 changed files with 1212 additions and 178 deletions
+8
View File
@@ -10,6 +10,7 @@ using System.Xml;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Background;
using Windows.ApplicationModel.Core;
using Windows.Globalization;
using Windows.Storage;
using Windows.System.Power;
@@ -22,6 +23,7 @@ namespace FoxTube
{
sealed partial class App : Application
{
Stopwatch sw = new Stopwatch();
public App()
{
SettingsStorage.LoadData();
@@ -45,6 +47,8 @@ namespace FoxTube
AppCenter.Start("45774462-9ea7-438a-96fc-03982666f39e", typeof(Analytics));
AppCenter.SetCountryCode(SettingsStorage.Region);
sw.Start();
}
/// <summary>
@@ -257,6 +261,10 @@ namespace FoxTube
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
sw.Stop();
SettingsStorage.Uptime += sw.Elapsed;
SettingsStorage.SaveData();
DownloadAgent.QuitPrompt();
deferral.Complete();
+4
View File
@@ -27,6 +27,10 @@ using YoutubeExplode.Models.MediaStreams;
namespace FoxTube
{
public interface NavigationPage
{
object Parameter { get; set; }
}
public static class Methods
{
private static ResourceLoader resources = ResourceLoader.GetForCurrentView("Methods");
+38 -21
View File
@@ -10,6 +10,9 @@ using Newtonsoft.Json;
using Windows.Storage;
using Windows.Services.Store;
using System.Net.Http;
using Google.Apis.Oauth2.v2.Data;
using Google.Apis.Oauth2.v2;
using static Google.Apis.Auth.OAuth2.UwpCodeReceiver;
namespace FoxTube
{
@@ -49,6 +52,7 @@ namespace FoxTube
public static string AccountId => UserChannel?.Id;
public static Channel UserChannel { get; private set; }
public static Userinfoplus UserInfo { get; private set; }
public static List<Subscription> Subscriptions { get; } = new List<Subscription>();
public static List<string> History { get; set; } = new List<string>();
@@ -116,31 +120,45 @@ namespace FoxTube
/// <param name="retrieveSubs">Loads user's subscriptions if true</param>
public static async void Authorize(bool retrieveSubs = true)
{
#region Retrieving user's credential
try
{
#region Retrieving user's credential
Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
Secrets,
new[]
{
Google.Apis.Oauth2.v2.Oauth2Service.Scope.UserinfoProfile,
Secrets,
new[]
{
Oauth2Service.Scope.UserinfoProfile,
Oauth2Service.Scope.UserinfoEmail,
YouTubeService.Scope.YoutubeForceSsl,
YouTubeService.Scope.Youtube,
YouTubeService.Scope.YoutubeUpload,
YouTubeService.Scope.YoutubeReadonly,
YouTubeService.Scope.Youtubepartner
},
"user",
CancellationToken.None);
if (Credential == null || !retrieveSubs)
goto InvokeEvent;
},
"user",
CancellationToken.None);
}
catch (AuthenticateException e)
{
if (e.Message.Contains("UserCancel"))
return;
else
throw e;
}
SettingsStorage.HasAccount = true;
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Credential.Token.AccessToken);
#endregion
if (Credential == null || !retrieveSubs)
return;
SettingsStorage.HasAccount = true;
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Credential.Token.AccessToken);
#endregion
try
{
#region Retrieving user's data
UserInfo = await new Oauth2Service(Initializer).Userinfo.Get().ExecuteAsync();
try
{
WatchLater = await Methods.GetLater();
@@ -148,10 +166,6 @@ namespace FoxTube
}
catch { }
var request = Service.Channels.List("snippet,contentDetails");
request.Mine = true;
UserChannel = (await request.ExecuteAsync()).Items[0];
SubscriptionsResource.ListRequest subRequest = Service.Subscriptions.List("snippet");
subRequest.Mine = true;
subRequest.MaxResults = 50;
@@ -169,13 +183,16 @@ namespace FoxTube
nextToken = subResponse.NextPageToken;
} while (!string.IsNullOrWhiteSpace(nextToken));
var request = Service.Channels.List("snippet,contentDetails");
request.Mine = true;
UserChannel = (await request.ExecuteAsync()).Items[0];
#endregion
//Saving user's subscriptions for background task
SaveSubscriptions();
InvokeEvent:
AuthorizationStateChanged?.Invoke(args: IsAuthorized);
AuthorizationStateChanged?.Invoke(args: true);
}
catch
{
@@ -189,7 +206,7 @@ namespace FoxTube
public static void SaveSubscriptions()
{
Dictionary<string, string> subs = new Dictionary<string, string>();
Subscriptions.ForEach(x => subs.Add(x.Snippet.ResourceId.ChannelId, x.Snippet.Thumbnails.Medium.Url));
Subscriptions.ForEach(x => subs.Add(x.Snippet.ResourceId.ChannelId, x.Snippet.Thumbnails.Default__.Url));
ApplicationData.Current.RoamingSettings.Values["subscriptions"] = JsonConvert.SerializeObject(subs);
}
+34 -2
View File
@@ -19,7 +19,7 @@ namespace FoxTube
public bool checkConnection = true;
public bool autoplay = true;
public int volume = 100;
public double 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";
@@ -28,6 +28,10 @@ namespace FoxTube
public bool hasAccount = false;
public int theme = 2;
public TimeSpan uptime = TimeSpan.FromSeconds(0);
public bool promptReview = true;
public bool promptFeedback = true;
}
public static class SettingsStorage
@@ -88,7 +92,7 @@ namespace FoxTube
SaveData();
}
}
public static int Volume
public static double Volume
{
get { return Container.volume; }
set
@@ -187,6 +191,34 @@ namespace FoxTube
}
}
public static TimeSpan Uptime
{
get { return Container.uptime; }
set
{
Container.uptime = value;
SaveData();
}
}
public static bool PromptReview
{
get { return Container.promptReview; }
set
{
Container.promptReview = value;
SaveData();
}
}
public static bool PromptFeedback
{
get { return Container.promptFeedback; }
set
{
Container.promptFeedback = value;
SaveData();
}
}
//Settings storage
private static readonly ApplicationDataContainer storage = ApplicationData.Current.RoamingSettings;
private static SettingsContainer Container;
+1 -1
View File
@@ -10,7 +10,7 @@
VerticalAlignment="Top"
d:DesignHeight="290"
d:DesignWidth="384"
MaxWidth="500">
Opacity="0">
<Windows10version1809:UserControl.OpacityTransition>
<ScalarTransition Duration="0:0:0.5"/>
@@ -84,6 +84,11 @@ namespace FoxTube
}
}
public void Minimize()
{
Minimize_Click(GetTemplateChild("minimize"), null);
}
private void ProgressSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
{
(GetTemplateChild("compactSeek") as ProgressBar).Value = e.NewValue;
@@ -189,6 +194,8 @@ namespace FoxTube
(GetTemplateChild("maximize") as Button).Visibility = Visibility.Collapsed;
(GetTemplateChild("compactClose") as Button).Visibility = Visibility.Collapsed;
(GetTemplateChild("dragholder") as Button).Visibility = Visibility.Visible;
(GetTemplateChild("captions") as LiveCaptions).Size = 15;
}
@@ -237,6 +244,8 @@ namespace FoxTube
(GetTemplateChild("footer") as Grid).Visibility = Visibility.Visible;
(GetTemplateChild("captions") as LiveCaptions).Size = 24;
(GetTemplateChild("dragholder") as Button).Visibility = Visibility.Collapsed;
}
public void SetMeta(string title, string channel)
+6 -17
View File
@@ -1,32 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Foundation;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
using Google.Apis.YouTube.v3.Data;
using Windows.UI.Xaml.Media.Imaging;
using Windows.Media;
using Windows.Storage.Streams;
using Windows.UI.ViewManagement;
using System.Xml;
using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.Media.Casting;
using YoutubeExplode.Models.MediaStreams;
using YoutubeExplode;
using YoutubeExplode.Models.ClosedCaptions;
using System.Globalization;
using FoxTube.Controls;
using Windows.System;
using Windows.Media.Core;
using Windows.Media.Playback;
using System.Net.Http;
using System.Diagnostics;
using Windows.UI.Popups;
namespace FoxTube
{
@@ -124,6 +107,11 @@ namespace FoxTube
MiniMode?.Invoke(this, e);
}
public void Minimize()
{
Controls.Minimize();
}
private void Controls_QualityChanged(object sender, MediaStreamInfo requestedQuality, MediaStreamInfoSet list)
{
videoSource.Pause();
@@ -232,6 +220,7 @@ namespace FoxTube
private void VideoSource_VolumeChanged(object sender, RoutedEventArgs e)
{
audioSource.Volume = videoSource.Volume;
SettingsStorage.Volume = videoSource.Volume;
}
}
}
-1
View File
@@ -10,7 +10,6 @@
VerticalAlignment="Top"
d:DesignHeight="290"
d:DesignWidth="384"
MaxWidth="500"
Opacity="0">
<Windows10version1809:Page.OpacityTransition>
-1
View File
@@ -10,7 +10,6 @@
VerticalAlignment="Top"
d:DesignHeight="290"
d:DesignWidth="384"
MaxWidth="500"
Opacity="0">
<Windows10version1809:UserControl.OpacityTransition>
+13 -7
View File
@@ -393,7 +393,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AdaptiveCards.Rendering.Uwp">
<Version>1.1.0</Version>
<Version>1.1.2</Version>
</PackageReference>
<PackageReference Include="Google.Apis">
<Version>1.30.0-beta02</Version>
@@ -414,25 +414,28 @@
<Version>10.1811.22001</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Analytics">
<Version>1.13.0</Version>
<Version>1.13.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.1.9</Version>
<Version>6.2.8</Version>
</PackageReference>
<PackageReference Include="Microsoft.Services.Store.Engagement">
<Version>10.1901.28001</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
<Version>5.0.0</Version>
<Version>5.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>5.0.0</Version>
<Version>5.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.0.181018003.1</Version>
<Version>2.0.181018004</Version>
</PackageReference>
<PackageReference Include="runtime.win10-arm64.runtime.native.System.IO.Compression">
<Version>4.3.2</Version>
</PackageReference>
<PackageReference Include="YoutubeExplode">
<Version>4.6.4</Version>
<Version>4.6.7</Version>
</PackageReference>
<PackageReference Include="YoutubeExtractor">
<Version>0.10.11</Version>
@@ -485,6 +488,9 @@
<SDKReference Include="Microsoft.Advertising.Xaml, Version=10.0">
<Name>Microsoft Advertising SDK for XAML</Name>
</SDKReference>
<SDKReference Include="Microsoft.Services.Store.Engagement, Version=10.0">
<Name>Microsoft Engagement Framework</Name>
</SDKReference>
</ItemGroup>
<ItemGroup />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
+1 -1
View File
@@ -15,7 +15,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="FoxTube.App" ResourceGroup="foxtube">
<uap:VisualElements DisplayName="FoxTube" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="YouTube Client for Windows 10" BackgroundColor="skyBlue">
<uap:VisualElements DisplayName="FoxTube" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="YouTube Client for Windows 10" BackgroundColor="#282828">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" ShortName="FoxTube" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
+10 -1
View File
@@ -21,8 +21,9 @@ namespace FoxTube.Pages
/// <summary>
/// Channel page
/// </summary>
public sealed partial class ChannelPage : Page
public sealed partial class ChannelPage : Page, NavigationPage
{
public object Parameter { get; set; } = null;
readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Cards");
public string channelId;
@@ -43,6 +44,7 @@ namespace FoxTube.Pages
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Parameter = e.Parameter;
if ((string)e.Parameter == null)
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated.");
else
@@ -124,6 +126,8 @@ namespace FoxTube.Pages
{ "Channel ID", channelId }
});
}
ScrollViewer_ViewChanged(this, null);
}
async void LoadPlaylist()
@@ -167,6 +171,11 @@ namespace FoxTube.Pages
{
if (content.SelectedIndex == 1 && !playlistLoaded)
LoadPlaylist();
if (content.SelectedIndex == 0)
ScrollViewer_ViewChanged(this, null);
else
ColapsedHeader.Opacity = 1;
}
private async void ShowMorePlaylists_Click()
+2 -1
View File
@@ -9,8 +9,9 @@ namespace FoxTube.Pages
/// <summary>
/// Downloads page
/// </summary>
public sealed partial class Downloads : Page
public sealed partial class Downloads : Page, NavigationPage
{
public object Parameter { get; set; } = null;
public Downloads()
{
InitializeComponent();
+3 -1
View File
@@ -12,8 +12,9 @@ namespace FoxTube.Pages
/// <summary>
/// YouTube history page
/// </summary>
public sealed partial class History : Page
public sealed partial class History : Page, NavigationPage
{
public object Parameter { get; set; } = null;
List<string> entries;
int page = 1;
public string id = "HL";
@@ -26,6 +27,7 @@ namespace FoxTube.Pages
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Parameter = e.Parameter;
loading.RefreshPage += Refresh_Click;
+2 -1
View File
@@ -14,8 +14,9 @@ namespace FoxTube
/// <summary>
/// Home page
/// </summary>
public sealed partial class Home : Page
public sealed partial class Home : Page, NavigationPage
{
public object Parameter { get; set; } = null;
private bool trendLoaded = false, recLoaded = false, subsLoaded = false;
List<string> homeList = new List<string>();
+6 -14
View File
@@ -40,7 +40,7 @@
<NavigationView SelectedItem="toHome" Windows10version1803:BackRequested="Nav_BackRequested" Windows10version1803:PaneClosing="Nav_PaneClosing" Windows10version1803:PaneOpened="Nav_PaneOpened" OpenPaneLength="300" Name="nav" SelectionChanged="Nav_SelectionChanged">
<NavigationView.Header>
<TextBlock Name="Title" Text="Hello, World!" Margin="0,30,0,10" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBlock Name="Title" Margin="0,30,0,10" Style="{StaticResource TitleTextBlockStyle}"/>
</NavigationView.Header>
<NavigationView.MenuItemTemplate>
@@ -81,7 +81,7 @@
</TransitionCollection>
</NavigationViewList.ItemContainerTransitions>
<NavigationViewItem Name="openWeb" Tapped="Web_Tapped" Icon="Globe" Content="Browser" Visibility="Collapsed"/>
<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" Visibility="Collapsed">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xED15;"/>
</NavigationViewItem.Icon>
@@ -93,18 +93,10 @@
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Name="account" Tapped="OpenContext">
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE8FA;" FontSize="16" Margin="0,0,16,0"/>
<TextBlock x:Uid="/Main/signIn" Text="Add account"/>
</StackPanel>
<NavigationViewItem.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem x:Uid="/Main/signEx" Text="Sign in with existing account" Name="signIn" Click="SignIn_Click"/>
<MenuFlyoutItem x:Uid="/Main/signNew" Text="Create new Google account" Name="createAccount" Click="CreateAccount_Click"/>
</MenuFlyout>
</NavigationViewItem.ContextFlyout>
<NavigationViewItem Name="account" x:Uid="/Main/signIn" Content="Add account" Tapped="SignIn_Click" Visibility="Collapsed">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE8FA;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Visibility="Collapsed" Name="avatar" Tapped="OpenContext" Padding="-5">
+94 -46
View File
@@ -18,31 +18,39 @@ using FoxTube.Pages;
using Windows.UI.Popups;
using Windows.Networking.Connectivity;
using Windows.ApplicationModel.Resources;
using Microsoft.Services.Store.Engagement;
using System.Linq;
namespace FoxTube
{
public enum Sender { Menu, Frame, None }
/// <summary>
/// Main app's layout
/// </summary>
public sealed partial class MainPage : Page
{
Sender s = Sender.None;
bool wasInvoked = false;
readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Main");
Dictionary<Type, Action> headers;
public MainPage()
{
InitializeComponent();
Window.Current.SetTitleBar(AppTitleBar);
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => SetTitleBar(s);
SecretsVault.AuthorizationStateChanged += AuthorizationStateChanged;
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
SecretsVault.Purchased += (sender, e) =>
SecretsVault.Purchased += async (sender, e) =>
{
//TODO: Localize strings
removeAds.Visibility = (e[0] as bool?).Value ? Visibility.Collapsed : Visibility.Visible;
content.Navigate(typeof(Home));
MessageDialog dialog = new MessageDialog("Thanks for purchasing full version of the app (^∇^) In order to complete changes we need to reopen it. But you can do it later");
dialog.Commands.Add(new UICommand("Close the app", (command) => Methods.CloseApp()));
dialog.Commands.Add(new UICommand("Later"));
dialog.CancelCommandIndex = 1;
dialog.DefaultCommandIndex = 0;
await dialog.ShowAsync();
};
SecretsVault.Initialize();
@@ -63,6 +71,55 @@ namespace FoxTube
{ typeof(Home), () => Title.Text = resources.GetString("/Main/home/Content") },
{ typeof(Downloads), () => Title.Text = resources.GetString("/Main/downloads/Content") }
};
if(StoreServicesFeedbackLauncher.IsSupported())
feedback.Visibility = Visibility.Visible;
PromptFeedback();
}
async void PromptFeedback()
{
//TODO: Localize strings
if (SettingsStorage.Uptime.TotalHours >= 12 && SettingsStorage.PromptFeedback)
{
MessageDialog dialog = new MessageDialog("Have some thoughts to share about the app or any suggestions? Leave feedback!");
dialog.Commands.Add(new UICommand("Don't ask me anymore", (command) => SettingsStorage.PromptFeedback = false));
dialog.Commands.Add(new UICommand("Maybe later"));
dialog.Commands.Add(new UICommand("Sure!", async (command) =>
{
SettingsStorage.PromptFeedback = false;
if (StoreServicesFeedbackLauncher.IsSupported())
await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();
else
{
MessageDialog message = new MessageDialog("Oops. Seems like you don't have a Feedback Hub app. But you can stil send your feedback to michael.xfox@outlook.com");
message.Commands.Add(new UICommand("Send an E-mail", async (c) => await Launcher.LaunchUriAsync("mailto:michael.xfox@outlook.com".ToUri())));
message.Commands.Add(new UICommand("Nevermind. Get me back"));
message.CancelCommandIndex = 1;
message.DefaultCommandIndex = 0;
await message.ShowAsync();
}
}));
dialog.DefaultCommandIndex = 2;
dialog.CancelCommandIndex = 1;
await dialog.ShowAsync();
}
if (SettingsStorage.Uptime.TotalHours >= 24 && SettingsStorage.PromptReview)
{
MessageDialog dialog = new MessageDialog("Like our app? Review it on Microsoft Store!");
dialog.Commands.Add(new UICommand("Don't ask me anymore", (command) => SettingsStorage.PromptReview = false));
dialog.Commands.Add(new UICommand("Maybe later"));
dialog.Commands.Add(new UICommand("Sure!", async (command) =>
{
SettingsStorage.PromptReview = false;
await Launcher.LaunchUriAsync("ms-windows-store://review/?ProductId=9NCQQXJTDLFH".ToUri());
}));
dialog.DefaultCommandIndex = 2;
dialog.CancelCommandIndex = 1;
await dialog.ShowAsync();
}
}
public string GetPlaylist()
@@ -73,7 +130,7 @@ namespace FoxTube
public void SetTitleBar(CoreApplicationViewTitleBar coreTitleBar = null)
{
if(coreTitleBar != null)
if (coreTitleBar != null)
{
bool full = ApplicationView.GetForCurrentView().IsFullScreenMode;
double left = 12 + (full ? 0 : coreTitleBar.SystemOverlayLeftInset);
@@ -89,10 +146,10 @@ namespace FoxTube
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveForegroundColor = Colors.Gray;
if(Application.Current.RequestedTheme == ApplicationTheme.Dark)
titleBar.ForegroundColor = Colors.White;
if(RequestedTheme == ElementTheme.Dark || (RequestedTheme == ElementTheme.Default && Application.Current.RequestedTheme == ApplicationTheme.Dark))
titleBar.ButtonForegroundColor = Colors.White;
else
titleBar.ForegroundColor = Colors.Black;
titleBar.ButtonForegroundColor = Colors.Black;
}
private void SecretsVault_SubscriptionsChanged(object sender, params object[] args)
@@ -100,7 +157,7 @@ namespace FoxTube
switch(args[0] as string)
{
case "add":
if (nav.MenuItems.Count >= 19)
if (nav.MenuItems.Count < 19)
nav.MenuItems.Add(args[1] as Subscription);
break;
@@ -113,7 +170,6 @@ namespace FoxTube
if (SecretsVault.Subscriptions.Count >= 10)
nav.MenuItems.Add(SecretsVault.Subscriptions[9]);
break;
}
}
@@ -124,22 +180,16 @@ namespace FoxTube
{
case true:
account.Visibility = Visibility.Collapsed;
try
{
Userinfoplus info = await new Oauth2Service(SecretsVault.Initializer).Userinfo.Get().ExecuteAsync();
myName.Text = myNameFlyout.Text = info.Name;
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 { }
myName.Text = myNameFlyout.Text = SecretsVault.UserInfo.Name;
myEmail.Text = SecretsVault.UserInfo.Email;
avatarFlyout.ProfilePicture = new BitmapImage(SecretsVault.UserInfo.Picture.ToUri());
((avatar.Content as StackPanel).Children[0] as PersonPicture).ProfilePicture = avatarFlyout.ProfilePicture;
avatar.Visibility = Visibility.Visible;
toChannel.Visibility = Visibility.Visible;
if(SecretsVault.UserChannel != null)
toChannel.Visibility = Visibility.Visible;
toSubscriptions.Visibility = Visibility.Visible;
libHeader.Visibility = Visibility.Visible;
toHistory.Visibility = Visibility.Visible;
@@ -152,9 +202,8 @@ namespace FoxTube
for (int k = 0; k < SecretsVault.Subscriptions.Count && k < 10; k++)
nav.MenuItems.Add(SecretsVault.Subscriptions[k]);
}
if (SecretsVault.UserChannel == null)
toChannel.Visibility = Visibility.Collapsed;
break;
case false:
for (int k = nav.MenuItems.Count - 1; k > 8; k--)
nav.MenuItems.RemoveAt(k);
@@ -172,6 +221,7 @@ namespace FoxTube
subsHeader.Visibility = Visibility.Collapsed;
break;
default:
MessageDialog dialog = new MessageDialog(resources.GetString("/Main/connectErrContent"), resources.GetString("/Main/connectErrHeader"));
@@ -191,12 +241,12 @@ namespace FoxTube
break;
}
if(e[0] as bool? != null)
DownloadAgent.Initialize();
await Dispatcher.RunIdleAsync((command) => DownloadAgent.Initialize());
wasInvoked = false;
s = Sender.None;
if (content.Content != null)
content.Navigate(content.SourcePageType);
content.Navigate(content.CurrentSourcePageType, (content.Content as NavigationPage).Parameter);
else
content.Navigate(typeof(Home));
@@ -206,15 +256,10 @@ namespace FoxTube
private async void Feedback_Click(object sender, TappedRoutedEventArgs e)
{
await Launcher.LaunchUriAsync(new Uri("feedback-hub:"));
await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();
}
private async void CreateAccount_Click(object sender, RoutedEventArgs e)
{
await Launcher.LaunchUriAsync(new Uri("https://accounts.google.com/signup/v2/webcreateaccount?ManageAccount&flowName=GlifWebSignIn&flowEntry=SignUp"));
}
private void SignIn_Click(object sender, RoutedEventArgs e)
private void SignIn_Click(object sender, TappedRoutedEventArgs e)
{
SecretsVault.Authorize();
}
@@ -318,13 +363,13 @@ namespace FoxTube
public void MinimizeAsInitializer()
{
if (videoPlaceholder.Content != null)
if (videoPlaceholder.Content == null)
return;
if ((videoPlaceholder.Content as VideoPage).LoadingPage.State != LoadingState.Loaded)
CloseVideo();
else
(videoPlaceholder.Content as VideoPage).Player.Controls_MiniModeChanged(this, true);
(videoPlaceholder.Content as VideoPage).Player.Minimize();
try { headers[content.SourcePageType](); }
catch { }
@@ -390,6 +435,8 @@ namespace FoxTube
nav.IsBackEnabled = true;
else
nav.IsBackEnabled = false;
SetNavigationMenu();
}
private void Search_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
@@ -400,6 +447,7 @@ namespace FoxTube
private void Search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
//TODO: Make it run async
if (search.Text.Length > 2 && args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
{
try
@@ -425,7 +473,7 @@ namespace FoxTube
if (nav.SelectedItem != item)
nav.SelectedItem = item;
else
s = Sender.None;
wasInvoked = false;
}
catch { }
}
@@ -435,9 +483,9 @@ namespace FoxTube
try { headers[e.SourcePageType](); }
catch { }
if (s == Sender.None)
if (!wasInvoked)
{
s = Sender.Frame;
wasInvoked = true;
if (e.SourcePageType == typeof(Settings))
SetNavigationItem(nav.SettingsItem);
@@ -472,7 +520,7 @@ namespace FoxTube
}
}
else
s = Sender.None;
wasInvoked = false;
if(e.SourcePageType == typeof(History))
{
@@ -512,9 +560,9 @@ namespace FoxTube
{
try
{
if (s == Sender.None)
if (!wasInvoked)
{
s = Sender.Menu;
wasInvoked = true;
if (args.IsSettingsSelected)
content.Navigate(typeof(Settings));
else
@@ -538,7 +586,7 @@ namespace FoxTube
}
}
else
s = Sender.None;
wasInvoked = false;
}
catch { }
}
+3 -1
View File
@@ -18,8 +18,9 @@ namespace FoxTube.Pages
/// <summary>
/// Playlist page
/// </summary>
public sealed partial class PlaylistPage : Page
public sealed partial class PlaylistPage : Page, NavigationPage
{
public object Parameter { get; set; } = null;
public string playlistId;
Playlist item;
@@ -36,6 +37,7 @@ namespace FoxTube.Pages
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Parameter = e.Parameter;
if (e.Parameter == null)
loading.Error("NullReferenceException", "Unable to initialize page. Playlist ID is not stated.");
else
+3 -1
View File
@@ -16,8 +16,9 @@ namespace FoxTube
/// <summary>
/// Search page
/// </summary>
public sealed partial class Search : Page
public sealed partial class Search : Page, NavigationPage
{
public object Parameter { get; set; } = null;
readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Search");
public SearchParameters Parameters;
@@ -63,6 +64,7 @@ namespace FoxTube
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Parameter = e.Parameter;
if (e.Parameter == null)
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated.");
else
+4 -2
View File
@@ -7,8 +7,9 @@ namespace FoxTube
/// <summary>
/// Settings tabs placeholder
/// </summary>
public sealed partial class Settings : Page
public sealed partial class Settings : Page, NavigationPage
{
public object Parameter { get; set; } = null;
bool inboxLoaded = false;
string inboxId = null;
public Settings()
@@ -19,7 +20,8 @@ namespace FoxTube
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if(!string.IsNullOrWhiteSpace(e.Parameter as string))
Parameter = e.Parameter;
if (!string.IsNullOrWhiteSpace(e.Parameter as string))
{
inboxId = e.Parameter as string;
pivot.SelectedIndex = 2;
+1 -1
View File
@@ -47,7 +47,7 @@
<HyperlinkButton x:Uid="/About/guides" Content="YouTube Community Guidelines" NavigateUri="https://youtube.com/t/community_guidelines" Padding="0,0,0,10"/>
<TextBlock x:Uid="/About/crMe" Text="© 2018 Michael Gordeev"/>
<TextBlock x:Uid="/About/crYt" Text="© 2018 YouTube, LLC"/>
<Button x:Uid="/About/feedback" Content="Leave feedback" Margin="0,5" Click="Button_Click"/>
<Button Name="feedback" x:Uid="/About/feedback" Content="Leave feedback" Margin="0,5" Click="Button_Click" Visibility="Collapsed"/>
</StackPanel>
<Image Grid.Column="1" Source="/Assets/LogoAvatar.png" VerticalAlignment="Top" Width="128"/>
</Grid>
+6 -2
View File
@@ -1,4 +1,5 @@
using System;
using Microsoft.Services.Store.Engagement;
using System;
using Windows.ApplicationModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -15,11 +16,14 @@ namespace FoxTube.Pages.SettingsPages
InitializeComponent();
PackageVersion ver = Package.Current.Id.Version;
version.Text = $"{ver.Major}.{ver.Minor}.{ver.Build}";
if (StoreServicesFeedbackLauncher.IsSupported())
feedback.Visibility = Visibility.Visible;
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("feedback-hub:"));
await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();
}
}
}
+4 -4
View File
@@ -126,20 +126,20 @@ namespace FoxTube.Pages.SettingsPages
if (sender == light && SettingsStorage.Theme != 0)
{
SettingsStorage.Theme = 0;
Application.Current.RequestedTheme = ApplicationTheme.Light;
Methods.MainPage.RequestedTheme = ElementTheme.Light;
}
else if (sender == dark && SettingsStorage.Theme != 1)
{
SettingsStorage.Theme = 1;
Application.Current.RequestedTheme = ApplicationTheme.Dark;
Methods.MainPage.RequestedTheme = ElementTheme.Dark;
}
else if (sender == system && SettingsStorage.Theme != 2)
{
SettingsStorage.Theme = 2;
if (new Windows.UI.ViewManagement.UISettings().GetColorValue(Windows.UI.ViewManagement.UIColorType.Background) == Colors.Black)
Application.Current.RequestedTheme = ApplicationTheme.Dark;
Methods.MainPage.RequestedTheme = ElementTheme.Dark;
else
Application.Current.RequestedTheme = ApplicationTheme.Light;
Methods.MainPage.RequestedTheme = ElementTheme.Light;
}
Methods.MainPage.SetTitleBar();
}
+2 -1
View File
@@ -8,8 +8,9 @@ namespace FoxTube.Pages
/// <summary>
/// User's subscriptions page
/// </summary>
public sealed partial class Subscriptions : Page
public sealed partial class Subscriptions : Page, NavigationPage
{
public object Parameter { get; set; } = null;
readonly List<Subscription> list = SecretsVault.Subscriptions;
public Subscriptions()
{
+15 -11
View File
@@ -4,18 +4,22 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI.Controls"
x:Name="root"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ui:AdaptiveGridView Name="list" DesiredWidth="400" SelectionMode="None" HorizontalContentAlignment="Left">
<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"/>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="grid" SizeChanged="Grid_SizeChanged">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<TextBlock Name="empty" Grid.ColumnSpan="5" Text="&#xD8;" FontSize="200" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.RowSpan="2"/>
<StackPanel Grid.Column="0" Name="col0"/>
<StackPanel Grid.Column="1" Name="col1"/>
<StackPanel Grid.Column="2" Name="col2"/>
<StackPanel Grid.Column="3" Name="col3"/>
<StackPanel Grid.Column="4" Name="col4"/>
</Grid>
</Page>
+47 -7
View File
@@ -1,6 +1,4 @@
using FoxTube.Controls;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -11,8 +9,18 @@ namespace FoxTube.Pages
/// </summary>
public sealed partial class VideoGrid : Page
{
public int Count => list.Items.Count;
public ItemCollection Children => list.Items;
public int Columns
{
get { return cols; }
set
{
cols = value;
UpdateGrid();
}
}
private int cols = 1;
public int Count => Children.Count;
public List<UIElement> Children { get; } = new List<UIElement>();
public VideoGrid()
{
@@ -21,7 +29,8 @@ namespace FoxTube.Pages
public void Add(UIElement card)
{
list.Items.Add(card);
(grid.Children[Count % cols + 1] as StackPanel).Children.Add(card);
Children.Add(card);
/*if (list.Items.Count % 10 == 0)
list.Items.Add(new CardAdvert());*/
empty.Visibility = Visibility.Collapsed;
@@ -29,8 +38,39 @@ namespace FoxTube.Pages
public void Clear()
{
list.Items.Clear();
for (int k = 1; k <= 5; k++)
(grid.Children[k] as StackPanel).Children.Clear();
empty.Visibility = Visibility.Visible;
}
void UpdateGrid()
{
for (int k = 1; k <= 5; k++)
(grid.Children[k] as StackPanel).Children.Clear();
for (int k = 0; k < Count; k++)
(grid.Children[k % cols + 1] as StackPanel).Children.Add(Children[k]);
for (int k = 0; k < cols; k++)
grid.ColumnDefinitions[k].Width = new GridLength(1, GridUnitType.Star);
for (int k = cols; k < 5; k++)
grid.ColumnDefinitions[k].Width = new GridLength(0);
}
private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.NewSize.Width >= 1600 && Columns != 5)
Columns = 5;
else if (e.NewSize.Width >= 1200 && e.NewSize.Width < 1600 && Columns != 4)
Columns = 4;
else if (e.NewSize.Width >= 900 && e.NewSize.Width < 1200 && Columns != 3)
Columns = 3;
else if (e.NewSize.Width >= 550 && e.NewSize.Width < 900 && Columns != 2)
Columns = 2;
else if (e.NewSize.Width < 550 && Columns != 1)
Columns = 1;
}
}
}
+1 -1
View File
@@ -9,7 +9,6 @@
xmlns:controls1="using:FoxTube.Controls"
mc:Ignorable="d">
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
@@ -61,6 +60,7 @@
<PivotItem Header="Description" Name="descriptionPanel">
<StackPanel Margin="0,10">
<TextBlock IsTextSelectionEnabled="True" Name="title" Text="[Video title]" FontSize="25" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Start"/>
<TextBlock Text="Published at: " Name="date"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
+2 -2
View File
@@ -53,7 +53,6 @@ namespace FoxTube.Pages
public Video item;
bool isExtended = false;
bool playlistLoaded = false;
Rating userRating = Rating.None;
@@ -229,6 +228,7 @@ namespace FoxTube.Pages
{
//Setting meta
title.Text = item.Snippet.Title;
date.Text = $"{resources.GetString("/VideoPage/publishedAt")}: {item.Snippet.PublishedAt} ({Methods.GetAgo(item.Snippet.PublishedAt.Value)})";
Methods.FormatText(ref description, item.Snippet.Description);
//Setting channel button
@@ -366,7 +366,7 @@ namespace FoxTube.Pages
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult video in response.Items)
relatedVideos.Children.Add(new VideoCard(video.Id.VideoId));
relatedVideos.Add(new VideoCard(video.Id.VideoId));
}
private void Player_Minimize(object sender, params object[] e)
+1 -1
View File
@@ -180,7 +180,7 @@
<data name="signEx.Text" xml:space="preserve">
<value>Sign in with existing account</value>
</data>
<data name="signIn.Text" xml:space="preserve">
<data name="signIn.Content" xml:space="preserve">
<value>Add account</value>
</data>
<data name="signNew.Text" xml:space="preserve">
+3
View File
@@ -261,4 +261,7 @@
<data name="yes" xml:space="preserve">
<value>Yes</value>
</data>
<data name="publishedAt" xml:space="preserve">
<value>Published at</value>
</data>
</root>
+1 -1
View File
@@ -180,7 +180,7 @@
<data name="signEx.Text" xml:space="preserve">
<value>Войти с помощью существующего аккаунта Google</value>
</data>
<data name="signIn.Text" xml:space="preserve">
<data name="signIn.Content" xml:space="preserve">
<value>Войти в аккаунт</value>
</data>
<data name="signNew.Text" xml:space="preserve">
+3
View File
@@ -261,4 +261,7 @@
<data name="yes" xml:space="preserve">
<value>Да</value>
</data>
<data name="publishedAt" xml:space="preserve">
<value>Опубликовано</value>
</data>
</root>
+2 -1
View File
@@ -533,6 +533,7 @@
<Button x:Name="compactClose" VerticalAlignment="Top" HorizontalAlignment="Right">
<FontIcon Glyph="&#xE106;"/>
</Button>
<Button Height="32" Width="50" Margin="0,0,48,0" VerticalAlignment="Top" HorizontalAlignment="Right" FontFamily="Segoe MDL2 Assets" Content="&#xE700;" IsHitTestVisible="False" x:Name="dragholder"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="centralStack"/>
@@ -578,7 +579,7 @@
<Grid Grid.Column="1" Margin="10,5">
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Left" x:Name="TimeElapsedElement" Text="00:00"/>
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Right" x:Name="TimeRemainingElement" Text="00:00"/>
<Grid VerticalAlignment="Top" Height="3" Margin="0,15,0,0">
<Grid VerticalAlignment="Top" Height="4" Margin="0,15,0,0">
<ProgressBar Background="#66FFFFFF" Foreground="#66FFFFFF" x:Name="BufferingProgressBar"/>
</Grid>
<Slider x:Name="ProgressSlider" Style="{StaticResource PlayerSeek}" IsThumbToolTipEnabled="False" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>