Archived
1
0

Refactored core

UI navigation framework

Related Work Items: #408, #414, #416
This commit is contained in:
Michael Gordeev
2020-06-15 15:46:38 +03:00
parent c58d846057
commit 787a6e9f48
72 changed files with 2002 additions and 1227 deletions
+13 -10
View File
@@ -5,8 +5,8 @@ using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Windows.ApplicationModel;
using FoxTube.Services;
using System.Globalization;
namespace FoxTube.Utils
{
@@ -15,26 +15,29 @@ namespace FoxTube.Utils
static readonly Stopwatch sw = new Stopwatch();
public static TimeSpan Uptime
{
get => Storage.GetValue<TimeSpan?>(Storage.Metrics.Uptime) ?? TimeSpan.FromSeconds(0);
set => Storage.SetValue(Storage.Metrics.Uptime, value);
get => StorageService.Uptime;
set => StorageService.Uptime = value;
}
public static string CurrentVersion
{
get
{
PackageVersion v = Package.Current.Id.Version;
return $"{v.Major}.{v.Minor}.{v.Revision}.{v.Build}";
// TODO: Remove on release
/*PackageVersion v = Package.Current.Id.Version;
return $"{v.Major}.{v.Minor}.{v.Revision}.{v.Build}";*/
return "2.0 Preview 1";
}
}
static Metrics()
{
sw.Start();
if (!Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
if (!SettingsService.AllowAnalytics)
return;
AppCenter.Start(SecretConstants.MetricsId, typeof(Analytics), typeof(Crashes));
AppCenter.SetCountryCode(Storage.GetValue<string>(Storage.Settings.Region));
AppCenter.SetCountryCode(RegionInfo.CurrentRegion.TwoLetterISORegionName);
AppCenter.LogLevel = LogLevel.Verbose;
}
@@ -43,7 +46,7 @@ namespace FoxTube.Utils
sw.Stop();
Uptime += sw.Elapsed;
if (Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
if (SettingsService.AllowAnalytics)
AddEvent("Session closed",
("Duration", sw.Elapsed.ToString()),
("Spend time total", Uptime.ToString()));
@@ -51,7 +54,7 @@ namespace FoxTube.Utils
public static void AddEvent(string eventName, params (string key, string value)[] details)
{
if (Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
if (SettingsService.AllowAnalytics)
Analytics.TrackEvent(eventName,
details.Length < 1 ? null :
details.Select(i => new KeyValuePair<string, string>(i.key, i.value)) as Dictionary<string, string>);
@@ -59,7 +62,7 @@ namespace FoxTube.Utils
public static void SendReport(Exception exception, ErrorAttachmentLog[] logs = null, params (string key, string value)[] details)
{
if (Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
if (SettingsService.AllowAnalytics)
{
logs ??= new ErrorAttachmentLog[0];
Crashes.TrackError(exception ?? new Exception("Unknown exception"),