Archived
1
0

Video cards fixes. Localization fixes. CardAdvert created

Related Work Items: #244, #245
This commit is contained in:
Michael Gordeev
2019-01-07 23:51:49 +03:00
parent 3a1f5d418f
commit d11d529768
11 changed files with 72 additions and 49 deletions
@@ -131,11 +131,6 @@
<Version>6.1.5</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Net.WebClient">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.netcore.universalwindowsplatform\6.1.5\ref\uap10.0.15138\System.Net.WebClient.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
-12
View File
@@ -36,18 +36,6 @@ namespace FoxTube
get { return (Window.Current.Content as Frame).Content as MainPage; }
}
public static CardAdvert CardAdvert { get; private set; }
public static void InitializeAds()
{
NativeAdsManagerV2 manager = new NativeAdsManagerV2(SecretsVault.AppId, SecretsVault.AdUnitId);
manager.AdReady += (s, e) =>
{
card = new CardAdvert(e.NativeAd);
e.NativeAd.RegisterAdContainer(card);
};
}
public static void CloseApp()
{
CoreApplication.Exit();
+34 -11
View File
@@ -2,13 +2,13 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using FoxTube.Controls.Adverts;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using Newtonsoft.Json;
using Windows.Storage;
using Windows.Services.Store;
namespace FoxTube
{
@@ -18,7 +18,7 @@ namespace FoxTube
//Events
public static event ObjectEventHandler AuthorizationStateChanged;
public static event ObjectEventHandler SubscriptionsChanged;
public static event Event NotPurchased; //Rising when app finds out that it's not a PRO version
public static event ObjectEventHandler Purchased; //Rising when app finds out that it's not a PRO version
//Private properties
private static ClientSecrets Secrets => new ClientSecrets()
@@ -37,8 +37,8 @@ namespace FoxTube
ApplicationName = "FoxTube"
};
public static YouTubeService Service => IsAuthorized ? new YouTubeService(Initializer) : NoAuthService;
public static string AppId => "d25517cb-12d4-4699-8bdc-52040c712cab";
public static string AdUnitId => "test";
public static string AppId => true ? "d25517cb-12d4-4699-8bdc-52040c712cab" : "9ncqqxjtdlfh";
public static string AdUnitId => true ? "test" : "1100037769";
public static bool AdsDisabled { get; private set; } = true;
//User info
@@ -196,15 +196,38 @@ namespace FoxTube
/// <summary>
/// Connects to MS Store and checks if user has bought ad-free
/// </summary>
public static void CheckAddons()
public static async void CheckAddons()
{
//TODO: Check addons list
bool purchased = true;
if(!purchased)
try
{
AdsDisabled = false;
NotPurchased?.Invoke();
StoreContext store = StoreContext.GetDefault();
StoreProductQueryResult requset = await store.GetAssociatedStoreProductsAsync(new[] { "Consumable", "Durable", "UnmanagedConsumable" });
if (!requset.Products["foxtube-adsremove"].IsInUserCollection)
{
AdsDisabled = false;
Purchased?.Invoke(args:false);
}
}
catch { }
}
public static async void GetAdblock()
{
StoreContext store = StoreContext.GetDefault();
StorePurchaseResult request = await store.RequestPurchaseAsync("foxtube-adsremove");
switch (request.Status)
{
case StorePurchaseStatus.AlreadyPurchased:
Purchased?.Invoke(args: true);
AdsDisabled = true;
break;
case StorePurchaseStatus.Succeeded:
Purchased?.Invoke(args: true);
AdsDisabled = true;
break;
}
}
#endregion
+1 -1
View File
@@ -36,7 +36,7 @@ namespace FoxTube.Controls
Visibility = Visibility.Visible;
else
Visibility = Visibility.Collapsed;
SecretsVault.NotPurchased += () => Visibility = Visibility.Visible;
SecretsVault.Purchased += (s, e) => Visibility = (bool)e[0] ? Visibility.Collapsed : Visibility.Visible;
}
private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
+13 -4
View File
@@ -3,7 +3,6 @@ using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.Advertising.WinRT.UI;
using Windows.UI.Xaml.Media.Imaging;
using System.Diagnostics;
namespace FoxTube.Controls.Adverts
{
@@ -12,12 +11,20 @@ namespace FoxTube.Controls.Adverts
/// </summary>
public sealed partial class CardAdvert : UserControl
{
NativeAdV2 advert;
public CardAdvert(NativeAdV2 ad)
NativeAdsManagerV2 manager = new NativeAdsManagerV2(SecretsVault.AppId, SecretsVault.AdUnitId);
public NativeAdV2 advert;
public CardAdvert()
{
InitializeComponent();
advert = ad;
manager.AdReady += AdReady;
manager.RequestAd();
}
private void AdReady(object sender, NativeAdReadyEventArgs e)
{
advert = e.NativeAd;
Initialize();
e.NativeAd.RegisterAdContainer(this);
}
public void Initialize()
@@ -43,6 +50,8 @@ namespace FoxTube.Controls.Adverts
desc.Text = advert.CallToActionText;
else
desc.Text = advert.Price;
Visibility = Visibility.Visible;
}
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
+1 -1
View File
@@ -36,7 +36,7 @@
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem x:Uid="/Main/adsFree" Content="Remove ads" Visibility="Collapsed" Name="removeAds">
<NavigationViewItem x:Uid="/Main/adsFree" Content="Remove ads" Visibility="Collapsed" Tapped="RemoveAds_Tapped" Name="removeAds">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE14D;"/>
</NavigationViewItem.Icon>
+12 -3
View File
@@ -41,10 +41,14 @@ namespace FoxTube
InitializeComponent();
CheckVersion();
SecretsVault.AuthorizationStateChanged += AuthorizationStateChanged;
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
SecretsVault.NotPurchased += () => removeAds.Visibility = Visibility.Visible;
SecretsVault.Purchased += (sender, e) =>
{
removeAds.Visibility = (e[0] as bool?).Value ? Visibility.Collapsed : Visibility.Visible;
content.Navigate(typeof(Home));
};
SecretsVault.CheckAuthorization();
SecretsVault.CheckAddons();
@@ -351,7 +355,7 @@ namespace FoxTube
if (videoPlaceholder.Content != null)
(videoPlaceholder.Content as VideoPage).player.close_Click(this, null);
videoPlaceholder.Content = null;
Fullscreen(false);
@@ -740,5 +744,10 @@ namespace FoxTube
{
((NavigationViewItem)sender).ContextFlyout.ShowAt((NavigationViewItem)sender);
}
private void RemoveAds_Tapped(object sender, TappedRoutedEventArgs e)
{
SecretsVault.GetAdblock();
}
}
}
+3 -2
View File
@@ -1,6 +1,7 @@
using FoxTube.Controls.Adverts;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FoxTube.Pages
{
@@ -17,8 +18,8 @@ namespace FoxTube.Pages
public void Add(UIElement card)
{
list.Items.Add(card);
if (list.Items.Count % 5 == 0)
list.Items.Add(new CardAdvert());
/*if (list.Items.Count % 10 == 0)
list.Items.Add(new CardAdvert());*/
empty.Visibility = Visibility.Collapsed;
}
+1
View File
@@ -1,4 +1,5 @@
using FoxTube.Controls;
using FoxTube.Controls.Adverts;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using System;
+4 -1
View File
@@ -151,7 +151,7 @@
<value>Liked videos</value>
</data>
<data name="metered" xml:space="preserve">
<value>"You are on metered connection now. Additional charges may apply. Do you want to continue?"</value>
<value>You are on metered connection now. Additional charges may apply. Do you want to continue?</value>
</data>
<data name="myChannel.Content" xml:space="preserve">
<value>My channel</value>
@@ -180,6 +180,9 @@
<data name="signEx.Text" xml:space="preserve">
<value>Sign in with existing account</value>
</data>
<data name="signIn.Content" xml:space="preserve">
<value>Add account</value>
</data>
<data name="signNew.Text" xml:space="preserve">
<value>Create new Google account</value>
</data>
+3 -9
View File
@@ -151,10 +151,7 @@
<value>Понравившиеся</value>
</data>
<data name="metered" xml:space="preserve">
<value>"You are on metered connection now. Additional charges may apply. Do you want to continue?"</value>
</data>
<data name="myAccount.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Мой аккаунт</value>
<value>Передача данных в этой сети ограничена. Может взиматься дополнительная плата. Вы хотите продолжить?</value>
</data>
<data name="myChannel.Content" xml:space="preserve">
<value>Мой канал</value>
@@ -168,9 +165,6 @@
<data name="no" xml:space="preserve">
<value>Нет</value>
</data>
<data name="notifications.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Уведомления</value>
</data>
<data name="playlist" xml:space="preserve">
<value>Плейлист</value>
</data>
@@ -186,8 +180,8 @@
<data name="signEx.Text" xml:space="preserve">
<value>Войти с помощью существующего аккаунта Google</value>
</data>
<data name="signIn.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Войти</value>
<data name="signIn.Content" xml:space="preserve">
<value>Войти в аккаунт</value>
</data>
<data name="signNew.Text" xml:space="preserve">
<value>Создать новый аккаунт Google</value>