- History page re-design
- Added app history management (doesn't affect web site's history) - Extended history information for videos (watching progress) - Continue where you left off feature - Watch later playlist now acts like regular playlist - If video is longer than 1 hour ads will be shown every 30 minutes - Added incognito mode (available in video card context menu) - Search suggestions now run smoother Related Work Items: #140, #252
This commit is contained in:
@@ -3,6 +3,7 @@ using Microsoft.AppCenter.Analytics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.System;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
@@ -15,9 +16,8 @@ namespace FoxTube.Pages
|
||||
public sealed partial class History : Page, NavigationPage
|
||||
{
|
||||
public object Parameter { get; set; } = null;
|
||||
List<string> entries;
|
||||
int page = 1;
|
||||
public string id = "HL";
|
||||
int webPage = 0;
|
||||
|
||||
public History()
|
||||
{
|
||||
@@ -29,11 +29,6 @@ namespace FoxTube.Pages
|
||||
base.OnNavigatedTo(e);
|
||||
Parameter = e.Parameter;
|
||||
|
||||
loading.RefreshPage += Refresh_Click;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(e.Parameter.ToString()))
|
||||
id = e.Parameter.ToString();
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@@ -43,52 +38,127 @@ namespace FoxTube.Pages
|
||||
{
|
||||
loading.Refresh();
|
||||
|
||||
entries = id == "HL" ? SecretsVault.History = await Methods.GetHistory() : SecretsVault.WatchLater = await Methods.GetLater();
|
||||
await Dispatcher.RunIdleAsync((command) =>
|
||||
{
|
||||
for (int k = 0; k < 25 && k < HistorySet.Items.Count; k++)
|
||||
list.Add(new VideoCard(HistorySet.Items[k].Id, "HL"));
|
||||
|
||||
for (int k = 0; k < 25 && k < entries.Count; k++)
|
||||
list.Add(new VideoCard(entries[k]));
|
||||
if (list.Count >= HistorySet.Items.Count)
|
||||
more.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (list.Count >= entries.Count)
|
||||
more.Visibility = Visibility.Collapsed;
|
||||
if (list.Count == 0)
|
||||
clear.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
|
||||
loading.Close();
|
||||
}
|
||||
catch (System.Net.Http.HttpRequestException)
|
||||
{
|
||||
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
loading.Error(e.GetType().ToString(), e.Message);
|
||||
Analytics.TrackEvent("History loading error", new Dictionary<string, string>()
|
||||
Analytics.TrackEvent("Local history loading error", new Dictionary<string, string>()
|
||||
{
|
||||
{ "Exception", e.GetType().ToString() },
|
||||
{ "Message", e.Message },
|
||||
{ "ID", id }
|
||||
{ "Message", e.Message }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void toBrowser_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri(id == "HL" ? "https://www.youtube.com/feed/history" : "https://www.youtube.com/playlist?list=WL"));
|
||||
await Launcher.LaunchUriAsync("https://www.youtube.com/feed/history".ToUri());
|
||||
}
|
||||
|
||||
private void Refresh_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
list.Clear();
|
||||
Initialize();
|
||||
Methods.MainPage.GoToHistory();
|
||||
}
|
||||
|
||||
private void ShowMore_Clicked()
|
||||
private async void ShowMore_Clicked()
|
||||
{
|
||||
for (int k = 25 * page++; k < 25 * page; k++)
|
||||
list.Add(new VideoCard(entries[k]));
|
||||
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
for (int k = 25 * page++; k < 25 * page && k < HistorySet.Items.Count; k++)
|
||||
list.Add(new VideoCard(HistorySet.Items[k].Id, "HL"));
|
||||
|
||||
if (list.Count >= entries.Count)
|
||||
more.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
more.Complete();
|
||||
if (list.Count >= HistorySet.Items.Count)
|
||||
more.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
more.Complete();
|
||||
});
|
||||
}
|
||||
|
||||
private async void Clear_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//TODO: Localize strings
|
||||
MessageDialog dialog = new MessageDialog("Are you sure? This action cannot be undone", "Delete app history");
|
||||
dialog.Commands.Add(new UICommand("No"));
|
||||
dialog.Commands.Add(new UICommand("Yes", (command) =>
|
||||
{
|
||||
HistorySet.Clear();
|
||||
Refresh_Click(this, null);
|
||||
}));
|
||||
|
||||
dialog.CancelCommandIndex = 0;
|
||||
dialog.DefaultCommandIndex = 1;
|
||||
await dialog.ShowAsync();
|
||||
}
|
||||
|
||||
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if(webPage == 0)
|
||||
{
|
||||
webPage++;
|
||||
LoadWeb();
|
||||
}
|
||||
}
|
||||
|
||||
async void LoadWeb()
|
||||
{
|
||||
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
websiteLoading.Refresh();
|
||||
|
||||
SecretsVault.History = await Methods.GetHistory();
|
||||
|
||||
for (int k = 0; k < 25 && k < SecretsVault.History.Count; k++)
|
||||
websiteList.Add(new VideoCard(SecretsVault.History[k], "HL"));
|
||||
|
||||
if (websiteList.Count >= SecretsVault.History.Count)
|
||||
websiteMore.Visibility = Visibility.Collapsed;
|
||||
|
||||
websiteLoading.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
websiteLoading.Error(e.GetType().ToString(), e.Message);
|
||||
Analytics.TrackEvent("History loading error", new Dictionary<string, string>()
|
||||
{
|
||||
{ "Exception", e.GetType().ToString() },
|
||||
{ "Message", e.Message }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async void WebsiteMore_Clicked()
|
||||
{
|
||||
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
for (int k = 25 * webPage++; k < 25 * webPage && k < SecretsVault.History.Count; k++)
|
||||
websiteList.Add(new VideoCard(HistorySet.Items[k].Id, "HL"));
|
||||
|
||||
if (websiteList.Count >= SecretsVault.History.Count)
|
||||
websiteMore.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
websiteMore.Complete();
|
||||
});
|
||||
}
|
||||
|
||||
public void Delete (VideoCard item)
|
||||
{
|
||||
list.DeleteItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user