Archived
1
0

Added CommentAdvert

Activated pro version validation
Leave feedback and account buttons were moved to header
This commit is contained in:
Michael Gordeev
2019-04-11 00:38:32 +03:00
parent 7cbbc59e16
commit b43ea6b8c4
12 changed files with 160 additions and 17 deletions
+2
View File
@@ -11,6 +11,7 @@
- Added support of April 2018 Update (Windows 10 build 17134) - Added support of April 2018 Update (Windows 10 build 17134)
- Added adverts - Added adverts
- Fixed header titles - Fixed header titles
- Some items were moved from menu to header
</en-US> </en-US>
<ru-RU>### Что нового: <ru-RU>### Что нового:
- Добавлено уведомление со списком изменений при первом запуске после обновления - Добавлено уведомление со списком изменений при первом запуске после обновления
@@ -21,6 +22,7 @@
- Добавлена поддержка Апрельского Обновления 2018 (Windows 10 сборка 17134) - Добавлена поддержка Апрельского Обновления 2018 (Windows 10 сборка 17134)
- Добавлена реклама - Добавлена реклама
- Исправлено изменение заголовков - Исправлено изменение заголовков
- Некоторые пункты меню перемещены в заголовок
</ru-RU> </ru-RU>
</content> </content>
</item> </item>
+2 -2
View File
@@ -110,9 +110,9 @@ namespace FoxTube
/// </summary> /// </summary>
public static void Initialize() public static void Initialize()
{ {
CheckAuthorization();
// TODO: Reactivate addons initialization // TODO: Reactivate addons initialization
//CheckAddons(); CheckAddons();
CheckAuthorization();
} }
/// <summary> /// <summary>
@@ -0,0 +1,27 @@
<UserControl
x:Class="FoxTube.Controls.Adverts.CommentAdvert"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
d:DesignWidth="400">
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Margin="5,30,5,5" Name="icon" Initials="&#xEC24;" FontFamily="Segoe MDL2 Assets" Height="50" VerticalAlignment="Top"/>
<StackPanel Grid.Column="1" Margin="5">
<Border HorizontalAlignment="Left" Background="Red" CornerRadius="5">
<TextBlock Text="Sponsored by" Foreground="White" TextWrapping="WrapWholeWords" FontSize="13" Margin="3,0,3,3"/>
</Border>
<TextBlock Name="meta" Text="" TextWrapping="WrapWholeWords" Foreground="Gray" FontSize="13"/>
<TextBlock Name="title" Text="Title" TextWrapping="WrapWholeWords" Style="{StaticResource SubtitleTextBlockStyle}"/>
<TextBlock Name="description" Text="Description" TextWrapping="WrapWholeWords"/>
<Button Name="cta" Content="CALL TO ACTION TEXT" Margin="0,5"/>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,53 @@
using Microsoft.Advertising.WinRT.UI;
using System.Collections.Generic;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace FoxTube.Controls.Adverts
{
/// <summary>
/// Advert which is looks similar to video comment
/// </summary>
public sealed partial class CommentAdvert : UserControl
{
NativeAdsManagerV2 manager = new NativeAdsManagerV2(SecretsVault.AppId, SecretsVault.AdUnitId);
public NativeAdV2 advert;
public CommentAdvert()
{
InitializeComponent();
manager.AdReady += AdReady;
manager.ErrorOccurred += ErrorOccurred;
manager.RequestAd();
}
private void ErrorOccurred(object sender, NativeAdErrorEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Error has occured while loading ad");
}
private void AdReady(object sender, NativeAdReadyEventArgs e)
{
advert = e.NativeAd;
Initialize();
if(cta.Visibility == Visibility.Collapsed)
e.NativeAd.RegisterAdContainer(this);
else
e.NativeAd.RegisterAdContainer(this, new List<FrameworkElement> { cta });
}
private void Initialize()
{
title.Text = advert.Title;
description.Text = advert.Description.GuardFromNull();
icon.ProfilePicture = advert.AdIcon == null ? null : advert.AdIcon.Source;
cta.Content = advert.CallToActionText.GuardFromNull();
cta.Visibility = advert.CallToActionText.IsNullOrWhiteSpace() ? Visibility.Collapsed : Visibility.Visible;
meta.Text += advert.Price;
meta.Text += " " + advert.Rating;
meta.Visibility = meta.Text.IsNullOrWhiteSpace() ? Visibility.Collapsed : Visibility.Visible;
}
}
}
+7
View File
@@ -113,6 +113,9 @@
<Compile Include="Controls\Adverts\CardAdvert.xaml.cs"> <Compile Include="Controls\Adverts\CardAdvert.xaml.cs">
<DependentUpon>CardAdvert.xaml</DependentUpon> <DependentUpon>CardAdvert.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\Adverts\CommentAdvert.xaml.cs">
<DependentUpon>CommentAdvert.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ChannelCard.xaml.cs"> <Compile Include="Controls\ChannelCard.xaml.cs">
<DependentUpon>ChannelCard.xaml</DependentUpon> <DependentUpon>ChannelCard.xaml</DependentUpon>
</Compile> </Compile>
@@ -282,6 +285,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Controls\Adverts\CommentAdvert.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\ChannelCard.xaml"> <Page Include="Controls\ChannelCard.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
+1
View File
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:FoxTube.Controls" xmlns:controls="using:FoxTube.Controls"
xmlns:adverts="using:FoxTube.Controls.Adverts"
mc:Ignorable="d" mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
+8
View File
@@ -51,8 +51,12 @@ namespace FoxTube.Pages
more.Visibility = Visibility.Collapsed; more.Visibility = Visibility.Collapsed;
foreach (CommentThread comment in response.Items) foreach (CommentThread comment in response.Items)
{
if ((placeholder.Children.Count - 5) % 20 == 0 && !SecretsVault.AdsDisabled)
placeholder.Children.Add(new Controls.Adverts.CommentAdvert());
placeholder.Children.Add(new CommentCard(comment)); placeholder.Children.Add(new CommentCard(comment));
} }
}
public void RemoveComment(CommentCard commentCard, string topCommentId = null) public void RemoveComment(CommentCard commentCard, string topCommentId = null)
{ {
@@ -156,7 +160,11 @@ namespace FoxTube.Pages
var response = await request.ExecuteAsync(); var response = await request.ExecuteAsync();
foreach (CommentThread comment in response.Items) foreach (CommentThread comment in response.Items)
{
if ((placeholder.Children.Count - 5) % 20 == 0 && !SecretsVault.AdsDisabled)
placeholder.Children.Add(new Controls.Adverts.CommentAdvert());
placeholder.Children.Add(new CommentCard(comment)); placeholder.Children.Add(new CommentCard(comment));
}
token = response.NextPageToken; token = response.NextPageToken;
more.Complete(); more.Complete();
+47 -5
View File
@@ -37,7 +37,49 @@
<ui:NavigationView FontSize="14" SelectedItem="toHome" BackRequested="Nav_BackRequested" PaneClosing="Nav_PaneClosing" PaneOpened="Nav_PaneOpened" OpenPaneLength="300" Name="nav" SelectionChanged="Nav_SelectionChanged"> <ui:NavigationView FontSize="14" SelectedItem="toHome" BackRequested="Nav_BackRequested" PaneClosing="Nav_PaneClosing" PaneOpened="Nav_PaneOpened" OpenPaneLength="300" Name="nav" SelectionChanged="Nav_SelectionChanged">
<ui:NavigationView.Header> <ui:NavigationView.Header>
<TextBlock Name="Title" Style="{StaticResource TitleTextBlockStyle}"/> <Grid>
<TextBlock Text="Home" 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>
<PersonPicture Width="25"/>
</Button>
</StackPanel>
<CommandBar HorizontalAlignment="Right" Background="Transparent" OverflowButtonVisibility="Collapsed" Visibility="Collapsed" Margin="100,0">
<AppBarButton Label="Leave feedback">
<AppBarButton.Icon>
<FontIcon Glyph="&#xED15;"/>
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton Label="Add account">
<AppBarButton.Icon>
<FontIcon Glyph="&#xE8FA;"/>
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton>
<AppBarButton.Content>
<PersonPicture/>
</AppBarButton.Content>
</AppBarButton>
</CommandBar>
</Grid>
</ui:NavigationView.Header> </ui:NavigationView.Header>
<ui:NavigationView.MenuItemTemplate> <ui:NavigationView.MenuItemTemplate>
@@ -78,11 +120,11 @@
</TransitionCollection> </TransitionCollection>
</ui:NavigationViewList.ItemContainerTransitions> </ui:NavigationViewList.ItemContainerTransitions>
<ui:NavigationViewItem Name="openWeb" Tapped="Web_Tapped" Icon="Globe" Content="Browser" Visibility="Collapsed"/> <ui:NavigationViewItem Name="openWeb" Tapped="Web_Tapped" Icon="Globe" Content="Browser" Visibility="Collapsed"/>
<ui:NavigationViewItem x:Uid="/Main/feedback" Name="feedback" Content="Give a feedback" Tapped="Feedback_Click" Visibility="Collapsed"> <!--<ui:NavigationViewItem x:Uid="/Main/feedback" Name="feedback" Content="Give a feedback" Tapped="Feedback_Click" Visibility="Collapsed">
<ui:NavigationViewItem.Icon> <ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xED15;"/> <FontIcon Glyph="&#xED15;"/>
</ui:NavigationViewItem.Icon> </ui:NavigationViewItem.Icon>
</ui:NavigationViewItem> </ui:NavigationViewItem>-->
<ui:NavigationViewItem x:Uid="/Main/adsFree" Content="Remove ads" Visibility="Collapsed" Tapped="RemoveAds_Tapped" Name="removeAds"> <ui:NavigationViewItem x:Uid="/Main/adsFree" Content="Remove ads" Visibility="Collapsed" Tapped="RemoveAds_Tapped" Name="removeAds">
<ui:NavigationViewItem.Icon> <ui:NavigationViewItem.Icon>
@@ -90,7 +132,7 @@
</ui:NavigationViewItem.Icon> </ui:NavigationViewItem.Icon>
</ui:NavigationViewItem> </ui:NavigationViewItem>
<ui:NavigationViewItem Name="account" x:Uid="/Main/signIn" Content="Add account" Tapped="SignIn_Click" Visibility="Collapsed"> <!--<ui:NavigationViewItem Name="account" x:Uid="/Main/signIn" Content="Add account" Tapped="SignIn_Click" Visibility="Collapsed">
<ui:NavigationViewItem.Icon> <ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE8FA;"/> <FontIcon Glyph="&#xE8FA;"/>
</ui:NavigationViewItem.Icon> </ui:NavigationViewItem.Icon>
@@ -118,7 +160,7 @@
</Grid> </Grid>
</Flyout> </Flyout>
</ui:NavigationViewItem.ContextFlyout> </ui:NavigationViewItem.ContextFlyout>
</ui:NavigationViewItem> </ui:NavigationViewItem>-->
</ui:NavigationViewList> </ui:NavigationViewList>
</ui:NavigationView.PaneFooter> </ui:NavigationView.PaneFooter>
+8 -5
View File
@@ -41,8 +41,10 @@ namespace FoxTube
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged; SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
SecretsVault.Purchased += async (sender, e) => SecretsVault.Purchased += async (sender, e) =>
{ {
//TODO: Localize strings
removeAds.Visibility = (e[0] as bool?).Value ? Visibility.Collapsed : Visibility.Visible; removeAds.Visibility = (e[0] as bool?).Value ? Visibility.Collapsed : Visibility.Visible;
if (!(bool)e[0])
return;
//TODO: Localize strings
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"); 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("Close the app", (command) => Methods.CloseApp()));
dialog.Commands.Add(new UICommand("Later")); dialog.Commands.Add(new UICommand("Later"));
@@ -174,10 +176,11 @@ namespace FoxTube
case true: case true:
account.Visibility = Visibility.Collapsed; account.Visibility = Visibility.Collapsed;
myName.Text = myNameFlyout.Text = SecretsVault.UserInfo.Name; ToolTipService.SetToolTip(avatar, $"{SecretsVault.UserInfo.Name} ({SecretsVault.UserInfo.Email})");
myNameFlyout.Text = SecretsVault.UserInfo.Name;
myEmail.Text = SecretsVault.UserInfo.Email; myEmail.Text = SecretsVault.UserInfo.Email;
avatarFlyout.ProfilePicture = new BitmapImage(SecretsVault.UserInfo.Picture.ToUri()); avatarFlyout.ProfilePicture = new BitmapImage(SecretsVault.UserInfo.Picture.ToUri());
((avatar.Content as StackPanel).Children[0] as PersonPicture).ProfilePicture = avatarFlyout.ProfilePicture; (avatar.Content as PersonPicture).ProfilePicture = avatarFlyout.ProfilePicture;
avatar.Visibility = Visibility.Visible; avatar.Visibility = Visibility.Visible;
@@ -247,12 +250,12 @@ namespace FoxTube
GoToVideo((videoPlaceholder.Content as VideoPage).videoId, (videoPlaceholder.Content as VideoPage).playlistId); GoToVideo((videoPlaceholder.Content as VideoPage).videoId, (videoPlaceholder.Content as VideoPage).playlistId);
} }
private async void Feedback_Click(object sender, TappedRoutedEventArgs e) private async void Feedback_Click(object sender, RoutedEventArgs e)
{ {
await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync(); await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();
} }
private void SignIn_Click(object sender, TappedRoutedEventArgs e) private void SignIn_Click(object sender, RoutedEventArgs e)
{ {
SecretsVault.Authorize(); SecretsVault.Authorize();
} }
+1 -1
View File
@@ -34,7 +34,7 @@ namespace FoxTube.Pages
(grid.Children[Count % cols + 1] as StackPanel).Children.Add(card); (grid.Children[Count % cols + 1] as StackPanel).Children.Add(card);
Children.Add(card); Children.Add(card);
if ((Children.Count - 5) % 20 == 0) if ((Children.Count - 5) % 20 == 0 && !SecretsVault.AdsDisabled)
{ {
CardAdvert advert = new CardAdvert(IsRelatedVideos); CardAdvert advert = new CardAdvert(IsRelatedVideos);
(grid.Children[Count % cols + 1] as StackPanel).Children.Add(advert); (grid.Children[Count % cols + 1] as StackPanel).Children.Add(advert);
+2 -2
View File
@@ -135,7 +135,7 @@
<data name="downloads.Content" xml:space="preserve"> <data name="downloads.Content" xml:space="preserve">
<value>Downloads</value> <value>Downloads</value>
</data> </data>
<data name="feedback.Content" xml:space="preserve"> <data name="feedback.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Give a feedback</value> <value>Give a feedback</value>
</data> </data>
<data name="history.Content" xml:space="preserve"> <data name="history.Content" xml:space="preserve">
@@ -180,7 +180,7 @@
<data name="signEx.Text" xml:space="preserve"> <data name="signEx.Text" xml:space="preserve">
<value>Sign in with existing account</value> <value>Sign in with existing account</value>
</data> </data>
<data name="signIn.Content" xml:space="preserve"> <data name="signIn.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Add account</value> <value>Add account</value>
</data> </data>
<data name="signNew.Text" xml:space="preserve"> <data name="signNew.Text" xml:space="preserve">
+2 -2
View File
@@ -135,7 +135,7 @@
<data name="downloads.Content" xml:space="preserve"> <data name="downloads.Content" xml:space="preserve">
<value>Загрузки</value> <value>Загрузки</value>
</data> </data>
<data name="feedback.Content" xml:space="preserve"> <data name="feedback.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Оставить отзыв</value> <value>Оставить отзыв</value>
</data> </data>
<data name="history.Content" xml:space="preserve"> <data name="history.Content" xml:space="preserve">
@@ -180,7 +180,7 @@
<data name="signEx.Text" xml:space="preserve"> <data name="signEx.Text" xml:space="preserve">
<value>Войти с помощью существующего аккаунта Google</value> <value>Войти с помощью существующего аккаунта Google</value>
</data> </data>
<data name="signIn.Content" xml:space="preserve"> <data name="signIn.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Войти в аккаунт</value> <value>Войти в аккаунт</value>
</data> </data>
<data name="signNew.Text" xml:space="preserve"> <data name="signNew.Text" xml:space="preserve">