Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Feb 7, 2024
2 parents b4f9cdf + 22ef434 commit 0e17fc7
Show file tree
Hide file tree
Showing 37 changed files with 113 additions and 130 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
@@ -1,10 +1,13 @@
# v3.3.462
# v3.3.463
### Client
* Fix: Updating ServerTokenUrl from the server
* Fix: The "Connect" button for free public server does not work under certain circumstances

* ### Server
* Fix: Updating ServerTokenUrl & ServerSecret from the server
# v3.3.462
### Client
* Fix: Pull the recent tokens from the server & URL

### Server
* Fix: Push the recent tokens to clients

# v3.3.454
### Client
Expand Down
4 changes: 1 addition & 3 deletions Pub/Core/PublishAndroidApp.ps1
Expand Up @@ -73,7 +73,7 @@ if ($apk)
}

# ------------- aab
else
if ($aab)
{
# set app icon
$appIconXmlNode.SetAttribute("android:drawable", "@mipmap/appicon_background");
Expand All @@ -91,8 +91,6 @@ else
/p:ApplicationId=$packageId `
/p:DefineConstants=GOOGLE_PLAY `
/p:AndroidSigningKeyPass=$keystorePass /p:AndroidKeyStore=True;


}

# restore standard icon
Expand Down
4 changes: 2 additions & 2 deletions Pub/PubVersion.json
@@ -1,6 +1,6 @@
{
"Version": "3.3.462",
"BumpTime": "2024-02-04T11:13:50.9100381Z",
"Version": "3.3.463",
"BumpTime": "2024-02-07T22:49:13.5670292Z",
"Prerelease": false,
"DeprecatedVersion": "3.0.416"
}
1 change: 1 addition & 0 deletions Pub/PublishApps.ps1
Expand Up @@ -32,6 +32,7 @@ Remove-Item "$packagesRootDir/ReleaseNote.txt" -ErrorAction Ignore;
& "$solutionDir/VpnHood.Client.Device/_publish.ps1";
& "$solutionDir/VpnHood.Client.Device.WinDivert/_publish.ps1";
& "$solutionDir/VpnHood.Client.App/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Resources/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.WebServer/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Store/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Android.Common/_publish.ps1";
Expand Down
Expand Up @@ -21,7 +21,7 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageProjectUrl>https://github.com/vpnhood/vpnhood</PackageProjectUrl>
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<Version>3.3.462</Version>
<Version>3.3.463</Version>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<BaseOutputPath></BaseOutputPath>
<BaseIntermediateOutputPath />
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Client.App.Android.Connect/MainActivity.cs
Expand Up @@ -43,8 +43,8 @@ protected override void OnCreate(Bundle? savedInstanceState)

var googlePlayAuthenticationService = new GooglePlayAuthenticationService(this, AssemblyInfo.FirebaseClientId);
var authenticationService = new AppAuthenticationService(AssemblyInfo.StoreBaseUri, AssemblyInfo.StoreAppId, googlePlayAuthenticationService, AssemblyInfo.IsDebugMode);
var googlePlayBillingService = GooglePlayBillingService.Create(this);
VpnHoodApp.Instance.AccountService = new AppAccountService(authenticationService, googlePlayBillingService);
var googlePlayBillingService = GooglePlayBillingService.Create(this, authenticationService);
VpnHoodApp.Instance.AccountService = new AppAccountService(authenticationService, googlePlayBillingService, AssemblyInfo.StoreAppId);
}

protected override void OnDestroy()
Expand Down
Expand Up @@ -21,7 +21,7 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageProjectUrl>https://github.com/vpnhood/vpnhood</PackageProjectUrl>
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<Version>3.3.462</Version>
<Version>3.3.463</Version>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<BaseOutputPath></BaseOutputPath>
<BaseIntermediateOutputPath />
Expand Down
53 changes: 43 additions & 10 deletions VpnHood.Client.App.Android.GooglePlay/GooglePlayBillingService.cs
@@ -1,4 +1,5 @@
using Android.BillingClient.Api;
using Org.Apache.Http.Authentication;
using VpnHood.Client.App.Abstractions;

namespace VpnHood.Client.App.Droid.GooglePlay;
Expand All @@ -7,24 +8,41 @@ public class GooglePlayBillingService: IAppBillingService
{
private readonly BillingClient _billingClient;
private readonly Activity _activity;
private readonly IAppAuthenticationService _authenticationService;
private ProductDetails? _productDetails;
private IList<ProductDetails.SubscriptionOfferDetails>? _subscriptionOfferDetails;
private GooglePlayBillingService(Activity activity)
private TaskCompletionSource<string>? _taskCompletionSource;
private GooglePlayBillingService(Activity activity, IAppAuthenticationService authenticationService)
{
var builder = BillingClient.NewBuilder(activity);
builder.SetListener(PurchasesUpdatedListener);
_billingClient = builder.EnablePendingPurchases().Build();
_activity = activity;
_authenticationService = authenticationService;
}

public static GooglePlayBillingService Create(Activity activity)
public static GooglePlayBillingService Create(Activity activity, IAppAuthenticationService authenticationService)
{
return new GooglePlayBillingService(activity);
return new GooglePlayBillingService(activity, authenticationService);
}

private void PurchasesUpdatedListener(BillingResult billingResult, IList<Purchase> purchases)
{
throw new NotImplementedException();
switch (billingResult.ResponseCode)
{
case BillingResponseCode.Ok:
if (purchases.Any())
_taskCompletionSource?.TrySetResult(purchases.First().OrderId);
else
_taskCompletionSource?.TrySetException(new Exception("There is no any order."));
break;
case BillingResponseCode.UserCancelled:
_taskCompletionSource?.TrySetCanceled();
break;
default:
_taskCompletionSource?.TrySetException(CreateBillingResultException(billingResult));
break;
}
}

public async Task<SubscriptionPlan[]> GetSubscriptionPlans()
Expand Down Expand Up @@ -68,10 +86,13 @@ public async Task<SubscriptionPlan[]> GetSubscriptionPlans()
return subscriptionPlans;
}

public async Task Purchase(string userId, string planId)
public async Task<string> Purchase(string planId)
{
await EnsureConnected();

if (_authenticationService.UserId == null)
throw new AuthenticationException();

var offerToken = _subscriptionOfferDetails == null
? throw new NullReferenceException("Could not found subscription offer details.")
: _subscriptionOfferDetails
Expand All @@ -85,18 +106,19 @@ public async Task Purchase(string userId, string planId)
.Build();

var billingFlowParams = BillingFlowParams.NewBuilder()
.SetObfuscatedAccountId(userId)
.SetObfuscatedAccountId(_authenticationService.UserId)
.SetProductDetailsParamsList([productDetailsParam])
.Build();


var billingResult = _billingClient.LaunchBillingFlow(_activity, billingFlowParams);

if (billingResult.ResponseCode != BillingResponseCode.Ok)
throw new Exception(billingResult.DebugMessage)
{
Data = { {"ResponseCode", billingResult.ResponseCode} }
};
throw CreateBillingResultException(billingResult);

_taskCompletionSource = new TaskCompletionSource<string>();
var orderId = await _taskCompletionSource.Task;
return orderId;
}

private async Task EnsureConnected()
Expand All @@ -114,4 +136,15 @@ public void Dispose()
{
_billingClient.Dispose();
}

private static Exception CreateBillingResultException(BillingResult billingResult)
{
if (billingResult.ResponseCode == BillingResponseCode.Ok)
throw new InvalidOperationException("Response code should be not OK.");

return new Exception(billingResult.DebugMessage)
{
Data = { { "ResponseCode", billingResult.ResponseCode } }
};
}
}
Expand Up @@ -21,7 +21,7 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageProjectUrl>https://github.com/vpnhood/vpnhood</PackageProjectUrl>
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<Version>3.3.462</Version>
<Version>3.3.463</Version>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<BaseOutputPath></BaseOutputPath>
<BaseIntermediateOutputPath />
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Client.App.Android/VpnHood.Client.App.Android.csproj
Expand Up @@ -5,8 +5,8 @@
<RootNamespace>VpnHood.Client.App.Droid</RootNamespace>
<OutputType>Exe</OutputType>
<ApplicationId>com.vpnhood.client.android.web</ApplicationId>
<ApplicationVersion>462</ApplicationVersion>
<ApplicationDisplayVersion>3.3.462</ApplicationDisplayVersion>
<ApplicationVersion>463</ApplicationVersion>
<ApplicationDisplayVersion>3.3.463</ApplicationDisplayVersion>
<SupportedOSPlatformVersion>23.0</SupportedOSPlatformVersion>
</PropertyGroup>

Expand All @@ -30,7 +30,7 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageProjectUrl>https://github.com/vpnhood/vpnhood</PackageProjectUrl>
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<Version>3.3.462</Version>
<Version>3.3.463</Version>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<BaseOutputPath></BaseOutputPath>
<BaseIntermediateOutputPath />
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Client.App.Android/_publish_aab.ps1
@@ -1,2 +1,2 @@
& "$PSScriptRoot/../Pub/Core/PublishAndroidApp.ps1" $PSScriptRoot "VpnHoodClient" `
"com.vpnhood.client.android" "google" "appicon_background";
"com.vpnhood.client.android" "google" "appicon_background" -aab;
Binary file modified VpnHood.Client.App.Resources/Resources/SPA.zip
Binary file not shown.
Expand Up @@ -19,14 +19,20 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageProjectUrl>https://github.com/vpnhood/vpnhood</PackageProjectUrl>
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<Version>3.2.437</Version>
<Version>3.3.463</Version>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\VpnHood.Client.App\VpnHood.Client.App.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\VpnHood.png" Link="Resources\VpnHood.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<Compile Update="Resource.Designer.cs">
Expand Down
12 changes: 8 additions & 4 deletions VpnHood.Client.App.Store/AppAccountService.cs
Expand Up @@ -4,21 +4,25 @@
namespace VpnHood.Client.App.Store;

public class AppAccountService(
AppAuthenticationService authenticationService,
IAppBillingService? billingService)
IAppAuthenticationService authenticationService,
IAppBillingService? billingService,
Guid storeAppId)
: IAppAccountService, IDisposable
{
public IAppAuthenticationService Authentication => authenticationService;
public IAppBillingService? Billing => billingService;

public async Task<AppAccount> GetAccount()
public async Task<AppAccount?> GetAccount()
{
if (authenticationService.UserId == null)
return null;

var httpClient = authenticationService.HttpClient;
var authenticationClient = new AuthenticationClient(httpClient);
var currentUser = await authenticationClient.GetCurrentUserAsync();

var currentVpnUserClient = new CurrentVpnUserClient(httpClient);
var activeSubscription = await currentVpnUserClient.ListSubscriptionsAsync(authenticationService.StoreAppId, false, false);
var activeSubscription = await currentVpnUserClient.ListSubscriptionsAsync(storeAppId, false, false);
var subscriptionPlanId = activeSubscription.SingleOrDefault()?.LastOrder;

var appAccount = new AppAccount()
Expand Down
8 changes: 3 additions & 5 deletions VpnHood.Client.App.Store/AppAuthenticationService.cs
Expand Up @@ -17,6 +17,9 @@ public class AppAuthenticationService : IAppAuthenticationService
private ApiKey? _apiKey;
public static string AccountFilePath => Path.Combine(VpnHoodApp.Instance.AppDataFolderPath, "account.json");
public bool IsSignInWithGoogleSupported => _externalAuthenticationService != null;

public string? UserId => ApiKey?.UserId;

public HttpClient HttpClient { get; }
public Guid StoreAppId { get; }

Expand Down Expand Up @@ -119,11 +122,6 @@ public async Task SignOut()
await _externalAuthenticationService.SignOut();
}

public bool IsSignedOut()
{
return ApiKey == null;
}

private async Task SignInToVpnHoodStore(string idToken, bool autoSignUp)
{
var authenticationClient = new AuthenticationClient(_httpClientWithoutAuth);
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Client.App.Store/VpnHood.Client.App.Store.csproj
Expand Up @@ -19,7 +19,7 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageProjectUrl>https://github.com/vpnhood/vpnhood</PackageProjectUrl>
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<Version>3.3.462</Version>
<Version>3.3.463</Version>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
</PropertyGroup>

Expand Down

0 comments on commit 0e17fc7

Please sign in to comment.