Archived
1
0

Development 110218

This commit is contained in:
Michael Gordeev
2018-11-02 10:33:34 +03:00
parent 3126b9cf19
commit bba4fe4f00
16 changed files with 400 additions and 125 deletions
+2 -2
View File
@@ -8,12 +8,12 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Name="grid">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid>
<Grid Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="30"/>
+2
View File
@@ -43,6 +43,8 @@ namespace FoxTube.Pages
if (!SecretsVault.IsAuthorized)
grid.RowDefinitions[0].Height = new GridLength(0);
else
grid.RowDefinitions[0].Height = GridLength.Auto;
counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount);
+44 -8
View File
@@ -24,6 +24,8 @@ using System.Net;
using Windows.UI.Popups;
using Windows.Networking.Connectivity;
using Windows.UI.Core;
using System.IO;
using Newtonsoft.Json;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
@@ -74,7 +76,7 @@ namespace FoxTube
if (settings.Values["ver"] == null)
settings.Values.Add("ver", $"{ver.Major}.{ver.Minor}");
//if((string)settings.Values["ver"] != $"{ver.Major}.{ver.Minor}")
if((string)settings.Values["ver"] != $"{ver.Major}.{ver.Minor}")
{
try
{
@@ -93,6 +95,16 @@ namespace FoxTube
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
SecretsVault.CheckAuthorization();
SetTitleBar();
Initialize();
}
public async void Initialize()
{
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(notificationsSettings));
Debug.WriteLine(ApplicationData.Current.RoamingFolder.Path);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
@@ -227,7 +239,8 @@ namespace FoxTube
}
nav.SelectedItem = toHome;
content.Navigate(typeof(Home));
if(content.Content is Home)
content.Navigate(typeof(Home));
if (videoPlaceholder.Content != null)
GoToVideo((videoPlaceholder.Content as VideoPage).videoId);
@@ -274,13 +287,12 @@ namespace FoxTube
public async void GoToVideo(string id, string playlistId = null)
{
Debug.WriteLine($"Video id: {id}; Playlist id: {playlistId}");
bool cancel = false;
try
{
var connection = NetworkInformation.GetInternetConnectionProfile().GetConnectionCost();
if ((bool)settings.Values["moblieWarning"] && (connection.NetworkCostType == NetworkCostType.Fixed || connection.NetworkCostType == NetworkCostType.Variable))
{
bool cancel = false;
MessageDialog dialog = new MessageDialog("You are on metered connection now. Additional charges may apply. Do you want to continue?")
{
DefaultCommandIndex = 2,
@@ -290,16 +302,40 @@ namespace FoxTube
dialog.Commands.Add(new UICommand("No", (command) => cancel = true));
dialog.Commands.Add(new UICommand("Add to 'Watch later' playlist", (command) =>
{
//TO-DO: Adding video to "Watch later"
try
{
if (!SecretsVault.IsAuthorized)
SecretsVault.CheckAuthorization(false);
if (!SecretsVault.IsAuthorized)
throw new Exception("Not authenticated");
PlaylistItem item = new PlaylistItem()
{
Snippet = new PlaylistItemSnippet()
{
ResourceId = new ResourceId()
{
Kind = "youtube#video",
VideoId = id
},
PlaylistId = "WL"
}
};
SecretsVault.Service.PlaylistItems.Insert(item, "snippet").Execute();
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
cancel = true;
}));
await dialog.ShowAsync();
if (cancel)
return;
}
}
catch { }
if (cancel)
return;
nav.IsPaneOpen = false;
+8 -2
View File
@@ -28,6 +28,7 @@ namespace FoxTube
public sealed partial class Settings : Page
{
bool inboxLoaded = false;
string inboxId = null;
public Settings()
{
this.InitializeComponent();
@@ -40,9 +41,9 @@ namespace FoxTube
{
if ((e.Parameter as string).Contains("inbox") || (e.Parameter as string).Contains("changelog"))
{
pivot.SelectedIndex = 2;
if ((string)e.Parameter != "inbox" && (string)e.Parameter != "changelog")
((pivot.SelectedItem as PivotItem).Content as Inbox).Open(e.Parameter as string);
inboxId = e.Parameter as string;
pivot.SelectedIndex = 2;
}
else
switch(e.Parameter as string)
@@ -63,6 +64,11 @@ namespace FoxTube
{
(((pivot.Items[2] as PivotItem).Content as ScrollViewer).Content as Inbox).LoadItems();
inboxLoaded = true;
if(inboxId != null)
{
(((pivot.Items[2] as PivotItem).Content as ScrollViewer).Content as Inbox).Open(inboxId as string);
inboxId = null;
}
}
}
}
+12 -3
View File
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -90,9 +91,13 @@ namespace FoxTube.Pages.SettingsPages
settings.Values["videoAutoplay"] = autoplay.IsOn;
}
private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
private async void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
{
settings.Values["newVideoNotification"] = newVideo.IsOn;
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(notificationsSettings));
}
private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -135,9 +140,13 @@ namespace FoxTube.Pages.SettingsPages
CoreApplication.Exit();
}
private void devNews_Toggled(object sender, RoutedEventArgs e)
private async void devNews_Toggled(object sender, RoutedEventArgs e)
{
settings.Values["devnews"] = devNews.IsOn;
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(notificationsSettings));
}
}
}
+4 -3
View File
@@ -5,8 +5,8 @@
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:ui="using:Microsoft.Advertising.WinRT.UI"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:controls="using:FoxTube.Controls"
x:Name="root"
mc:Ignorable="d">
@@ -15,7 +15,8 @@
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<controls:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None" Grid.Row="1"/>
<controls:Advert/>
<ui:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None" Grid.Row="1"/>
<TextBlock Name="empty" Text="&#xD8;" FontSize="200" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.RowSpan="2"/>
</Grid>
</Page>
+46 -2
View File
@@ -8,6 +8,7 @@
xmlns:pages="using:FoxTube.Pages"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:ui="using:Microsoft.Advertising.WinRT.UI"
xmlns:controls1="using:FoxTube.Controls"
mc:Ignorable="d">
@@ -106,7 +107,47 @@
<MenuFlyout x:Name="downloadSelector"/>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarButton Label="Add to" Icon="Add" IsEnabled="False"/>
<AppBarButton Name="addTo" Label="Add to" Icon="Add">
<AppBarButton.Flyout>
<Flyout>
<ScrollViewer Margin="-12" MaxHeight="300">
<NavigationViewList Width="200" IsMultiSelectCheckBoxEnabled="True" SelectionMode="Multiple">
<NavigationViewItem Content="Watch later">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE728;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="New playlist">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE109;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItemHeader Content="Other playlists"/>
<NavigationViewItem Content="My playlist">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE292;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Cats">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE292;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Dogs">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE292;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Another playlist">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE292;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
</NavigationViewList>
</ScrollViewer>
</Flyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarButton Name="refresh" Click="refresh_Click" Icon="Refresh" Label="Refresh page"/>
<AppBarButton Name="share" Click="share_Click" Icon="Share" Label="Share"/>
<AppBarButton Name="openBrowser" Click="openBrowser_Click" Icon="Globe" Label="Open in browser"/>
@@ -116,7 +157,10 @@
<Pivot Grid.Row="1" Name="pivot" SelectedIndex="0" IsHeaderItemsCarouselEnabled="False">
<PivotItem Header="Suggestions">
<ScrollViewer>
<StackPanel Name="relatedVideos"/>
<StackPanel>
<controls1:Advert/>
<StackPanel Name="relatedVideos"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem Header="Comments" Name="commentsPlaceholder">
+6
View File
@@ -209,6 +209,12 @@ namespace FoxTube.Pages
}
subscribe.Visibility = Visibility.Visible;
}
else
{
download.Visibility = Visibility.Collapsed;
addTo.Visibility = Visibility.Collapsed;
subscribe.Visibility = Visibility.Collapsed;
}
ChannelsResource.ListRequest channelRequest = SecretsVault.Service.Channels.List("snippet, statistics");
channelRequest.Id = item.Snippet.ChannelId;