Archived
1
0

222: Fixed

227: Additional fixes (final)
Introduced new settings storing system

Related Work Items: #222, #227
This commit is contained in:
Michael Gordeev
2018-12-23 22:22:22 +03:00
parent 91fd3f6ab9
commit efb07fda10
8 changed files with 96 additions and 229 deletions
+1
View File
@@ -244,6 +244,7 @@ namespace FoxTube
private void OnSuspending(object sender, SuspendingEventArgs e) private void OnSuspending(object sender, SuspendingEventArgs e)
{ {
var deferral = e.SuspendingOperation.GetDeferral(); var deferral = e.SuspendingOperation.GetDeferral();
SettingsStorage.ExportSettings();
DownloadAgent.QuitPrompt(); DownloadAgent.QuitPrompt();
deferral.Complete(); deferral.Complete();
} }
+16
View File
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Web; using System.Web;
using Windows.ApplicationModel.Core; using Windows.ApplicationModel.Core;
@@ -33,6 +34,21 @@ namespace FoxTube
return new Uri(url); return new Uri(url);
} }
public static void ForEach<T>(this IEnumerable<T> array, Action<T> action)
{
array.ToList().ForEach(action);
}
public static T Find<T>(this IEnumerable<T> array, Predicate<T> match)
{
return array.ToList().Find(match);
}
public static List<T> FindAll<T>(this IEnumerable<T> array, Predicate<T> match)
{
return array.ToList().FindAll(match);
}
public static string ReplaceInvalidChars(this string str, char newValue) public static string ReplaceInvalidChars(this string str, char newValue)
{ {
foreach (char i in Path.GetInvalidFileNameChars()) foreach (char i in Path.GetInvalidFileNameChars())
+10 -2
View File
@@ -176,11 +176,19 @@ namespace FoxTube
public static async void SaveData() public static async void SaveData()
{ {
storage.Values["settings"] = JsonConvert.SerializeObject(settings); storage.Values["settings"] = JsonConvert.SerializeObject(settings);
ExportSettings();
}
bool[] notificationsSettings = new[] { VideoNotifications, DevNotifications }; public static async void ExportSettings()
await FileIO.WriteTextAsync( {
try
{
bool[] notificationsSettings = new[] { VideoNotifications, DevNotifications };
await FileIO.WriteTextAsync(
await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting), await ApplicationData.Current.RoamingFolder.CreateFileAsync("notifications.json", CreationCollisionOption.ReplaceExisting),
JsonConvert.SerializeObject(notificationsSettings)); JsonConvert.SerializeObject(notificationsSettings));
}
catch { }
} }
} }
} }
+3 -9
View File
@@ -15,13 +15,10 @@
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged" SelectedIndex="1"> <Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged">
<PivotItem Header="Recommended" Name="recommended"> <PivotItem Header="Recommended" Name="recommended">
<ScrollViewer> <ScrollViewer>
<StackPanel> <StackPanel/>
<pages:VideoGrid/>
<controls:ShowMore Clicked="RecMore_Clicked"/>
</StackPanel>
</ScrollViewer> </ScrollViewer>
</PivotItem> </PivotItem>
<PivotItem Header="Trending" Name="trending"> <PivotItem Header="Trending" Name="trending">
@@ -34,10 +31,7 @@
</PivotItem> </PivotItem>
<PivotItem Header="Subscriptions" Name="subscriptions"> <PivotItem Header="Subscriptions" Name="subscriptions">
<ScrollViewer> <ScrollViewer>
<StackPanel> <StackPanel/>
<pages:VideoGrid/>
<controls:ShowMore Clicked="SubsMore_Clicked"/>
</StackPanel>
</ScrollViewer> </ScrollViewer>
</PivotItem> </PivotItem>
</Pivot> </Pivot>
+15 -120
View File
@@ -1,68 +1,39 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Globalization;
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using Windows.Storage; using Windows.Storage;
using Windows.UI.Text;
using FoxTube.Controls; using FoxTube.Controls;
using FoxTube.Pages; using FoxTube.Pages;
using System.Collections.ObjectModel; using System.Globalization;
using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube namespace FoxTube
{ {
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// Home page
/// </summary> /// </summary>
public sealed partial class Home : Page public sealed partial class Home : Page
{ {
private bool recLoaded = false;
private bool trendLoaded = false; private bool trendLoaded = false;
private bool subsLoaded = false;
VideoGrid recGrid, trendGrid, subsGrid; VideoGrid trendGrid;
ShowMore recMore, trendMore, subsMore; ShowMore trendMore;
LoadingPage loading; LoadingPage loading;
string trendToken, recToken; string trendToken;
Dictionary<string, string> subsTokens = new Dictionary<string, string>(); Dictionary<string, string> subsTokens = new Dictionary<string, string>();
string reg; string reg;
public Home() public Home()
{ {
this.InitializeComponent(); InitializeComponent();
try reg = CultureInfo.GetCultures(CultureTypes.AllCultures).Find(i => i.IetfLanguageTag == SettingsStorage.Region).IetfLanguageTag.Remove(0, 3);
{
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToLower().Remove(0, 3);
}
catch (ArgumentOutOfRangeException)
{
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper();
}
recGrid = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
trendGrid = ((trending.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid; trendGrid = ((trending.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
subsGrid = ((subscriptions.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid; trendMore = ((trending.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
recMore = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
trendMore = ((trending.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore; ;
subsMore = ((subscriptions.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
loading = grid.Children[2] as LoadingPage; loading = grid.Children[2] as LoadingPage;
@@ -74,11 +45,6 @@ namespace FoxTube
Methods.MainPage.GoToHome(); Methods.MainPage.GoToHome();
} }
private void RecMore_Clicked()
{
throw new NotImplementedException();
}
private async void TrendMore_Clicked() private async void TrendMore_Clicked()
{ {
try try
@@ -99,7 +65,7 @@ namespace FoxTube
foreach (Video vid in response.Items) foreach (Video vid in response.Items)
{ {
VideoCard vCard = new VideoCard(vid.Id); VideoCard vCard = new VideoCard(vid.Id);
recGrid.Add(vCard); trendGrid.Add(vCard);
} }
trendMore.Complete(); trendMore.Complete();
} }
@@ -109,45 +75,6 @@ namespace FoxTube
} }
} }
private async void SubsMore_Clicked()
{
try
{
List<SearchResult> items = new List<SearchResult>();
Dictionary<string, string> pairs = new Dictionary<string, string>();
SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
request.Type = "video";
request.MaxResults = 10;
request.Order = SearchResource.ListRequest.OrderEnum.Date;
foreach (KeyValuePair<string, string> i in subsTokens)
{
request.ChannelId = i.Key;
request.PageToken = i.Value;
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult result in response.Items)
items.Add(result);
if (response.NextPageToken != null)
pairs.Add(i.Value, response.NextPageToken);
}
if (pairs.Count == 0)
subsMore.Complete(true);
else
subsTokens = pairs;
items = items.OrderByDescending(x => x.Snippet.PublishedAt).ToList();
foreach (SearchResult i in items)
subsGrid.Add(new VideoCard(i.Id.VideoId));
subsMore.Complete();
}
catch
{
subsMore.Complete(true);
}
}
public void Initialize() public void Initialize()
{ {
if(SecretsVault.IsAuthorized) if(SecretsVault.IsAuthorized)
@@ -164,11 +91,11 @@ namespace FoxTube
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
loading.Close(); loading.Close();
if (pivot.SelectedItem == recommended && !recLoaded) if (pivot.SelectedItem == recommended)
LoadRecommendations(); LoadRecommendations();
else if (pivot.SelectedItem == trending && !trendLoaded) else if (pivot.SelectedItem == trending && !trendLoaded)
LoadTrending(); LoadTrending();
else if (pivot.SelectedItem == subscriptions && !subsLoaded) else if (pivot.SelectedItem == subscriptions)
LoadSubscriptions(); LoadSubscriptions();
} }
@@ -215,63 +142,31 @@ namespace FoxTube
try try
{ {
loading.Refresh(); loading.Refresh();
throw new NotImplementedException("This page has not implemented yet.");
throw new NotImplementedException();
loading.Close();
recLoaded = true;
} }
catch (System.Net.Http.HttpRequestException) catch (System.Net.Http.HttpRequestException)
{ {
recLoaded = false;
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch (Exception e) catch (Exception e)
{ {
recLoaded = false;
loading.Error(e.GetType().ToString(), e.Message); loading.Error(e.GetType().ToString(), e.Message);
} }
} }
async void LoadSubscriptions() void LoadSubscriptions()
{ {
try try
{ {
loading.Refresh(); loading.Refresh();
List<SearchResult> items = new List<SearchResult>(); throw new NotImplementedException("This page has not implemented yet.");
SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
request.Type = "video";
request.MaxResults = 10;
request.Order = SearchResource.ListRequest.OrderEnum.Date;
foreach (Subscription i in SecretsVault.Subscriptions)
{
request.ChannelId = i.Snippet.ResourceId.ChannelId;
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult result in response.Items)
items.Add(result);
if (response.NextPageToken != null)
subsTokens.Add(i.Snippet.ResourceId.ChannelId, response.NextPageToken);
}
if (subsTokens.Count == 0)
subsMore.Complete(true);
items = items.OrderByDescending(x => x.Snippet.PublishedAt).ToList();
foreach (SearchResult i in items)
subsGrid.Add(new VideoCard(i.Id.VideoId));
loading.Close();
subsLoaded = true;
} }
catch (System.Net.Http.HttpRequestException) catch (System.Net.Http.HttpRequestException)
{ {
subsLoaded = false;
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch (Exception e) catch (Exception e)
{ {
subsLoaded = false;
loading.Error(e.GetType().ToString(), e.Message); loading.Error(e.GetType().ToString(), e.Message);
} }
} }
+2 -8
View File
@@ -69,12 +69,6 @@ namespace FoxTube
SetTitleBar(); SetTitleBar();
} }
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
content.Navigate(typeof(Home));
}
public Video GetCurrentItem() public Video GetCurrentItem()
{ {
try { return (videoPlaceholder.Content as VideoPage).item; } try { return (videoPlaceholder.Content as VideoPage).item; }
@@ -243,10 +237,10 @@ namespace FoxTube
await dialog.ShowAsync(); await dialog.ShowAsync();
} }
content.Navigate(typeof(Home));
if (videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
GoToVideo((videoPlaceholder.Content as VideoPage).videoId); GoToVideo((videoPlaceholder.Content as VideoPage).videoId);
nav.SelectedItem = toHome;
} }
private async void feedback_Click(object sender, TappedRoutedEventArgs e) private async void feedback_Click(object sender, TappedRoutedEventArgs e)
+7 -23
View File
@@ -3,29 +3,17 @@ using FoxTube.Pages;
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage; using Windows.Storage;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using Windows.System; using Windows.System;
using System.Globalization;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube namespace FoxTube
{ {
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// Search page
/// </summary> /// </summary>
public sealed partial class Search : Page public sealed partial class Search : Page
{ {
@@ -40,7 +28,7 @@ namespace FoxTube
public Search() public Search()
{ {
this.InitializeComponent(); InitializeComponent();
loading = grid.Children[2] as LoadingPage; loading = grid.Children[2] as LoadingPage;
list = ((grid.Children[0] as ScrollViewer).Content as StackPanel).Children[4] as VideoGrid; list = ((grid.Children[0] as ScrollViewer).Content as StackPanel).Children[4] as VideoGrid;
more = ((grid.Children[0] as ScrollViewer).Content as StackPanel).Children[5] as ShowMore; more = ((grid.Children[0] as ScrollViewer).Content as StackPanel).Children[5] as ShowMore;
@@ -108,14 +96,10 @@ namespace FoxTube
} }
request.Q = arg.Term; request.Q = arg.Term;
request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"]; request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"];
try
{ request.RegionCode = CultureInfo.GetCultures(CultureTypes.AllCultures).Find(i => i.IetfLanguageTag == SettingsStorage.Region).IetfLanguageTag.Remove(0, 3);
request.RelevanceLanguage = settings.Values["region"].ToString().Remove(2).ToLower(); request.RelevanceLanguage = CultureInfo.GetCultures(CultureTypes.AllCultures).Find(i => i.IetfLanguageTag == SettingsStorage.Region).TwoLetterISOLanguageName;
}
catch (ArgumentOutOfRangeException)
{
request.RelevanceLanguage = settings.Values["region"].ToString().ToLower();
}
request.MaxResults = 48; request.MaxResults = 48;
try try
{ {
+42 -67
View File
@@ -1,49 +1,42 @@
using Newtonsoft.Json; using System.Globalization;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.Core; using Windows.ApplicationModel.Core;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI; using Windows.UI;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages.SettingsPages namespace FoxTube.Pages.SettingsPages
{ {
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// Settings page with general preferences
/// </summary> /// </summary>
public sealed partial class General : Page public sealed partial class General : Page
{ {
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
public General() public General()
{ {
this.InitializeComponent(); InitializeComponent();
language.SelectedIndex = (string)settings.Values["language"] == "en-US"? 0 : 1; language.SelectedItem = language.Items.Find(i => ((ComboBoxItem)i).Tag.ToString() == SettingsStorage.Language);
quality.SelectedItem = quality.Items.ToList().Find(x => (x as ComboBoxItem).Tag as string == (string)settings.Values["quality"]); CultureInfo.GetCultures(CultureTypes.AllCultures).FindAll(i => !i.IsNeutralCulture).ForEach(i =>
{
region.Items.Add(new ComboBoxItem
{
Content = i.DisplayName,
Tag = i.IetfLanguageTag
});
if (i.IetfLanguageTag == SettingsStorage.Region)
region.SelectedItem = region.Items.Last();
});
safeSearch.SelectedIndex = SettingsStorage.SafeSearch;
newVideo.IsOn = (bool)settings.Values["newVideoNotification"]; quality.SelectedItem = quality.Items.ToList().Find(i => ((ComboBoxItem)i).Tag.ToString() == SettingsStorage.VideoQuality);
mobileWarning.IsOn = SettingsStorage.CheckConnection;
autoplay.IsOn = SettingsStorage.Autoplay;
mobileWarning.IsOn = (bool)settings.Values["moblieWarning"]; newVideo.IsOn = SettingsStorage.VideoNotifications;
autoplay.IsOn = (bool)settings.Values["videoAutoplay"]; devNews.IsOn = SettingsStorage.DevNotifications;
safeSearch.SelectedIndex = (int)settings.Values["safeSearch"]; switch(SettingsStorage.Theme)
switch((int)settings.Values["themeMode"])
{ {
case 0: case 0:
light.IsChecked = true; light.IsChecked = true;
@@ -55,77 +48,63 @@ namespace FoxTube.Pages.SettingsPages
system.IsChecked = true; system.IsChecked = true;
break; break;
} }
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
region.Items.Add(culture.DisplayName);
if (culture.Name == (string)settings.Values["region"])
region.SelectedIndex = region.Items.Count - 1;
}
} }
private void language_SelectionChanged(object sender, SelectionChangedEventArgs e) private void language_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if ((string)settings.Values["language"] != (language.SelectedItem as ComboBoxItem).Tag.ToString()) if (SettingsStorage.Language == (language.SelectedItem as ComboBoxItem).Tag.ToString())
{ return;
settings.Values["language"] = (language.SelectedItem as ComboBoxItem).Tag.ToString();
restartNote.Visibility = Visibility.Visible; SettingsStorage.Language = (language.SelectedItem as ComboBoxItem).Tag.ToString();
} restartNote.Visibility = Visibility.Visible;
else
restartNote.Visibility = Visibility.Collapsed;
} }
private void quality_SelectionChanged(object sender, SelectionChangedEventArgs e) private void quality_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
settings.Values["quality"] = (quality.SelectedItem as ComboBoxItem).Tag as string; SettingsStorage.VideoQuality = (quality.SelectedItem as ComboBoxItem).Tag as string;
} }
private void mobileWarning_Toggled(object sender, RoutedEventArgs e) private void mobileWarning_Toggled(object sender, RoutedEventArgs e)
{ {
settings.Values["moblieWarning"] = mobileWarning.IsOn; SettingsStorage.CheckConnection = mobileWarning.IsOn;
} }
private void autoplay_Toggled(object sender, RoutedEventArgs e) private void autoplay_Toggled(object sender, RoutedEventArgs e)
{ {
SettingsStorage.Autoplay = autoplay.IsOn;
settings.Values["videoAutoplay"] = autoplay.IsOn;
} }
private async void notification_IsEnabledChanged(object sender, RoutedEventArgs e) private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
{ {
settings.Values["newVideoNotification"] = newVideo.IsOn; SettingsStorage.VideoNotifications = 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) private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
settings.Values["region"] = CultureInfo.GetCultures(CultureTypes.AllCultures)[region.SelectedIndex].Name; SettingsStorage.Region = CultureInfo.GetCultures(CultureTypes.AllCultures)[region.SelectedIndex].Name;
} }
private void safeSearch_SelectionChanged(object sender, SelectionChangedEventArgs e) private void safeSearch_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
settings.Values["safeSearch"] = safeSearch.SelectedIndex; SettingsStorage.SafeSearch = safeSearch.SelectedIndex;
} }
private void RadioButton_Checked(object sender, RoutedEventArgs e) private void RadioButton_Checked(object sender, RoutedEventArgs e)
{ {
if (sender == light && (int)settings.Values["themeMode"] != 0) if (sender == light && SettingsStorage.Theme != 0)
{ {
settings.Values["themeMode"] = 0; SettingsStorage.Theme = 0;
Methods.MainPage.RequestedTheme = ElementTheme.Light; Methods.MainPage.RequestedTheme = ElementTheme.Light;
} }
if (sender == dark && (int)settings.Values["themeMode"] != 1) else if (sender == dark && SettingsStorage.Theme != 1)
{ {
settings.Values["themeMode"] = 1; SettingsStorage.Theme = 1;
Methods.MainPage.RequestedTheme = ElementTheme.Dark; Methods.MainPage.RequestedTheme = ElementTheme.Dark;
} }
if (sender == system && (int)settings.Values["themeMode"] != 2) else if (sender == system && SettingsStorage.Theme != 2)
{ {
settings.Values["themeMode"] = 2; SettingsStorage.Theme = 2;
Color uiTheme = (new Windows.UI.ViewManagement.UISettings()).GetColorValue(Windows.UI.ViewManagement.UIColorType.Background); Color uiTheme = new Windows.UI.ViewManagement.UISettings().GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
if (uiTheme == Colors.Black) if (uiTheme == Colors.Black)
Methods.MainPage.RequestedTheme = ElementTheme.Dark; Methods.MainPage.RequestedTheme = ElementTheme.Dark;
else else
@@ -139,13 +118,9 @@ namespace FoxTube.Pages.SettingsPages
CoreApplication.Exit(); CoreApplication.Exit();
} }
private async void devNews_Toggled(object sender, RoutedEventArgs e) private void devNews_Toggled(object sender, RoutedEventArgs e)
{ {
settings.Values["devnews"] = devNews.IsOn; SettingsStorage.DevNotifications = 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));
} }
} }
} }