App UI development
Updated and enchanced MainPage Updated Core
This commit is contained in:
@@ -6,7 +6,9 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using Windows.Devices.PointOfService;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace FoxTube
|
||||
{
|
||||
@@ -39,6 +41,9 @@ namespace FoxTube
|
||||
public static bool Belongs<T>(this T obj, params T[] args) =>
|
||||
args.Contains(obj);
|
||||
|
||||
public static bool Belongs(this int number, int lowerLimit, int upperLimit) =>
|
||||
number >= lowerLimit && number <= upperLimit;
|
||||
|
||||
public static string ToHex(this Color color) =>
|
||||
$"#{color.R:X}{color.G:X}{color.B:X}";
|
||||
|
||||
@@ -57,6 +62,17 @@ namespace FoxTube
|
||||
};
|
||||
}
|
||||
|
||||
public static BitmapImage LoadImage (this BitmapImage image, string source, int? height = null, int? width = null)
|
||||
{
|
||||
image.UriSource = source.ToUri();
|
||||
if (height.HasValue)
|
||||
image.DecodePixelHeight = height.Value;
|
||||
if (width.HasValue)
|
||||
image.DecodePixelWidth = width.Value;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
public static TimeSpan GetDuration(this string rawDuration)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -167,9 +167,6 @@
|
||||
<PackageReference Include="Google.Apis.YouTube.v3">
|
||||
<Version>1.45.0.1929</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Advertising.XAML">
|
||||
<Version>10.1811.22001</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AppCenter.Analytics">
|
||||
<Version>3.2.1</Version>
|
||||
</PackageReference>
|
||||
@@ -186,22 +183,16 @@
|
||||
<Version>2.4.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="YoutubeExplode">
|
||||
<Version>5.0.3</Version>
|
||||
<Version>5.0.4</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SDKReference Include="Microsoft.Advertising.Xaml, Version=10.0">
|
||||
<Name>Microsoft Advertising SDK for XAML</Name>
|
||||
</SDKReference>
|
||||
<SDKReference Include="Microsoft.Services.Store.Engagement, Version=10.0">
|
||||
<Name>Microsoft Engagement Framework</Name>
|
||||
</SDKReference>
|
||||
<SDKReference Include="Microsoft.VCLibs, Version=14.0">
|
||||
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
|
||||
</SDKReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="ValueConverters\" />
|
||||
|
||||
@@ -133,7 +133,10 @@ namespace FoxTube
|
||||
return "en-US";
|
||||
}
|
||||
|
||||
public static void ResetSettings() =>
|
||||
public static void ResetSettings()
|
||||
{
|
||||
settings.Values.Clear();
|
||||
ApplicationData.Current.LocalSettings.Values.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace FoxTube
|
||||
{
|
||||
public static class UserManagement
|
||||
{
|
||||
public const int MaxUsersCount = 2;
|
||||
public const int MaxUsersCount = 1;
|
||||
|
||||
#region Private members
|
||||
private static readonly ApplicationDataContainer storage = ApplicationData.Current.LocalSettings;
|
||||
@@ -48,16 +48,13 @@ namespace FoxTube
|
||||
{
|
||||
ClientId = "349735264870-2ekqlm0a4mkg3mmrfcv90s3qp3o15dq0.apps.googleusercontent.com",
|
||||
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
|
||||
},
|
||||
new ClientSecrets // DISABLED
|
||||
{
|
||||
ClientId = "1096685398208-u95rcpkqb4e1ijfmb8jdq3jsg37l8igv.apps.googleusercontent.com",
|
||||
ClientSecret = "IU5bbdjwvmx8ttJoXQ7e6JWd"
|
||||
}
|
||||
};
|
||||
#endregion
|
||||
|
||||
public static Userinfoplus[] Users { get; private set; } = new Userinfoplus[MaxUsersCount];
|
||||
|
||||
public static bool CanAddAccounts => Users.Any(i => i == null);
|
||||
public static User CurrentUser { get; set; }
|
||||
public static bool Authorized => CurrentUser != null;
|
||||
public static ExtendedYouTubeService Service => CurrentUser?.Service ?? _defaultService;
|
||||
@@ -108,7 +105,7 @@ namespace FoxTube
|
||||
|
||||
public static async Task Initialize()
|
||||
{
|
||||
Users = JsonConvert.DeserializeObject<Userinfoplus[]>(storage.Values["UserManagement.Users"] as string);
|
||||
Users = JsonConvert.DeserializeObject<Userinfoplus[]>(storage.Values["UserManagement.Users"] as string ?? "") ?? new Userinfoplus[MaxUsersCount];
|
||||
int? lastUserIndex = storage.Values["UserManagement.LastUser"] as int?;
|
||||
|
||||
if (lastUserIndex.HasValue && Users[lastUserIndex.Value] != null ||
|
||||
@@ -126,8 +123,12 @@ namespace FoxTube
|
||||
string userId = CurrentUser.UserInfo.Id;
|
||||
|
||||
PasswordVault passwordVault = new PasswordVault();
|
||||
PasswordCredential credential = passwordVault.Retrieve("foxtube", userId);
|
||||
passwordVault.Remove(credential);
|
||||
try
|
||||
{
|
||||
PasswordCredential credential = passwordVault.Retrieve("foxtube", userId);
|
||||
passwordVault.Remove(credential);
|
||||
}
|
||||
catch { }
|
||||
|
||||
await CurrentUser.Credential.RevokeTokenAsync(CancellationToken.None);
|
||||
|
||||
@@ -159,20 +160,27 @@ namespace FoxTube
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task SwitchUser(int userIndex)
|
||||
public static async Task<bool> SwitchUser(int userIndex)
|
||||
{
|
||||
Userinfoplus userInfo = Users[userIndex];
|
||||
|
||||
PasswordVault valut = new PasswordVault();
|
||||
PasswordCredential vaultCredential = valut.Retrieve("foxtube", userInfo.Id);
|
||||
if (vaultCredential == null)
|
||||
throw new NullReferenceException("No user found to switch on");
|
||||
try
|
||||
{
|
||||
PasswordCredential vaultCredential = valut.Retrieve("foxtube", userInfo.Id);
|
||||
|
||||
vaultCredential.RetrievePassword();
|
||||
string token = vaultCredential.Password;
|
||||
YouTube.Authorization.UserCredential credential = await AuthorizationHelpers.RestoreUser(ClientSecrets[userIndex], token);
|
||||
vaultCredential.RetrievePassword();
|
||||
string token = vaultCredential.Password;
|
||||
YouTube.Authorization.UserCredential credential = await AuthorizationHelpers.RestoreUser(ClientSecrets[userIndex], token);
|
||||
|
||||
await LoadUser(credential, userIndex);
|
||||
await LoadUser(credential, userIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task LoadUser(YouTube.Authorization.UserCredential credential, int userIndex)
|
||||
@@ -192,15 +200,16 @@ namespace FoxTube
|
||||
private static void UpdateToken(string id, string refreshToken)
|
||||
{
|
||||
PasswordVault passwordVault = new PasswordVault();
|
||||
PasswordCredential vaultCredential = passwordVault.Retrieve("foxtube", id);
|
||||
|
||||
if (vaultCredential == null)
|
||||
try
|
||||
{
|
||||
vaultCredential = new PasswordCredential("foxtube", CurrentUser.UserInfo.Id, refreshToken);
|
||||
PasswordCredential vaultCredential = passwordVault.Retrieve("foxtube", id);
|
||||
vaultCredential.Password = refreshToken;
|
||||
}
|
||||
catch
|
||||
{
|
||||
PasswordCredential vaultCredential = new PasswordCredential("foxtube", CurrentUser.UserInfo.Id, refreshToken);
|
||||
passwordVault.Add(vaultCredential);
|
||||
}
|
||||
else
|
||||
vaultCredential.Password = refreshToken;
|
||||
}
|
||||
|
||||
internal static void SubscriptionsChangedInvoker(User sender, Subscription subscription) =>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Advertising.WinRT.UI;
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Services.Store;
|
||||
@@ -14,12 +13,10 @@ namespace FoxTube.Utils
|
||||
|
||||
private static bool UseTestAds => true;
|
||||
|
||||
private static string ApplicationId => UseTestAds ? "d25517cb-12d4-4699-8bdc-52040c712cab" : "9ncqqxjtdlfh";
|
||||
private static string AdsId => UseTestAds ? "test" : "1100044398";
|
||||
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()
|
||||
{
|
||||
StoreProductQueryResult requset = await StoreContext.GetDefault().GetAssociatedStoreProductsAsync(new[] { "Durable" });
|
||||
|
||||
Reference in New Issue
Block a user