Added "Add to" button on video page
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
<content>
|
||||
<en-US>### What's new:
|
||||
- Changelog notification now pops up after update at first launch
|
||||
- Added ability to add videos to playlists on video page
|
||||
</en-US>
|
||||
<ru-RU>### Что нового:
|
||||
- Добавлено уведомление со списком изменений при первом запуске после обновления
|
||||
- Добавлена возможность добавлять видео в плейлисты на странице просмотра
|
||||
</ru-RU>
|
||||
</content>
|
||||
</item>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:pages="using:FoxTube.Pages"
|
||||
xmlns:controls1="using:FoxTube.Controls"
|
||||
xmlns:controls="using:FoxTube.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="grid_SizeChanged">
|
||||
@@ -110,35 +110,12 @@
|
||||
<MenuFlyout x:Name="downloadSelector"/>
|
||||
</AppBarButton.Flyout>
|
||||
</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>
|
||||
<MenuFlyout x:Name="addList">
|
||||
<MenuFlyoutItem Text="New playlist" Name="newPlaylist" Click="NewPlaylist_Click">
|
||||
<MenuFlyoutItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</MenuFlyoutItem.Icon>
|
||||
</MenuFlyoutItem>
|
||||
<ToggleMenuFlyoutItem Text="Watch later" Background="Red" Name="wl" Click="Wl_Click">
|
||||
<MenuFlyoutItem.Icon>
|
||||
<FontIcon Glyph=""/>
|
||||
</MenuFlyoutItem.Icon>
|
||||
</ToggleMenuFlyoutItem>
|
||||
<MenuFlyoutItem Text="New playlist" Name="newPlaylist" Click="NewPlaylist_Click" Icon="Add"/>
|
||||
<ToggleMenuFlyoutItem Text="Watch later" Name="wl" Click="Wl_Click" Icon="Clock"/>
|
||||
<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>
|
||||
<!--<Flyout>
|
||||
<ScrollViewer Margin="-12" MaxHeight="300">
|
||||
@@ -227,7 +204,11 @@
|
||||
<ContentDialog PrimaryButtonText="Create and add" Title="New playlist" DefaultButton="Primary" PrimaryButtonClick="ContentDialog_PrimaryButtonClick" Name="playlistDialog">
|
||||
<StackPanel>
|
||||
<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>
|
||||
</ContentDialog>
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace FoxTube.Pages
|
||||
SetSchedule();
|
||||
|
||||
LoadInfo();
|
||||
LoadAddTo();
|
||||
|
||||
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)
|
||||
{
|
||||
//TODO: Localize strings
|
||||
@@ -575,12 +660,59 @@ namespace FoxTube.Pages
|
||||
|
||||
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