Fixed adverts compiling, authorization and failsafe protocol
This commit is contained in:
@@ -130,6 +130,7 @@
|
|||||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Helpers\Constants.cs" />
|
||||||
<Compile Include="Helpers\Extensions.cs" />
|
<Compile Include="Helpers\Extensions.cs" />
|
||||||
<Compile Include="Helpers\Feedback.cs" />
|
<Compile Include="Helpers\Feedback.cs" />
|
||||||
<Compile Include="Helpers\Inbox.cs" />
|
<Compile Include="Helpers\Inbox.cs" />
|
||||||
@@ -154,7 +155,7 @@
|
|||||||
<Version>0.13.0</Version>
|
<Version>0.13.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="ExtendedYouTubeAPI">
|
<PackageReference Include="ExtendedYouTubeAPI">
|
||||||
<Version>1.0.1</Version>
|
<Version>1.0.2</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Google.Apis.Auth">
|
<PackageReference Include="Google.Apis.Auth">
|
||||||
<Version>1.42.0</Version>
|
<Version>1.42.0</Version>
|
||||||
@@ -189,11 +190,6 @@
|
|||||||
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
|
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
|
||||||
</SDKReference>
|
</SDKReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.Advertising">
|
|
||||||
<HintPath>..\..\..\..\NuGet\microsoft.advertising.xaml\10.1811.22001\SDK\Windows Kits\10\ExtensionSDKs\Microsoft.Advertising.Xaml\10.0\References\CommonConfiguration\neutral\Microsoft.Advertising.winmd</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace FoxTube.Core.Helpers
|
||||||
|
{
|
||||||
|
public static class Constants
|
||||||
|
{
|
||||||
|
public static string ApplicationId => "9ncqqxjtdlfh";
|
||||||
|
public static string AdsId => "1100044398";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,10 @@ using FoxTube.Core.Models;
|
|||||||
using YouTube;
|
using YouTube;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Google.Apis.YouTube.v3;
|
using Google.Apis.YouTube.v3;
|
||||||
|
using System.Net.Http;
|
||||||
|
using Google.Apis.Auth.OAuth2.Responses;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Google.Apis.Auth.OAuth2.Flows;
|
||||||
|
|
||||||
namespace FoxTube
|
namespace FoxTube
|
||||||
{
|
{
|
||||||
@@ -41,15 +45,17 @@ namespace FoxTube
|
|||||||
|
|
||||||
public static async Task<bool> AddUser()
|
public static async Task<bool> AddUser()
|
||||||
{
|
{
|
||||||
Uri callbackUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
|
Uri requestString = AuthorizationHelpers.FormQueryString(ClientSecrets, Scopes);
|
||||||
Uri requestString = AuthorizationHelpers.FormQueryString(ClientSecrets, callbackUri, Scopes);
|
|
||||||
|
|
||||||
WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.UseTitle, requestString, AuthorizationHelpers.Endpoint);
|
WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.UseTitle, requestString, AuthorizationHelpers.Endpoint);
|
||||||
switch(result.ResponseStatus)
|
switch(result.ResponseStatus)
|
||||||
{
|
{
|
||||||
case WebAuthenticationStatus.Success:
|
case WebAuthenticationStatus.Success:
|
||||||
UserCredential credential = await AuthorizationHelpers.ExchangeToken(ClientSecrets, new Regex(@"(?<=code=).?\w+").Match(result.ResponseData).Value);
|
string successCode = new Regex(@"(?<=code=)(.*?)(?=&)").Match(result.ResponseData).Value;
|
||||||
|
|
||||||
|
UserCredential credential = await AuthorizationHelpers.ExchangeToken(ClientSecrets, successCode);
|
||||||
CurrentUser = new User(credential);
|
CurrentUser = new User(credential);
|
||||||
|
|
||||||
PasswordVault passwordVault = new PasswordVault();
|
PasswordVault passwordVault = new PasswordVault();
|
||||||
passwordVault.Add(new PasswordCredential("foxtube", CurrentUser.UserInfo.Id, credential.Token.RefreshToken));
|
passwordVault.Add(new PasswordCredential("foxtube", CurrentUser.UserInfo.Id, credential.Token.RefreshToken));
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Advertising.WinRT.UI;
|
using System;
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using Windows.ApplicationModel.Core;
|
using Windows.ApplicationModel.Core;
|
||||||
|
using Windows.Security.Credentials;
|
||||||
|
|
||||||
namespace FoxTube.Core.Helpers
|
namespace FoxTube.Core.Helpers
|
||||||
{
|
{
|
||||||
@@ -23,15 +24,17 @@ namespace FoxTube.Core.Helpers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args">Parameters which will be provided to new application instance</param>
|
/// <param name="args">Parameters which will be provided to new application instance</param>
|
||||||
public static async void RestartApp(string args) =>
|
public static async void RestartApp(string args) =>
|
||||||
await CoreApplication.RequestRestartAsync(args);
|
await CoreApplication.RequestRestartAsync(args ?? "");
|
||||||
|
|
||||||
public static void InitializeFailsafeProtocol()
|
public static void InitializeFailsafeProtocol()
|
||||||
{
|
{
|
||||||
Metrics.AddEvent("Failsafe protocol initiated");
|
Metrics.AddEvent("Failsafe protocol initiated");
|
||||||
Settings.ResetSettings();
|
Settings.ResetSettings();
|
||||||
|
PasswordVault passwordVault = new PasswordVault();
|
||||||
|
IReadOnlyList<PasswordCredential> credentialEntries = passwordVault.RetrieveAll();
|
||||||
|
foreach (PasswordCredential credential in credentialEntries)
|
||||||
|
passwordVault.Remove(credential);
|
||||||
RestartApp();
|
RestartApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NativeAdsManagerV2 AdManager => new NativeAdsManagerV2("9ncqqxjtdlfh", "1100044398");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,13 +149,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||||
<Version>6.2.8</Version>
|
<Version>6.2.9</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MSTest.TestAdapter">
|
<PackageReference Include="MSTest.TestAdapter">
|
||||||
<Version>1.4.0</Version>
|
<Version>2.0.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MSTest.TestFramework">
|
<PackageReference Include="MSTest.TestFramework">
|
||||||
<Version>1.4.0</Version>
|
<Version>2.0.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace FoxTube.Controls.Cards
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class AdvertCard : UserControl
|
public sealed partial class AdvertCard : UserControl
|
||||||
{
|
{
|
||||||
NativeAdsManagerV2 manager = Utils.AdManager;
|
NativeAdsManagerV2 manager = new NativeAdsManagerV2(Constants.ApplicationId, Constants.AdsId);
|
||||||
NativeAdV2 advert;
|
NativeAdV2 advert;
|
||||||
public AdvertCard()
|
public AdvertCard()
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ namespace FoxTube.Controls.Cards
|
|||||||
manager.RequestAd();
|
manager.RequestAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ErrorOccurred(object sender, NativeAdErrorEventArgs e)
|
void ErrorOccurred(object sender, NativeAdErrorEventArgs e)
|
||||||
{
|
{
|
||||||
(Parent as StaggeredPanel)?.Children.Remove(this);
|
(Parent as StaggeredPanel)?.Children.Remove(this);
|
||||||
Metrics.AddEvent("Error has occured while loading ad",
|
Metrics.AddEvent("Error has occured while loading ad",
|
||||||
@@ -30,7 +30,7 @@ namespace FoxTube.Controls.Cards
|
|||||||
("Request ID", e.RequestId));
|
("Request ID", e.RequestId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AdReady(object sender, NativeAdReadyEventArgs e)
|
void AdReady(object sender, NativeAdReadyEventArgs e)
|
||||||
{
|
{
|
||||||
advert = e.NativeAd;
|
advert = e.NativeAd;
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -74,64 +74,64 @@
|
|||||||
</ui:NavigationView.MenuItemTemplate>
|
</ui:NavigationView.MenuItemTemplate>
|
||||||
|
|
||||||
<ui:NavigationView.MenuItems>
|
<ui:NavigationView.MenuItems>
|
||||||
<ui:NavigationViewItem Icon="Home" Content="Home" Name="home"/>
|
<ui:NavigationViewItem Icon="Home" Content="Home" x:Name="home"/>
|
||||||
<ui:NavigationViewItem Content="Subscriptions" Name="subscriptions">
|
<ui:NavigationViewItem Content="Subscriptions" x:Name="subscriptions">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
|
|
||||||
<ui:NavigationViewItemHeader Content="Library" Name="libraryHeader"/>
|
<ui:NavigationViewItemHeader Content="Library" x:Name="libraryHeader"/>
|
||||||
|
|
||||||
<ui:NavigationViewItem Content="History" Name="history">
|
<ui:NavigationViewItem Content="History" x:Name="history">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Content="Liked videos" Name="liked">
|
<ui:NavigationViewItem Content="Liked videos" x:Name="liked">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Icon="Clock" Content="Watch later" Name="wl"/>
|
<ui:NavigationViewItem Icon="Clock" Content="Watch later" x:Name="wl"/>
|
||||||
<ui:NavigationViewItem Icon="Download" Content="Downloads" Name="download"/>
|
<ui:NavigationViewItem Icon="Download" Content="Downloads" x:Name="download"/>
|
||||||
|
|
||||||
<ui:NavigationViewItemHeader Content="Subscriptions" Name="subscriptionsHeader"/>
|
<ui:NavigationViewItemHeader Content="Subscriptions" x:Name="subscriptionsHeader"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ui:NavigationViewItemHeader Content="Best of YouTube" Name="categoriesHeader"/>
|
<ui:NavigationViewItemHeader Content="Best of YouTube" x:Name="categoriesHeader"/>
|
||||||
<ui:NavigationViewItem Content="Music" Name="music">
|
<ui:NavigationViewItem Content="Music" x:Name="music">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Content="Sports" Name="sports">
|
<ui:NavigationViewItem Content="Sports" x:Name="sports">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Content="Movies" Name="movies">
|
<ui:NavigationViewItem Content="Movies" x:Name="movies">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Content="News" Name="news">
|
<ui:NavigationViewItem Content="News" x:Name="news">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Content="Live" Name="live">
|
<ui:NavigationViewItem Content="Live" x:Name="live">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Content="Spotlight" Name="spotlight">
|
<ui:NavigationViewItem Content="Spotlight" x:Name="spotlight">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
<ui:NavigationViewItem Content="360° video" Name="vr">
|
<ui:NavigationViewItem Content="360° video" x:Name="vr">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
|
|||||||
Reference in New Issue
Block a user