Added "Add to" button on video page
This commit is contained in:
@@ -4,9 +4,11 @@
|
|||||||
<content>
|
<content>
|
||||||
<en-US>### What's new:
|
<en-US>### What's new:
|
||||||
- Changelog notification now pops up after update at first launch
|
- Changelog notification now pops up after update at first launch
|
||||||
|
- Added ability to add videos to playlists on video page
|
||||||
</en-US>
|
</en-US>
|
||||||
<ru-RU>### Что нового:
|
<ru-RU>### Что нового:
|
||||||
- Добавлено уведомление со списком изменений при первом запуске после обновления
|
- Добавлено уведомление со списком изменений при первом запуске после обновления
|
||||||
|
- Добавлена возможность добавлять видео в плейлисты на странице просмотра
|
||||||
</ru-RU>
|
</ru-RU>
|
||||||
</content>
|
</content>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -6,7 +6,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:pages="using:FoxTube.Pages"
|
xmlns:pages="using:FoxTube.Pages"
|
||||||
xmlns:controls1="using:FoxTube.Controls"
|
xmlns:controls="using:FoxTube.Controls"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged">
|
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged">
|
||||||
@@ -110,35 +110,12 @@
|
|||||||
<MenuFlyout x:Name="downloadSelector"/>
|
<MenuFlyout x:Name="downloadSelector"/>
|
||||||
</AppBarButton.Flyout>
|
</AppBarButton.Flyout>
|
||||||
</AppBarButton>
|
</AppBarButton>
|
||||||
<AppBarButton x:Uid="/VideoPage/addTo" Name="addTo" Label="Add to" Icon="Add" Visibility="Collapsed">
|
<AppBarButton x:Uid="/VideoPage/addTo" Name="addTo" Label="Add to" Icon="Add" Visibility="Visible">
|
||||||
<AppBarButton.Flyout>
|
<AppBarButton.Flyout>
|
||||||
<MenuFlyout x:Name="addList">
|
<MenuFlyout x:Name="addList">
|
||||||
<MenuFlyoutItem Text="New playlist" Name="newPlaylist" Click="NewPlaylist_Click">
|
<MenuFlyoutItem Text="New playlist" Name="newPlaylist" Click="NewPlaylist_Click" Icon="Add"/>
|
||||||
<MenuFlyoutItem.Icon>
|
<ToggleMenuFlyoutItem Text="Watch later" Name="wl" Click="Wl_Click" Icon="Clock"/>
|
||||||
<FontIcon Glyph=""/>
|
|
||||||
</MenuFlyoutItem.Icon>
|
|
||||||
</MenuFlyoutItem>
|
|
||||||
<ToggleMenuFlyoutItem Text="Watch later" Background="Red" Name="wl" Click="Wl_Click">
|
|
||||||
<MenuFlyoutItem.Icon>
|
|
||||||
<FontIcon Glyph=""/>
|
|
||||||
</MenuFlyoutItem.Icon>
|
|
||||||
</ToggleMenuFlyoutItem>
|
|
||||||
<MenuFlyoutSeparator/>
|
<MenuFlyoutSeparator/>
|
||||||
<ToggleMenuFlyoutItem Text="Cats">
|
|
||||||
<ToggleMenuFlyoutItem.Icon>
|
|
||||||
<FontIcon Glyph=""/>
|
|
||||||
</ToggleMenuFlyoutItem.Icon>
|
|
||||||
</ToggleMenuFlyoutItem>
|
|
||||||
<ToggleMenuFlyoutItem Text="Dogs">
|
|
||||||
<ToggleMenuFlyoutItem.Icon>
|
|
||||||
<FontIcon Glyph=""/>
|
|
||||||
</ToggleMenuFlyoutItem.Icon>
|
|
||||||
</ToggleMenuFlyoutItem>
|
|
||||||
<ToggleMenuFlyoutItem Text="Porn">
|
|
||||||
<ToggleMenuFlyoutItem.Icon>
|
|
||||||
<FontIcon Glyph=""/>
|
|
||||||
</ToggleMenuFlyoutItem.Icon>
|
|
||||||
</ToggleMenuFlyoutItem>
|
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
<!--<Flyout>
|
<!--<Flyout>
|
||||||
<ScrollViewer Margin="-12" MaxHeight="300">
|
<ScrollViewer Margin="-12" MaxHeight="300">
|
||||||
@@ -227,7 +204,11 @@
|
|||||||
<ContentDialog PrimaryButtonText="Create and add" Title="New playlist" DefaultButton="Primary" PrimaryButtonClick="ContentDialog_PrimaryButtonClick" Name="playlistDialog">
|
<ContentDialog PrimaryButtonText="Create and add" Title="New playlist" DefaultButton="Primary" PrimaryButtonClick="ContentDialog_PrimaryButtonClick" Name="playlistDialog">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBox PlaceholderText="Enter playlist name" Name="newListName"/>
|
<TextBox PlaceholderText="Enter playlist name" Name="newListName"/>
|
||||||
<TextBlock Text="Invalid name: playlist with the name already exists" TextWrapping="WrapWholeWords" Foreground="Red" Visibility="Collapsed" Name="newListErr"/>
|
<ComboBox Header="Availablity" SelectedIndex="0" HorizontalAlignment="Stretch" Name="newListDisc">
|
||||||
|
<ComboBoxItem Content="Public"/>
|
||||||
|
<ComboBoxItem Content="Private"/>
|
||||||
|
<ComboBoxItem Content="Direct link"/>
|
||||||
|
</ComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ContentDialog>
|
</ContentDialog>
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ namespace FoxTube.Pages
|
|||||||
SetSchedule();
|
SetSchedule();
|
||||||
|
|
||||||
LoadInfo();
|
LoadInfo();
|
||||||
|
LoadAddTo();
|
||||||
|
|
||||||
loading.Close();
|
loading.Close();
|
||||||
}
|
}
|
||||||
@@ -567,6 +568,90 @@ namespace FoxTube.Pages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async void LoadAddTo()
|
||||||
|
{
|
||||||
|
if(SecretsVault.UserChannel == null)
|
||||||
|
{
|
||||||
|
addTo.Visibility = Visibility.Collapsed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SecretsVault.WatchLater.Contains(item.Id))
|
||||||
|
(addList.Items[1] as ToggleMenuFlyoutItem).IsChecked = true;
|
||||||
|
|
||||||
|
PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet");
|
||||||
|
request.Mine = true;
|
||||||
|
request.MaxResults = 50;
|
||||||
|
|
||||||
|
PlaylistListResponse response = await request.ExecuteAsync();
|
||||||
|
|
||||||
|
PlaylistItemsResource.ListRequest itemRequest = SecretsVault.Service.PlaylistItems.List("snippet");
|
||||||
|
itemRequest.VideoId = item.Id;
|
||||||
|
|
||||||
|
foreach (Playlist i in response.Items)
|
||||||
|
{
|
||||||
|
itemRequest.PlaylistId = i.Id;
|
||||||
|
ToggleMenuFlyoutItem menuItem = new ToggleMenuFlyoutItem
|
||||||
|
{
|
||||||
|
Text = i.Snippet.Title,
|
||||||
|
IsChecked = (await itemRequest.ExecuteAsync()).Items.Count > 0,
|
||||||
|
Tag = i,
|
||||||
|
Icon = new FontIcon
|
||||||
|
{
|
||||||
|
Glyph = "\xE728"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
menuItem.Click += Item_Click;
|
||||||
|
addList.Items.Add(menuItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Item_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if(((ToggleMenuFlyoutItem)sender).IsChecked)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PlaylistItem playlist = new PlaylistItem
|
||||||
|
{
|
||||||
|
Snippet = new PlaylistItemSnippet
|
||||||
|
{
|
||||||
|
PlaylistId = (((ToggleMenuFlyoutItem)sender).Tag as Playlist).Id,
|
||||||
|
ResourceId = new ResourceId
|
||||||
|
{
|
||||||
|
VideoId = item.Id,
|
||||||
|
Kind = "youtube#video"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
PlaylistItemsResource.InsertRequest request = SecretsVault.Service.PlaylistItems.Insert(playlist, "snippet");
|
||||||
|
|
||||||
|
await request.ExecuteAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
((ToggleMenuFlyoutItem)sender).IsChecked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PlaylistItemsResource.ListRequest itemRequest = SecretsVault.Service.PlaylistItems.List("snippet");
|
||||||
|
itemRequest.VideoId = item.Id;
|
||||||
|
itemRequest.PlaylistId = ((Playlist)((ToggleMenuFlyoutItem)sender).Tag).Id;
|
||||||
|
|
||||||
|
PlaylistItemsResource.DeleteRequest request = SecretsVault.Service.PlaylistItems.Delete((await itemRequest.ExecuteAsync()).Items[0].Id);
|
||||||
|
|
||||||
|
await request.ExecuteAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
((ToggleMenuFlyoutItem)sender).IsChecked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async void NewPlaylist_Click(object sender, RoutedEventArgs e)
|
private async void NewPlaylist_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
//TODO: Localize strings
|
//TODO: Localize strings
|
||||||
@@ -575,12 +660,59 @@ namespace FoxTube.Pages
|
|||||||
|
|
||||||
private void Wl_Click(object sender, RoutedEventArgs e)
|
private void Wl_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
// TODO: Add video to WL playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||||
{
|
{
|
||||||
|
string privacy = "private";
|
||||||
|
switch(newListDisc.SelectedIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
privacy = "public";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
privacy = "private";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
privacy = "unlisted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Playlist newItem = new Playlist
|
||||||
|
{
|
||||||
|
Snippet = new PlaylistSnippet
|
||||||
|
{
|
||||||
|
Title = newListName.Text
|
||||||
|
},
|
||||||
|
Status = new PlaylistStatus
|
||||||
|
{
|
||||||
|
PrivacyStatus = privacy,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Playlist i;
|
||||||
|
|
||||||
|
try { i = await SecretsVault.Service.Playlists.Insert(newItem, "snippet,status").ExecuteAsync(); }
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToggleMenuFlyoutItem menuItem = new ToggleMenuFlyoutItem
|
||||||
|
{
|
||||||
|
Text = i.Snippet.Title,
|
||||||
|
IsChecked = true,
|
||||||
|
Tag = i,
|
||||||
|
Icon = new FontIcon
|
||||||
|
{
|
||||||
|
Glyph = "\xE728"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
menuItem.Click += Item_Click;
|
||||||
|
addList.Items.Add(menuItem);
|
||||||
|
|
||||||
|
Item_Click(menuItem, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user