Core update. Base core features are done (main app doesn't compile)
Related Work Items: #416, #422, #423, #424
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
using Microsoft.Advertising.WinRT.UI;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Services.Store;
|
||||
|
||||
namespace FoxTube.Utils
|
||||
{
|
||||
public static class StoreInterop
|
||||
public static class AddonsInterop
|
||||
{
|
||||
public static bool AdsDisabled { get; private set; } = true;
|
||||
public static string Price { get; private set; }
|
||||
|
||||
private const bool UseTestAds = true;
|
||||
|
||||
private static bool UseTestAds => true;
|
||||
public static string ApplicationId => UseTestAds ? "d25517cb-12d4-4699-8bdc-52040c712cab" : SecretConstants.ApplicationProductId;
|
||||
public static string AdsId => UseTestAds ? "test" : SecretConstants.AdsUnitId;
|
||||
private const string ProProductId = SecretConstants.ProAddonId;
|
||||
|
||||
public static string ApplicationId => UseTestAds ? "d25517cb-12d4-4699-8bdc-52040c712cab" : "9ncqqxjtdlfh";
|
||||
public static string AdsId => UseTestAds ? "test" : "1100044398";
|
||||
private static string ProProductId => "9NP1QK556625";
|
||||
public static NativeAdsManagerV2 AdsManager => new NativeAdsManagerV2(ApplicationId, AdsId);
|
||||
|
||||
public static async Task UpdateStoreState()
|
||||
static AddonsInterop() =>
|
||||
UpdateStoreState();
|
||||
|
||||
public static async void UpdateStoreState()
|
||||
{
|
||||
StoreProductQueryResult requset = await StoreContext.GetDefault().GetAssociatedStoreProductsAsync(new[] { "Durable" });
|
||||
|
||||
@@ -42,17 +46,5 @@ namespace FoxTube.Utils
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async void RequestReview()
|
||||
{
|
||||
StoreRateAndReviewResult result = await StoreContext.GetDefault().RequestRateAndReviewAppAsync();
|
||||
|
||||
if (result.Status == StoreRateAndReviewStatus.Error)
|
||||
Metrics.SendReport(result.ExtendedError, new[] { ErrorAttachmentLog.AttachmentWithText(result.ExtendedJsonData, "extendedJsonData.json") },
|
||||
("Status", result.Status.ToString()),
|
||||
("WasReviewUpdated", result.WasUpdated.ToString()));
|
||||
|
||||
Metrics.AddEvent("Store review request has been recieved");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using FoxTube.Services;
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
using Microsoft.Services.Store.Engagement;
|
||||
using Windows.System;
|
||||
using Windows.Services.Store;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace FoxTube.Utils
|
||||
{
|
||||
public static class Feedback
|
||||
public static class FeedbackInterop
|
||||
{
|
||||
public static bool HasFeedbackHub => StoreServicesFeedbackLauncher.IsSupported();
|
||||
|
||||
@@ -13,15 +15,25 @@ namespace FoxTube.Utils
|
||||
{
|
||||
if (HasFeedbackHub)
|
||||
await StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();
|
||||
else
|
||||
await Launcher.LaunchUriAsync("mailto:feedback@xfox111.net".ToUri());
|
||||
}
|
||||
|
||||
public static async void RequestStoreReview()
|
||||
{
|
||||
StoreRateAndReviewResult result = await StoreContext.GetDefault().RequestRateAndReviewAppAsync();
|
||||
|
||||
if (result.Status == StoreRateAndReviewStatus.Error)
|
||||
Metrics.SendReport(result.ExtendedError, new[] { ErrorAttachmentLog.AttachmentWithText(result.ExtendedJsonData, "extendedJsonData.json") },
|
||||
("Status", result.Status.ToString()),
|
||||
("WasReviewUpdated", result.WasUpdated.ToString()));
|
||||
|
||||
Metrics.AddEvent("Store review request has been received");
|
||||
}
|
||||
|
||||
public static async void PromptFeedback()
|
||||
{
|
||||
if (!HasFeedbackHub)
|
||||
{
|
||||
Settings.PromptFeedback = false;
|
||||
Storage.SetValue(Storage.Settings.PromptFeedback, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,7 +53,7 @@ namespace FoxTube.Utils
|
||||
ContentDialogResult result = await dialog.ShowAsync();
|
||||
|
||||
if (result != ContentDialogResult.None)
|
||||
Settings.PromptFeedback = false;
|
||||
Storage.SetValue(Storage.Settings.PromptFeedback, false);
|
||||
|
||||
if (result == ContentDialogResult.Primary)
|
||||
OpenFeedbackHub();
|
||||
@@ -61,17 +73,17 @@ namespace FoxTube.Utils
|
||||
|
||||
Content = new TextBlock
|
||||
{
|
||||
Text = "Could you leave a feedback on Microsfot Store page? It's very important for me :)"
|
||||
Text = "Could you leave a feedback on Microsoft Store page? It's very important for me :)"
|
||||
}
|
||||
};
|
||||
|
||||
ContentDialogResult result = await dialog.ShowAsync();
|
||||
|
||||
if (result != ContentDialogResult.None)
|
||||
Settings.PromptReview = false;
|
||||
Storage.SetValue(Storage.Settings.PromptReview, false);
|
||||
|
||||
if (result == ContentDialogResult.Primary)
|
||||
StoreInterop.RequestReview();
|
||||
RequestStoreReview();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,19 +6,17 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Storage;
|
||||
using FoxTube.Services;
|
||||
|
||||
namespace FoxTube.Utils
|
||||
{
|
||||
public static class Metrics
|
||||
{
|
||||
static readonly ApplicationDataContainer storage = ApplicationData.Current.RoamingSettings;
|
||||
|
||||
static readonly Stopwatch sw = new Stopwatch();
|
||||
public static TimeSpan Uptime
|
||||
{
|
||||
get => (TimeSpan?)storage.Values["Metrics.SpentTime"] ?? TimeSpan.FromSeconds(0);
|
||||
set => storage.Values["Metrics.SpentTime"] = value;
|
||||
get => Storage.GetValue<TimeSpan?>(Storage.Metrics.Uptime) ?? TimeSpan.FromSeconds(0);
|
||||
set => Storage.SetValue(Storage.Metrics.Uptime, value);
|
||||
}
|
||||
public static string CurrentVersion
|
||||
{
|
||||
@@ -32,11 +30,11 @@ namespace FoxTube.Utils
|
||||
static Metrics()
|
||||
{
|
||||
sw.Start();
|
||||
if (!Settings.AllowAnalytics)
|
||||
if (!Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
|
||||
return;
|
||||
|
||||
AppCenter.Start("45774462-9ea7-438a-96fc-03982666f39e", typeof(Analytics), typeof(Crashes));
|
||||
AppCenter.SetCountryCode(Settings.Region);
|
||||
AppCenter.Start(SecretConstants.MetricsId, typeof(Analytics), typeof(Crashes));
|
||||
AppCenter.SetCountryCode(Storage.GetValue<string>(Storage.Settings.Region));
|
||||
AppCenter.LogLevel = LogLevel.Verbose;
|
||||
}
|
||||
|
||||
@@ -45,23 +43,30 @@ namespace FoxTube.Utils
|
||||
sw.Stop();
|
||||
Uptime += sw.Elapsed;
|
||||
|
||||
AddEvent("Session closed",
|
||||
("Duration", sw.Elapsed.ToString()),
|
||||
("Spend time total", Uptime.ToString()));
|
||||
if (Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
|
||||
AddEvent("Session closed",
|
||||
("Duration", sw.Elapsed.ToString()),
|
||||
("Spend time total", Uptime.ToString()));
|
||||
}
|
||||
|
||||
public static void AddEvent(string eventName, params (string key, string value)[] details) =>
|
||||
Analytics.TrackEvent(eventName,
|
||||
details.Length < 1 ? null :
|
||||
details.Select(i => new KeyValuePair<string, string>(i.key, i.value)) as Dictionary<string, string>);
|
||||
public static void AddEvent(string eventName, params (string key, string value)[] details)
|
||||
{
|
||||
if (Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
|
||||
Analytics.TrackEvent(eventName,
|
||||
details.Length < 1 ? null :
|
||||
details.Select(i => new KeyValuePair<string, string>(i.key, i.value)) as Dictionary<string, string>);
|
||||
}
|
||||
|
||||
public static void SendReport(Exception exception, ErrorAttachmentLog[] logs = null, params (string key, string value)[] details)
|
||||
{
|
||||
logs ??= new ErrorAttachmentLog[0];
|
||||
Crashes.TrackError(exception,
|
||||
details.Length < 1 ? null :
|
||||
details.Select(i => new KeyValuePair<string, string>(i.key, i.value)) as Dictionary<string, string>,
|
||||
logs);
|
||||
if (Storage.GetValue<bool>(Storage.Settings.AllowAnalytics))
|
||||
{
|
||||
logs ??= new ErrorAttachmentLog[0];
|
||||
Crashes.TrackError(exception ?? new Exception("Unknown exception"),
|
||||
details.Length < 1 ? null :
|
||||
details.Select(i => new KeyValuePair<string, string>(i.key, i.value)) as Dictionary<string, string>,
|
||||
logs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FoxTube.Services;
|
||||
|
||||
namespace FoxTube.Utils
|
||||
{
|
||||
public static class SecretConstants
|
||||
{
|
||||
public const string YoutubeApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0";
|
||||
public const string MetricsId = "45774462-9ea7-438a-96fc-03982666f39e";
|
||||
public const string ProAddonId = "9NP1QK556625";
|
||||
public const string AdsUnitId = "1100044398";
|
||||
public const string ApplicationProductId = "9ncqqxjtdlfh";
|
||||
|
||||
public static ClientSecrets[] ClientSecrets { get; } = new ClientSecrets[UserService.MaxUsersCount]
|
||||
{
|
||||
// TODO: Replace with actual secrets
|
||||
new ClientSecrets
|
||||
{
|
||||
ClientId = "349735264870-2ekqlm0a4mkg3mmrfcv90s3qp3o15dq0.apps.googleusercontent.com",
|
||||
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using FoxTube.Services;
|
||||
using System;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.Security.Credentials;
|
||||
|
||||
@@ -25,10 +26,10 @@ namespace FoxTube.Utils
|
||||
public static async void RestartApp(string args) =>
|
||||
await CoreApplication.RequestRestartAsync(args ?? "");
|
||||
|
||||
public static void InitializeFailsafeProtocol()
|
||||
public static async void InitializeFailsafeProtocol()
|
||||
{
|
||||
Metrics.AddEvent("Failsafe protocol initiated");
|
||||
Settings.ResetSettings();
|
||||
await Storage.ResetStorage();
|
||||
PasswordVault passwordVault = new PasswordVault();
|
||||
foreach (PasswordCredential credential in passwordVault.RetrieveAll())
|
||||
passwordVault.Remove(credential);
|
||||
|
||||
Reference in New Issue
Block a user