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