Archived
1
0
This commit is contained in:
Michael Gordeev
2018-12-09 17:15:16 +03:00
parent f16be876c6
commit aa3214cc60
10 changed files with 45 additions and 48 deletions
+5 -4
View File
@@ -260,20 +260,21 @@ namespace FoxTube
/// </summary> /// </summary>
/// <param name="sender">The source of the suspend request.</param> /// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param> /// <param name="e">Details about the suspend request.</param>
private async void OnSuspending(object sender, SuspendingEventArgs e) private void OnSuspending(object sender, SuspendingEventArgs e)
{ {
var deferral = e.SuspendingOperation.GetDeferral(); var deferral = e.SuspendingOperation.GetDeferral();
//await new MessageDialog("suspending").ShowAsync();
//Saving history //Saving history
await FileIO.WriteTextAsync( /*await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting), await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(SecretsVault.UserHistory)); JsonConvert.SerializeObject(SecretsVault.UserHistory));
//Saving WL playlist //Saving WL playlist
await FileIO.WriteTextAsync( await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting), await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(SecretsVault.WatchLater)); JsonConvert.SerializeObject(SecretsVault.WatchLater));*/
//Saving downloads //Saving downloads
Methods.MainPage.Agent.QuitPrompt(); Methods.MainPage.Agent.QuitPrompt();
ToastNotificationManager.CreateToastNotifier().Show(Background.Notification.GetInternalToast(null, "All data saved", "", null, null));
deferral.Complete(); deferral.Complete();
} }
} }
+1 -11
View File
@@ -52,13 +52,7 @@ namespace FoxTube.Controls
items.Remove(item); items.Remove(item);
} }
public void QuitPrompt() public async void QuitPrompt()
{
if(items.Exists(x => x.InProgress))
{
MessageDialog dialog = new MessageDialog($"Waiting pending downloads ({items.FindAll(x => x.InProgress).Count})...");
dialog.Commands.Add(new UICommand("Force quit", async (command) =>
{ {
foreach (DownloadItem i in items.FindAll(x => x.InProgress)) foreach (DownloadItem i in items.FindAll(x => x.InProgress))
i.Cancel(); i.Cancel();
@@ -71,10 +65,6 @@ namespace FoxTube.Controls
await FileIO.WriteTextAsync( await FileIO.WriteTextAsync(
await roaming.CreateFileAsync("downloads.json", CreationCollisionOption.ReplaceExisting), await roaming.CreateFileAsync("downloads.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(containers)); JsonConvert.SerializeObject(containers));
}));
prompt = dialog.ShowAsync();
}
} }
} }
} }
+8 -8
View File
@@ -16,7 +16,7 @@ using Windows.UI.Popups;
namespace FoxTube namespace FoxTube
{ {
public class HistoryItem /*public class HistoryItem
{ {
public string Id { get; set; } public string Id { get; set; }
public double LeftOn { get; set; } public double LeftOn { get; set; }
@@ -32,7 +32,7 @@ namespace FoxTube
Id = id; Id = id;
LeftOn = 0; LeftOn = 0;
} }
} }*/
public static class SecretsVault public static class SecretsVault
{ {
@@ -57,8 +57,8 @@ namespace FoxTube
public static bool IsAuthorized { get; private set; } = false; public static bool IsAuthorized { get; private set; } = false;
public static Channel UserChannel { get; private set; } public static Channel UserChannel { get; private set; }
public static List<string> WatchLater { get; private set; } = new List<string>(); /*public static List<string> WatchLater { get; private set; } = new List<string>();
public static List<HistoryItem> UserHistory { get; private set; } = new List<HistoryItem>(); public static List<HistoryItem> UserHistory { get; private set; } = new List<HistoryItem>();*/
public static List<Subscription> Subscriptions { get; private set; } = new List<Subscription>(); public static List<Subscription> Subscriptions { get; private set; } = new List<Subscription>();
public static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer() public static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer()
@@ -77,14 +77,14 @@ namespace FoxTube
} }
} }
public static void HistoryAdd(string id, TimeSpan elapsed, TimeSpan total) /*public static void HistoryAdd(string id, TimeSpan elapsed, TimeSpan total)
{ {
UserHistory.Remove(UserHistory.Find(x => x.Id == id)); UserHistory.Remove(UserHistory.Find(x => x.Id == id));
UserHistory.Add(new HistoryItem(id, elapsed, total)); UserHistory.Add(new HistoryItem(id, elapsed, total));
if (UserHistory.Count > 100) if (UserHistory.Count > 100)
UserHistory.RemoveAt(UserHistory.Count - 1); UserHistory.RemoveAt(UserHistory.Count - 1);
} }*/
public static async Task<bool> ChangeSubscriptionState(string id) public static async Task<bool> ChangeSubscriptionState(string id)
{ {
@@ -208,7 +208,7 @@ namespace FoxTube
UserChannel = (await request.ExecuteAsync()).Items[0]; UserChannel = (await request.ExecuteAsync()).Items[0];
AccountId = UserChannel.Id; AccountId = UserChannel.Id;
try /*try
{ {
await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json"); await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json");
UserHistory = JsonConvert.DeserializeObject<List<HistoryItem>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json"))); UserHistory = JsonConvert.DeserializeObject<List<HistoryItem>>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json")));
@@ -231,7 +231,7 @@ namespace FoxTube
await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting), await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(new List<string>())); JsonConvert.SerializeObject(new List<string>()));
WatchLater = new List<string>(); WatchLater = new List<string>();
} }*/
/*PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet"); /*PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet");
playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchHistory; playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchHistory;
+4 -6
View File
@@ -30,9 +30,7 @@ namespace FoxTube.Controls
public async void Initialize(string id, string playlist = null) public async void Initialize(string id, string playlist = null)
{ {
YouTubeService ytService = SecretsVault.NoAuthService; VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails");
VideosResource.ListRequest request = ytService.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails");
request.Id = id; request.Id = id;
VideoListResponse response = await request.ExecuteAsync(); VideoListResponse response = await request.ExecuteAsync();
@@ -71,7 +69,7 @@ namespace FoxTube.Controls
embed = false; embed = false;
} }
var request1 = ytService.Channels.List("snippet"); var request1 = SecretsVault.Service.Channels.List("snippet");
request1.Id = item.Snippet.ChannelId; request1.Id = item.Snippet.ChannelId;
ChannelListResponse response1 = await request1.ExecuteAsync(); ChannelListResponse response1 = await request1.ExecuteAsync();
@@ -82,11 +80,11 @@ namespace FoxTube.Controls
} }
catch { } catch { }
if(SecretsVault.UserHistory.Exists(x => x.Id == videoId)) /*if(SecretsVault.UserHistory.Exists(x => x.Id == videoId))
{ {
watched.Visibility = Visibility.Visible; watched.Visibility = Visibility.Visible;
leftOn.Value = SecretsVault.UserHistory.Find(x => x.Id == videoId).LeftOn; leftOn.Value = SecretsVault.UserHistory.Find(x => x.Id == videoId).LeftOn;
} }*/
} }
public async void Button_Click(object sender, RoutedEventArgs e) public async void Button_Click(object sender, RoutedEventArgs e)
+2 -2
View File
@@ -203,7 +203,7 @@ namespace FoxTube
systemControls.ButtonPressed += SystemControls_Engaged; systemControls.ButtonPressed += SystemControls_Engaged;
systemControls.IsEnabled = true; systemControls.IsEnabled = true;
SecretsVault.HistoryAdd(videoId, elapsed, total); //SecretsVault.HistoryAdd(videoId, elapsed, total);
t.Start(); t.Start();
@@ -615,7 +615,7 @@ namespace FoxTube
break; break;
} }
SecretsVault.HistoryAdd(videoId, elapsed, total); //SecretsVault.HistoryAdd(videoId, elapsed, total);
} }
private async void miniView_Click(object sender, RoutedEventArgs e) private async void miniView_Click(object sender, RoutedEventArgs e)
+1 -1
View File
@@ -20,7 +20,7 @@
<local:VideoGrid/> <local:VideoGrid/>
</ScrollViewer> </ScrollViewer>
<CommandBar Grid.Row="1" DefaultLabelPosition="Right"> <CommandBar Grid.Row="1" DefaultLabelPosition="Right">
<AppBarButton LabelPosition="Default" Icon="Help" Label="Missing some stuff?" Name="help" Click="help_Click"/> <AppBarButton Icon="Refresh" Label="Refresh" Name="refresh" Click="Refresh_Click"/>
<AppBarButton Label="Open in browser" Icon="Globe" Name="toBrowser" Click="toBrowser_Click"/> <AppBarButton Label="Open in browser" Icon="Globe" Name="toBrowser" Click="toBrowser_Click"/>
</CommandBar> </CommandBar>
<foxtube:LoadingPage Visibility="Collapsed" Grid.RowSpan="2"/> <foxtube:LoadingPage Visibility="Collapsed" Grid.RowSpan="2"/>
+2 -5
View File
@@ -35,9 +35,6 @@ namespace FoxTube.Pages
{ {
loading.Refresh(); loading.Refresh();
list.Clear();
SecretsVault.UserHistory.ForEach(i => list.Add(new VideoCard(i.Id)));
loading.Close(); loading.Close();
} }
@@ -46,9 +43,9 @@ namespace FoxTube.Pages
await Launcher.LaunchUriAsync(new Uri("youtube.com/feed/history")); await Launcher.LaunchUriAsync(new Uri("youtube.com/feed/history"));
} }
private void help_Click(object sender, RoutedEventArgs e) private void Refresh_Click(object sender, RoutedEventArgs e)
{ {
Methods.MainPage.GoToDeveloper("local-history");
} }
} }
} }
+1 -1
View File
@@ -15,7 +15,7 @@
<controls:AdaptiveGridView ItemsSource="{x:Bind list}" DesiredWidth="250" Margin="5,0,0,0"> <controls:AdaptiveGridView ItemsSource="{x:Bind list}" DesiredWidth="250" Margin="5,0,0,0">
<controls:AdaptiveGridView.ItemTemplate> <controls:AdaptiveGridView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Padding="5"> <Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Padding="5" Tag="{Binding Path=Snippet.ResourceId.ChannelId}" Click="Button_Click">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="55"/> <ColumnDefinition Width="55"/>
+5
View File
@@ -28,5 +28,10 @@ namespace FoxTube.Pages
{ {
this.InitializeComponent(); this.InitializeComponent();
} }
private void Button_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToChannel(((Button)sender).Tag.ToString());
}
} }
} }
+6
View File
@@ -37,6 +37,12 @@
<local:VideoPlayer/> <local:VideoPlayer/>
<PivotItem Header="Description" Name="descriptionPanel"> <PivotItem Header="Description" Name="descriptionPanel">
<StackPanel Margin="0,10"> <StackPanel Margin="0,10">
<Button Visibility="Collapsed">
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE1AD;" Margin="0,0,10,0"/>
<TextBlock Text="Continue watching from HH:MM:SS"/>
</StackPanel>
</Button>
<TextBlock IsTextSelectionEnabled="True" Name="title" Text="[Video title]" FontSize="25" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Start"/> <TextBlock IsTextSelectionEnabled="True" Name="title" Text="[Video title]" FontSize="25" TextWrapping="WrapWholeWords" HorizontalTextAlignment="Start"/>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>