Archived
1
0

Refinements

This commit is contained in:
Michael Gordeev
2020-07-06 15:07:23 +03:00
parent fee80ef07f
commit 6a8896d804
66 changed files with 234 additions and 119 deletions
+3 -3
View File
@@ -59,8 +59,8 @@ namespace FoxTube.Background
UserCredential Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "349735264870-2ekqlm0a4mkg3mmrfcv90s3qp3o15dq0.apps.googleusercontent.com",
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
ClientId = "1096685398208-rsabgv4dfkopr3c7p27p61pkcans012g.apps.googleusercontent.com",
ClientSecret = "EtX5VkCwrl7EZsFM2Dt7Jzpd"
},
new[]
{
@@ -107,7 +107,7 @@ namespace FoxTube.Background
foreach (Subscription item in subscriptions)
{
SearchResource.ListRequest request = service.Search.List("snippet");
request.PublishedAfter = lastCheck;
request.PublishedAfter = lastCheck.Subtract(TimeSpan.FromDays(3));
request.ChannelId = item.Snippet.ResourceId.ChannelId;
request.Type = "video";
request.MaxResults = 5;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 843 B

After

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 B

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

+21 -2
View File
@@ -1,6 +1,8 @@
using Newtonsoft.Json;
using Google.Apis.YouTube.v3.Data;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Windows.ApplicationModel.UserActivities;
using Windows.Storage;
namespace FoxTube
@@ -15,7 +17,7 @@ namespace FoxTube
{
public static List<HistoryItem> Items { get; set; } = new List<HistoryItem>();
public static void Update(HistoryItem item)
public static async void Update(HistoryItem item, Video video)
{
if (!SecretsVault.IsAuthorized)
return;
@@ -26,6 +28,23 @@ namespace FoxTube
if (Items.Count > 200)
Items.RemoveRange(200, Items.Count - 200);
Save();
UserActivitySession _currentActivity = null;
// Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
UserActivityChannel channel = UserActivityChannel.GetDefault();
UserActivity userActivity = await channel.GetOrCreateUserActivityAsync(item.Id);
// Populate required properties
userActivity.VisualElements.DisplayText = video.Snippet.Title;
userActivity.VisualElements.Description = video.Snippet.ChannelTitle;
userActivity.ActivationUri = new Uri("my-app://page2?action=edit");
//Save
await userActivity.SaveAsync(); //save the new metadata
// Dispose of any current UserActivitySession, and create a new one.
_currentActivity?.Dispose();
_currentActivity = userActivity.CreateSession();
}
public static void Delete(HistoryItem item)
+28 -14
View File
@@ -34,7 +34,7 @@ namespace FoxTube
public static class Methods
{
private static readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Methods");
public static CommentsPage CommentsPage { get; set; }
public static MainPage MainPage => (Window.Current.Content as Frame).Content as MainPage;
@@ -241,7 +241,7 @@ namespace FoxTube
return "Unknown";
}
}
public async static void ProcessLink(string url)
{
string type;
@@ -304,29 +304,43 @@ namespace FoxTube
public static async Task<List<string>> GetHistory()
{
SecretsVault.RefreshToken();
List<string> list = new List<string>();
string output = await SecretsVault.HttpClient.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=HL&hl={SettingsStorage.RelevanceLanguage}");
try
{
SecretsVault.RefreshToken();
dynamic raw = JsonConvert.DeserializeObject(output);
foreach (dynamic i in raw.video)
list.Add(i.encrypted_id.ToString());
string output = await SecretsVault.HttpClient.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=HL&hl={SettingsStorage.RelevanceLanguage}");
dynamic raw = JsonConvert.DeserializeObject(output);
foreach (dynamic i in raw.video)
list.Add(i.encrypted_id.ToString());
}
catch
{
}
return list;
}
public static async Task<List<string>> GetLater()
{
SecretsVault.RefreshToken();
List<string> list = new List<string>();
string output = await SecretsVault.HttpClient.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=WL&hl={SettingsStorage.RelevanceLanguage}");
try
{
SecretsVault.RefreshToken();
dynamic raw = JsonConvert.DeserializeObject(output);
foreach (dynamic i in raw.video)
list.Add(i.encrypted_id.ToString());
string output = await SecretsVault.HttpClient.GetStringAsync($"https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=WL&hl={SettingsStorage.RelevanceLanguage}");
dynamic raw = JsonConvert.DeserializeObject(output);
foreach (dynamic i in raw.video)
list.Add(i.encrypted_id.ToString());
}
catch
{
}
return list;
}
}
+19 -6
View File
@@ -15,6 +15,7 @@ using Google.Apis.Oauth2.v2;
using static Google.Apis.Auth.OAuth2.UwpCodeReceiver;
using Microsoft.AppCenter.Analytics;
using System.Net;
using Google.Apis.Auth.OAuth2.Responses;
namespace FoxTube
{
@@ -30,12 +31,12 @@ namespace FoxTube
public static NetworkCredential EmailCredential => new NetworkCredential("mikhailagord@gmail.com", "JkY39w$.7?bT57O,8k3a");
private static ClientSecrets Secrets => new ClientSecrets
{
ClientId = "349735264870-2ekqlm0a4mkg3mmrfcv90s3qp3o15dq0.apps.googleusercontent.com",
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
ClientId = "1096685398208-rsabgv4dfkopr3c7p27p61pkcans012g.apps.googleusercontent.com",
ClientSecret = "EtX5VkCwrl7EZsFM2Dt7Jzpd"
};
private static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer
{
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
ApiKey = "AIzaSyD7tpbuvmYDv9h4udo9L_g3r0sLPFAnN00",
ApplicationName = "FoxTube"
});
public static BaseClientService.Initializer Initializer => new BaseClientService.Initializer
@@ -150,6 +151,16 @@ namespace FoxTube
await Credential.RefreshTokenAsync(CancellationToken.None);
}
catch (TokenResponseException e)
{
AuthorizationStateChanged?.Invoke(args: new bool?[] { null });
Analytics.TrackEvent("Failed to authorize", new Dictionary<string, string>
{
{ "Exception", e.GetType().ToString() },
{ "Message", e.Message },
{ "StackTrace", e.StackTrace }
});
}
catch (AuthenticateException e)
{
if (e.Message.Contains("UserCancel"))
@@ -212,10 +223,12 @@ namespace FoxTube
}
catch (Exception e)
{
Deauthenticate();
AuthorizationStateChanged?.Invoke(args: new bool?[] { null });
Methods.SendMail($@"Exception: {e.GetType()}
/*Methods.SendMail($@"Exception: {e.GetType()}
Message: {e.Message}
Stack trace: {e.StackTrace}");
Stack trace: {e.StackTrace}");*/
Analytics.TrackEvent("Failed to retrieve user's info", new Dictionary<string, string>
{
{ "Exception", e.GetType().ToString() },
@@ -269,7 +282,7 @@ Stack trace: {e.StackTrace}");
{
if (!await Credential.RevokeTokenAsync(CancellationToken.None))
return;
Credential = null;
UserChannel = null;
UserInfo = null;
+1 -1
View File
@@ -203,7 +203,7 @@ namespace FoxTube
}
set
{
storage.Values["mature"] = value;
storage.Values["mature"] = (int)value;
}
}
+18 -4
View File
@@ -156,7 +156,7 @@ namespace FoxTube
if (queue.Count > 0)
foreach (Action i in queue)
i();
base.OnApplyTemplate();
}
@@ -214,6 +214,7 @@ namespace FoxTube
private async void Quality_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//return;
if (Meta.Snippet.LiveBroadcastContent == "live")
goto SetQuality;
if(!needUpdateTimecode)
@@ -222,12 +223,13 @@ namespace FoxTube
Player.Pause();
Player.Source = null;
SetQuality:
SetQuality:
object info = (quality.SelectedItem as ComboBoxItem).Tag;
if (info is MuxedStreamInfo)
Player.SetPlaybackSource(MediaSource.CreateFromUri((info as MuxedStreamInfo).Url.ToUri()));
else if (info is VideoStreamInfo || info == null)
Player.SetPlaybackSource(MediaSource.CreateFromUri(await ManifestGenerator.GetManifest(Meta, info as VideoStreamInfo, MediaStreams)));
return;
//Player.SetPlaybackSource(MediaSource.CreateFromUri(await ManifestGenerator.GetManifest(Meta, info as VideoStreamInfo, MediaStreams)));
else if (info is StreamQuality)
Player.SetPlaybackSource(MediaSource.CreateFromUri((info as StreamQuality).Url));
}
@@ -427,7 +429,19 @@ namespace FoxTube
title.Text = meta.Snippet.Title;
channel.Text = meta.Snippet.ChannelTitle;
MediaStreams = await new YoutubeClient().GetVideoMediaStreamInfosAsync(meta.Id);
try
{
MediaStreams = await new YoutubeClient().GetVideoMediaStreamInfosAsync(meta.Id);
}
catch
{
await new ContentDialog
{
Title = "Failed to load video",
PrimaryButtonText = "Ok"
}.ShowAsync();
return;
}
if (meta.Snippet.LiveBroadcastContent == "none")
{
+4 -4
View File
@@ -54,7 +54,7 @@ namespace FoxTube
videoSource.Markers.Add(new TimelineMarker { Time = TimeSpan.FromMinutes(k * 30) });
if (!privateMode)
HistorySet.Update(history);
HistorySet.Update(history, item);
}
else if (item.Snippet.LiveBroadcastContent == "live")
{
@@ -130,11 +130,11 @@ namespace FoxTube
videoSource.Pause();
systemControls.IsEnabled = false;
videoSource.Source = null;
if (!incognito && item.Snippet.LiveBroadcastContent == "none")
{
history.LeftOn = videoSource.Position;
HistorySet.Update(history);
HistorySet.Update(history, item);
}
Methods.MainPage.CloseVideo();
@@ -153,7 +153,7 @@ namespace FoxTube
if (!incognito && item.Snippet.LiveBroadcastContent == "none")
{
history.LeftOn = videoSource.Position;
HistorySet.Update(history);
HistorySet.Update(history, item);
}
}
+9 -9
View File
@@ -11,8 +11,8 @@
<AssemblyName>FoxTube</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17134.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@@ -432,7 +432,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AngleSharp">
<Version>0.12.1</Version>
<Version>0.14.0</Version>
</PackageReference>
<PackageReference Include="Google.Apis">
<Version>1.30.0-beta02</Version>
@@ -453,22 +453,22 @@
<Version>10.1811.22001</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Analytics">
<Version>2.1.1</Version>
<Version>3.2.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.8</Version>
<Version>6.2.10</Version>
</PackageReference>
<PackageReference Include="Microsoft.Services.Store.Engagement">
<Version>10.1901.28001</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
<Version>5.1.1</Version>
<Version>6.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>5.1.1</Version>
<Version>6.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.0.181011001</Version>
<Version>2.4.2</Version>
</PackageReference>
<PackageReference Include="runtime.win10-arm64.runtime.native.System.IO.Compression">
<Version>4.3.2</Version>
@@ -477,7 +477,7 @@
<Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="YoutubeExplode">
<Version>4.7.6</Version>
<Version>4.7.16</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
+2 -2
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="#282828">
<uap:VisualElements DisplayName="FoxTube" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="YouTube Client for Windows 10" BackgroundColor="#404040">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" ShortName="FoxTube" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
@@ -23,7 +23,7 @@
<uap:ShowOn Tile="square310x310Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#282828" />
<uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#404040" />
<uap:LockScreen Notification="badgeAndTileText" BadgeLogo="Assets\BadgeLogo.png"/>
</uap:VisualElements>
<Extensions>
+64 -54
View File
@@ -8,6 +8,23 @@
xmlns:ui="using:Microsoft.UI.Xaml.Controls"
xmlns:controls="using:FoxTube.Controls">
<Page.Resources>
<Style x:Key="HeaderActionButton" TargetType="Button" BasedOn="{StaticResource ButtonRevealStyle}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Height" Value="32" />
<Setter Property="Width" Value="40" />
<Setter Property="Padding" Value="0" />
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
<Setter Property="FontSize" Value="15" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</Page.Resources>
<Grid Name="grid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
@@ -22,70 +39,63 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="AppTitleBar"
<Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="40,0,0,0" Width="40" Height="40" Padding="0" FontFamily="Segoe MDL2 Assets" Content="&#xE700;" Canvas.ZIndex="2" Background="Transparent" CornerRadius="0" Click="PaneToggle"/>
<Border x:Name="AppTitleBar"
Margin="80,0,500,0"
Height="40"
IsHitTestVisible="True"
VerticalAlignment="Top"
Background="Transparent"
Canvas.ZIndex="1">
<TextBlock x:Name="AppTitle"
Text="FoxTube"
Text="FoxTube (v2.0 Preview 1)"
VerticalAlignment="Center"
Margin="12, 8, 0, 0"
Margin="12,0"
Style="{StaticResource CaptionTextBlockStyle}" />
</Border>
<ui:NavigationView SelectedItem="toHome" BackRequested="Nav_BackRequested" PaneClosing="Nav_PaneClosing" PaneOpened="Nav_PaneOpened" OpenPaneLength="300" Name="nav" SelectionChanged="Nav_SelectionChanged">
<ui:NavigationView.Header>
<Grid>
<TextBlock Name="Title" Style="{StaticResource TitleTextBlockStyle}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Uid="/Main/feedback" Name="feedback" Click="Feedback_Click" Visibility="Collapsed" FontFamily="Segoe MDL2 Assets" Content="&#xED15;" Background="Transparent" Height="41" Width="60" FontSize="15"/>
<Button x:Uid="/Main/signIn" Name="account" Click="SignIn_Click" Visibility="Collapsed" FontFamily="Segoe MDL2 Assets" Content="&#xE8FA;" Background="Transparent" Height="41" Width="60" FontSize="15"/>
<Button Background="Transparent" Visibility="Collapsed" Name="avatar" Height="41" Width="60" FontSize="15" Padding="0">
<Button.Flyout>
<Flyout>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Width="65" 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>
</Button.Flyout>
<Ellipse Width="25" Height="25">
<Ellipse.Fill>
<ImageBrush ImageSource="/Assets/Icons/profile.png"/>
</Ellipse.Fill>
</Ellipse>
</Button>
</StackPanel>
</Grid>
</ui:NavigationView.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,350,0">
<Button Style="{StaticResource HeaderActionButton}" x:Uid="/Main/feedback" Name="feedback" Click="Feedback_Click" Visibility="Visible" FontFamily="Segoe MDL2 Assets" Content="&#xED15;"/>
<Button Style="{StaticResource HeaderActionButton}" x:Uid="/Main/signIn" Name="account" Click="SignIn_Click" Visibility="Collapsed" FontFamily="Segoe MDL2 Assets" Content="&#xE8FA;" />
<Button Style="{StaticResource HeaderActionButton}" Background="Transparent" Visibility="Collapsed" Name="avatar" Padding="0">
<Button.Flyout>
<Flyout>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Width="65" 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"/>
<ToggleSwitch OnContent="Incognito mode" OffContent="Incognito mode" Toggled="IncognitoToggle"/>
</StackPanel>
</Grid>
</Flyout>
</Button.Flyout>
<Ellipse Width="25" Height="25">
<Ellipse.Fill>
<ImageBrush ImageSource="/Assets/Icons/profile.png"/>
</Ellipse.Fill>
</Ellipse>
</Button>
</StackPanel>
<ui:NavigationView.MenuItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Padding="5" Margin="-5,0,0,0" Tag="{Binding Snippet.ResourceId.ChannelId}">
<PersonPicture Height="20" Margin="-5,0,15,0">
<PersonPicture.ProfilePicture>
<BitmapImage UriSource="{Binding Snippet.Thumbnails.Medium.Url}" DecodePixelHeight="20" DecodePixelWidth="20"/>
</PersonPicture.ProfilePicture>
</PersonPicture>
<TextBlock FontSize="14" Text="{Binding Snippet.Title}"/>
</StackPanel>
</DataTemplate>
</ui:NavigationView.MenuItemTemplate>
<ui:NavigationView IsTitleBarAutoPaddingEnabled="False" IsPaneToggleButtonVisible="False" SelectedItem="toHome" BackRequested="Nav_BackRequested" PaneClosing="Nav_PaneClosing" PaneOpened="Nav_PaneOpened" OpenPaneLength="350" Name="nav" SelectionChanged="Nav_SelectionChanged">
<ui:NavigationView.Header>
<Grid Visibility="Collapsed">
<TextBlock Name="Title" Style="{StaticResource TitleTextBlockStyle}"/>
</Grid>
</ui:NavigationView.Header>
<ui:NavigationView.MenuItems>
<ui:NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/>
<ui:NavigationView.MenuItems>
<ui:NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/>
<ui:NavigationViewItem x:Uid="/Main/myChannel" Icon="Contact" Content="My channel" Name="toChannel" Visibility="Collapsed"/>
<ui:NavigationViewItem x:Uid="/Main/subscriptions" Icon="People" Content="Subscriptions" Name="toSubscriptions" Visibility="Collapsed"/>
<!--<ui:NavigationViewItem x:Uid="/Main/subscriptions" Icon="People" Content="Subscriptions" Name="toSubscriptions" Visibility="Collapsed"/>-->
<ui:NavigationViewItemHeader x:Uid="/Main/myLibrary" FontSize="14" Content="My library" Name="libHeader" Visibility="Collapsed"/>
<ui:NavigationViewItem x:Uid="/Main/history" Content="History" Name="toHistory" Visibility="Collapsed">
<ui:NavigationViewItem.Icon>
@@ -95,8 +105,8 @@
<ui:NavigationViewItem x:Uid="/Main/liked" Icon="Like" Content="Liked videos" Name="toLiked" Visibility="Collapsed"/>
<ui:NavigationViewItem x:Uid="/Main/later" Icon="Clock" Content="Watch later" Name="toLater" Visibility="Collapsed"/>
<ui:NavigationViewItem x:Uid="/Main/downloads" Icon="Download" Content="Downloads" Name="toDownloads"/>
<ui:NavigationViewItemHeader x:Uid="/Main/subscriptions" FontSize="14" Content="Subscriptions" Name="subsHeader" Visibility="Collapsed"/>
</ui:NavigationView.MenuItems>
<ui:NavigationViewItem x:Uid="/Main/subscriptions" Icon="People" FontSize="14" Content="Subscriptions" Name="subsHeader" Visibility="Collapsed"/>
</ui:NavigationView.MenuItems>
<ui:NavigationView.PaneFooter>
<ui:NavigationViewItem Content="Remove ads" Visibility="Collapsed" Tapped="RemoveAds_Tapped" Name="removeAds">
@@ -110,7 +120,7 @@
<AutoSuggestBox x:Name="search" QueryIcon="Find" QuerySubmitted="Search_QuerySubmitted" TextChanged="Search_TextChanged" x:Uid="/Main/searchPlaceholder" PlaceholderText="Search"/>
</ui:NavigationView.AutoSuggestBox>
<Grid>
<Grid Margin="0,-24,0,0">
<controls:ContentFrame x:Name="content" Navigated="Content_Navigated"/>
<controls:ContentFrame x:Name="videoPlaceholder"/>
</Grid>
+65 -20
View File
@@ -206,7 +206,7 @@ namespace FoxTube
}
var titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonHoverBackgroundColor = Colors.IndianRed;
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
@@ -218,27 +218,27 @@ namespace FoxTube
else
titleBar.ButtonForegroundColor = Colors.Black;
}
private void SecretsVault_SubscriptionsChanged(object sender, params object[] args)
{
switch((string)args[0])
{
case "add":
if (nav.MenuItems.Count < 19)
nav.MenuItems.Add(args[1] as Subscription);
if (subsHeader.MenuItems.Count < 10)
subsHeader.MenuItems.Add(GetFromSubscription(args[1] as Subscription));
break;
case "remove":
if(nav.MenuItems.Contains((Subscription)args[1]))
if(subsHeader.MenuItems.Contains((Subscription)args[1]))
{
nav.MenuItems.Remove(args[1]);
if (SecretsVault.Subscriptions.Count >= 10)
nav.MenuItems.Add(SecretsVault.Subscriptions[9]);
subsHeader.MenuItems.Remove(args[1]);
//if (SecretsVault.Subscriptions.Count >= 10)
// nav.MenuItems.Add(SecretsVault.Subscriptions[9]);
}
break;
}
}
private async void AuthorizationStateChanged(object sender, params object[] e)
{
wasInvoked = false;
@@ -257,7 +257,7 @@ namespace FoxTube
avatar.Visibility = Visibility.Visible;
toChannel.Visibility = Visibility.Visible;
toSubscriptions.Visibility = Visibility.Visible;
//toSubscriptions.Visibility = Visibility.Visible;
libHeader.Visibility = Visibility.Visible;
toHistory.Visibility = Visibility.Visible;
toLiked.Visibility = Visibility.Visible;
@@ -267,7 +267,7 @@ namespace FoxTube
{
subsHeader.Visibility = Visibility.Visible;
for (int k = 0; k < SecretsVault.Subscriptions.Count && k < 10; k++)
nav.MenuItems.Add(SecretsVault.Subscriptions[k]);
subsHeader.MenuItems.Add(GetFromSubscription(SecretsVault.Subscriptions[k]));
}
HistorySet.Load();
@@ -280,14 +280,15 @@ namespace FoxTube
case false:
content.Frame.Navigate(typeof(Home));
for (int k = nav.MenuItems.Count - 1; k > 8; k--)
nav.MenuItems.RemoveAt(k);
subsHeader.MenuItems.Clear();
//for (int k = nav.MenuItems.Count - 1; k > 8; k--)
// nav.MenuItems.RemoveAt(k);
account.Visibility = Visibility.Visible;
avatar.Visibility = Visibility.Collapsed;
toChannel.Visibility = Visibility.Collapsed;
toSubscriptions.Visibility = Visibility.Collapsed;
//toSubscriptions.Visibility = Visibility.Collapsed;
libHeader.Visibility = Visibility.Collapsed;
toHistory.Visibility = Visibility.Collapsed;
toLiked.Visibility = Visibility.Collapsed;
@@ -330,6 +331,35 @@ namespace FoxTube
DownloadAgent.Initialize();
}
public Microsoft.UI.Xaml.Controls.NavigationViewItem GetFromSubscription(Subscription subscription)
{
Grid grid = new Grid
{
ColumnSpacing = 12
};
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(20) });
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.Children.Add(new Microsoft.UI.Xaml.Controls.PersonPicture
{
Width = 20,
ProfilePicture = new BitmapImage(subscription.Snippet.Thumbnails.Default__.Url.ToUri()) { DecodePixelHeight = 20, DecodePixelWidth = 20 }
});
grid.Children.Add(new TextBlock
{
Text = subscription.Snippet.Title
});
Grid.SetColumn(grid.Children[1] as TextBlock, 1);
return new Microsoft.UI.Xaml.Controls.NavigationViewItem
{
Content = grid,
Tag = subscription.Snippet.ChannelId
};
}
private async void Feedback_Click(object sender, RoutedEventArgs e)
{
await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();
@@ -525,7 +555,7 @@ namespace FoxTube
if (e.SourcePageType == typeof(Settings))
SetNavigationItem(nav.SettingsItem);
else if (e.SourcePageType == typeof(Subscriptions))
SetNavigationItem(toSubscriptions);
SetNavigationItem(subsHeader);
else if (e.SourcePageType == typeof(Downloads))
SetNavigationItem(toDownloads);
else if (e.SourcePageType == typeof(Home))
@@ -538,8 +568,8 @@ namespace FoxTube
{
if (e.Parameter.ToString() == SecretsVault.AccountId)
SetNavigationItem(toChannel);
else if (nav.MenuItems.Contains(SecretsVault.Subscriptions.Find(i => i.Snippet.ResourceId.ChannelId == e.Parameter.ToString())))
SetNavigationItem(SecretsVault.Subscriptions.Find(i => i.Snippet.ResourceId.ChannelId == e.Parameter.ToString()));
else if (subsHeader.MenuItems.Find(i => SecretsVault.Subscriptions.Any(s => (i as Microsoft.UI.Xaml.Controls.NavigationViewItem).Tag.Equals(s.Snippet.ChannelId))) is object item)
SetNavigationItem(item);
else
SetNavigationItem(null);
}
@@ -596,14 +626,14 @@ namespace FoxTube
content.Frame.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes);
else if (args.SelectedItem == toLater)
content.Frame.Navigate(typeof(PlaylistPage), "WL");
else if (args.SelectedItem == toSubscriptions)
else if (args.SelectedItem == subsHeader)
content.Frame.Navigate(typeof(Subscriptions));
else if (args.SelectedItem == toDownloads)
content.Frame.Navigate(typeof(Downloads));
else if (args.SelectedItem == toChannel)
content.Frame.Navigate(typeof(ChannelPage), SecretsVault.UserChannel.Id);
else
content.Frame.Navigate(typeof(ChannelPage), (args.SelectedItem as Subscription).Snippet.ResourceId.ChannelId);
content.Frame.Navigate(typeof(ChannelPage), (args.SelectedItem as FrameworkElement).Tag as string);
}
}
else
@@ -634,5 +664,20 @@ namespace FoxTube
{
AppTitle.Visibility = Visibility.Visible;
}
}
private void PaneToggle(object sender, RoutedEventArgs e)
{
nav.IsPaneOpen = !nav.IsPaneOpen;
}
ElementTheme savedTheme;
private void IncognitoToggle(object sender, RoutedEventArgs e)
{
savedTheme = RequestedTheme;
if ((sender as ToggleSwitch).IsOn)
RequestedTheme = ElementTheme.Dark;
else
RequestedTheme = savedTheme;
}
}
}