Archived
1
0

Fixed extensions in Methods

Added chat ads
Optimized users's avatar
CardAdverts now appearing every 25 items
Added privacy url in CommentAdvert

Related Work Items: #162, #252
This commit is contained in:
Michael Gordeev
2019-04-11 18:11:45 +03:00
parent b43ea6b8c4
commit d28442ba1d
9 changed files with 169 additions and 22 deletions
+2
View File
@@ -3,6 +3,7 @@
<item time="2019-04-06" version="0.5">
<content>
<en-US>### What's new:
- App optimization
- Changelog notification now pops up after update at first launch
- Added ability to add videos to playlists on video page
- Added ability to add videos to playlists through card's context menu
@@ -14,6 +15,7 @@
- Some items were moved from menu to header
</en-US>
<ru-RU>### Что нового:
- Оптимизация приложения
- Добавлено уведомление со списком изменений при первом запуске после обновления
- Добавлена возможность добавлять видео в плейлисты на странице просмотра
- Добавлена возможность добавлять видео в плейлисты через контекстное меню карточки
+5 -7
View File
@@ -42,10 +42,13 @@ namespace FoxTube
public static Uri ToUri(this string url)
{
return new Uri(url);
if (string.IsNullOrWhiteSpace(url))
return null;
else
return new Uri(url);
}
public static string GuardFromNull(this string str)
public static string GuardFromNull(string str)
{
if (string.IsNullOrWhiteSpace(str))
return string.Empty;
@@ -53,11 +56,6 @@ namespace FoxTube
return str;
}
public static bool IsNullOrWhiteSpace(this string str)
{
return string.IsNullOrWhiteSpace(str);
}
public static string GetChars(this string str, int count)
{
try
+4 -4
View File
@@ -47,19 +47,19 @@ namespace FoxTube.Controls.Adverts
icon.ProfilePicture = advert.AdIcon == null ? null : advert.AdIcon.Source;
sponsor.Text = advert.SponsoredBy.GuardFromNull();
sponsor.Text = Methods.GuardFromNull(advert.SponsoredBy);
if (advert.CallToActionText.IsNullOrWhiteSpace())
if (string.IsNullOrWhiteSpace(advert.CallToActionText))
(info.Parent as FrameworkElement).Visibility = Visibility.Collapsed;
else
info.Text = advert.CallToActionText;
desc.Text = string.Empty;
if (!advert.Price.IsNullOrWhiteSpace())
if (!string.IsNullOrWhiteSpace(advert.Price))
desc.Text += advert.Price;
if (!advert.Rating.IsNullOrWhiteSpace())
if (!string.IsNullOrWhiteSpace(advert.Rating))
desc.Text += " " + advert.Rating;
show.Begin();
+2 -1
View File
@@ -18,8 +18,9 @@
<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="title" Text="Title" TextWrapping="WrapWholeWords" FontWeight="Bold"/>
<TextBlock Name="description" Text="Description" TextWrapping="WrapWholeWords"/>
<HyperlinkButton Name="privacy"/>
<Button Name="cta" Content="CALL TO ACTION TEXT" Margin="0,5"/>
</StackPanel>
@@ -39,15 +39,19 @@ namespace FoxTube.Controls.Adverts
private void Initialize()
{
title.Text = advert.Title;
description.Text = advert.Description.GuardFromNull();
description.Text = Methods.GuardFromNull(advert.Description);
icon.ProfilePicture = advert.AdIcon == null ? null : advert.AdIcon.Source;
cta.Content = advert.CallToActionText.GuardFromNull();
cta.Visibility = advert.CallToActionText.IsNullOrWhiteSpace() ? Visibility.Collapsed : Visibility.Visible;
privacy.NavigateUri = advert.PrivacyUrl.ToUri();
privacy.Content = advert.PrivacyUrl;
privacy.Visibility = string.IsNullOrWhiteSpace(advert.PrivacyUrl) ? Visibility.Collapsed : Visibility.Visible;
cta.Content = Methods.GuardFromNull(advert.CallToActionText);
cta.Visibility = string.IsNullOrWhiteSpace(advert.CallToActionText) ? Visibility.Collapsed : Visibility.Visible;
meta.Text += advert.Price;
meta.Text += " " + advert.Rating;
meta.Visibility = meta.Text.IsNullOrWhiteSpace() ? Visibility.Collapsed : Visibility.Visible;
meta.Visibility = string.IsNullOrWhiteSpace(meta.Text) ? Visibility.Collapsed : Visibility.Visible;
}
}
}
+8 -2
View File
@@ -4,6 +4,7 @@
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"
xmlns:controls="using:FoxTube.Controls"
mc:Ignorable="d"
d:DesignHeight="600"
d:DesignWidth="400">
@@ -26,7 +27,7 @@
<ListView Name="list" Grid.Row="1" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="controls:ChatMessage">
<Border BorderBrush="Red" BorderThickness="{Binding Path=BorderThickness}" CornerRadius="5" HorizontalAlignment="Stretch" Background="{Binding Path=Background}" Margin="0,2">
<Grid Margin="0,5,5,0">
<Grid.ColumnDefinitions>
@@ -62,7 +63,12 @@
</FontIcon>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1" VerticalAlignment="Top" Margin="0,0,5,0">
<HyperlinkButton Content="{Binding Path=Author}" Tag="{Binding Path=ChannelId}" Grid.Column="1" Margin="0,-6,0,0" FontWeight="Bold" Click="HyperlinkButton_Click"/>
<HyperlinkButton Tag="{Binding Path=ChannelId}" Margin="0,-6,0,0" FontWeight="Bold" Click="HyperlinkButton_Click">
<ToolTipService.ToolTip>
<TextBlock Text="{Binding Path=Author}" Style="{StaticResource CaptionTextBlockStyle}"/>
</ToolTipService.ToolTip>
<TextBlock TextTrimming="CharacterEllipsis" MaxWidth="150" Text="{Binding Path=Author}"/>
</HyperlinkButton>
<TextBlock Text=":"/>
</StackPanel>
<GroupItem Content="{Binding Path=Message}" Grid.Column="2"/>
+137 -1
View File
@@ -9,6 +9,9 @@ using Microsoft.AppCenter.Analytics;
using System.Collections.Generic;
using Windows.UI.Popups;
using Windows.ApplicationModel.Resources;
using Microsoft.Advertising.WinRT.UI;
using Windows.UI.Xaml.Media.Imaging;
using System.Linq;
namespace FoxTube.Controls
{
@@ -68,17 +71,24 @@ namespace FoxTube.Controls
public sealed partial class Chat : UserControl
{
NativeAdsManagerV2 manager = new NativeAdsManagerV2(SecretsVault.AppId, SecretsVault.AdUnitId);
public NativeAdV2 advert;
string chatId;
DateTime lastInsert;
LiveChatMessagesResource.ListRequest request;
LiveChatMessageListResponse response;
DispatcherTimer timer = new DispatcherTimer()
DispatcherTimer timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1)
};
DispatcherTimer adTimer = new DispatcherTimer
{
Interval = TimeSpan.FromMinutes(5)
};
public Chat(string id)
{
InitializeComponent();
@@ -90,6 +100,132 @@ namespace FoxTube.Controls
timer.Tick += Update;
timer.Start();
if (SecretsVault.AdsDisabled)
return;
adTimer.Tick += (s, e) => manager.RequestAd();
adTimer.Start();
manager.AdReady += AdReady;
manager.ErrorOccurred += ErrorOccurred;
}
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;
Grid grid = new Grid
{
Margin = new Thickness(0, 5, 5, 5),
};
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
StackPanel iconStack = new StackPanel
{
Orientation = Orientation.Horizontal,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(5, 0, 5, 0)
};
iconStack.Children.Add(new PersonPicture
{
Height = 20,
ProfilePicture = advert.AdIcon == null ? null : advert.AdIcon.Source
});
FontIcon sponsor = new FontIcon
{
Glyph = "\xE735",
Margin = new Thickness(2, 0, 2, 0)
};
ToolTipService.SetToolTip(sponsor, ResourceLoader.GetForCurrentView("Chat").GetString("/Chat/sponsor/Text"));
iconStack.Children.Add(sponsor);
StackPanel nameStack = new StackPanel
{
Orientation = Orientation.Horizontal,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(0, 0, 2, 0)
};
Grid.SetColumn(nameStack, 1);
HyperlinkButton sponsorName = new HyperlinkButton
{
Margin = new Thickness(0, -6, 0, 0),
FontWeight = Windows.UI.Text.FontWeights.Bold,
Content = new TextBlock
{
TextTrimming = TextTrimming.CharacterEllipsis,
MaxWidth = 150,
Text = Methods.GuardFromNull(advert.SponsoredBy)
}
};
ToolTipService.SetToolTip(sponsorName, Methods.GuardFromNull(advert.SponsoredBy));
nameStack.Children.Add(sponsorName);
nameStack.Children.Add(new TextBlock { Text = ":" });
StackPanel contentStack = new StackPanel
{
Padding = new Thickness(2, 0, 0, 0)
};
Grid.SetColumn(contentStack, 2);
contentStack.Children.Add(new TextBlock
{
VerticalAlignment = VerticalAlignment.Top,
TextWrapping = TextWrapping.WrapWholeWords,
FontWeight = Windows.UI.Text.FontWeights.Bold,
Text = advert.Title
});
if(!string.IsNullOrWhiteSpace(advert.Description))
contentStack.Children.Add(new TextBlock
{
VerticalAlignment = VerticalAlignment.Top,
TextWrapping = TextWrapping.WrapWholeWords,
Text = advert.Description
});
if (!string.IsNullOrWhiteSpace(advert.CallToActionText))
contentStack.Children.Add(new HyperlinkButton
{
VerticalAlignment = VerticalAlignment.Top,
Content = new TextBlock
{
TextWrapping = TextWrapping.WrapWholeWords,
Text = advert.CallToActionText
}
});
grid.Children.Add(iconStack);
grid.Children.Add(nameStack);
grid.Children.Add(contentStack);
ListViewItem item = new ListViewItem
{
Content = new Border
{
BorderBrush = new SolidColorBrush(Colors.Red),
BorderThickness = new Thickness(2),
CornerRadius = new CornerRadius(5),
HorizontalAlignment = HorizontalAlignment.Stretch,
Margin = new Thickness(0, 2, 0, 2),
Background = new SolidColorBrush(Colors.Red) { Opacity = .2 },
Child = grid
},
Padding = new Thickness(0,25,0,0)
};
list.Items.Insert(0, item);
if (contentStack.Children.Last() is HyperlinkButton)
advert.RegisterAdContainer(item, new List<FrameworkElement> { contentStack.Children.Last() as HyperlinkButton });
else
advert.RegisterAdContainer(item);
}
public async void Update(object sender, object e)
+2 -2
View File
@@ -179,8 +179,8 @@ namespace FoxTube
ToolTipService.SetToolTip(avatar, $"{SecretsVault.UserInfo.Name} ({SecretsVault.UserInfo.Email})");
myNameFlyout.Text = SecretsVault.UserInfo.Name;
myEmail.Text = SecretsVault.UserInfo.Email;
avatarFlyout.ProfilePicture = new BitmapImage(SecretsVault.UserInfo.Picture.ToUri());
(avatar.Content as PersonPicture).ProfilePicture = avatarFlyout.ProfilePicture;
avatarFlyout.ProfilePicture = new BitmapImage(SecretsVault.UserInfo.Picture.ToUri()) { DecodePixelHeight = 65, DecodePixelWidth = 65 };
(avatar.Content as PersonPicture).ProfilePicture = new BitmapImage(SecretsVault.UserInfo.Picture.ToUri()) { DecodePixelHeight = 25, DecodePixelWidth = 25 };
avatar.Visibility = Visibility.Visible;
+1 -1
View File
@@ -34,7 +34,7 @@ namespace FoxTube.Pages
(grid.Children[Count % cols + 1] as StackPanel).Children.Add(card);
Children.Add(card);
if ((Children.Count - 5) % 20 == 0 && !SecretsVault.AdsDisabled)
if ((Children.Count - 5) % 25 == 0 && !SecretsVault.AdsDisabled)
{
CardAdvert advert = new CardAdvert(IsRelatedVideos);
(grid.Children[Count % cols + 1] as StackPanel).Children.Add(advert);