Skip to content

Commit 6e94fea

Browse files
committed
Implemented IapService
1 parent faeed8e commit 6e94fea

File tree

14 files changed

+156
-52
lines changed

14 files changed

+156
-52
lines changed

SecureFolderFS.AvaloniaUI/App.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private IServiceProvider ConfigureServices(IModifiableFolder settingsFolder)
8383
.AddSingleton<ILocalizationService, LocalizationService>()
8484
.AddSingleton<IFileExplorerService, FileExplorerService>()
8585
.AddSingleton<IClipboardService, ClipboardService>()
86-
.AddSingleton<IUpdateService, UpdateService>()
86+
.AddSingleton<IUpdateService, AvaloniaUpdateService>()
8787

8888
// Conditional (singleton) services
8989
#if DEBUG

SecureFolderFS.AvaloniaUI/ServiceImplementation/UpdateService.cs renamed to SecureFolderFS.AvaloniaUI/ServiceImplementation/AvaloniaUpdateService.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1+
using SecureFolderFS.Sdk.Enums;
2+
using SecureFolderFS.Sdk.Services;
13
using System;
24
using System.Threading;
35
using System.Threading.Tasks;
4-
using SecureFolderFS.Sdk.Enums;
5-
using SecureFolderFS.Sdk.Services;
66

77
namespace SecureFolderFS.AvaloniaUI.ServiceImplementation
88
{
9-
// TODO implement
9+
// TODO: Implement updates on AvaloniaUI
1010
/// <inheritdoc cref="IUpdateService"/>
11-
internal sealed class UpdateService : IUpdateService
11+
internal sealed class AvaloniaUpdateService : IUpdateService
1212
{
13+
/// <inheritdoc/>
1314
public Task<bool> IsSupportedAsync()
1415
{
1516
return Task.FromResult(false);
1617
}
1718

18-
public Task<bool> InitializeAsync()
19-
{
20-
throw new NotImplementedException();
21-
}
22-
23-
public Task<bool> IsUpdateAvailableAsync()
19+
/// <inheritdoc/>
20+
public Task<bool> IsUpdateAvailableAsync(CancellationToken cancellationToken = default)
2421
{
2522
throw new NotImplementedException();
2623
}
2724

25+
/// <inheritdoc/>
2826
public Task<AppUpdateResultType> UpdateAsync(IProgress<double>? progress, CancellationToken cancellationToken = default)
2927
{
3028
throw new NotImplementedException();

SecureFolderFS.AvaloniaUI/UserControls/GraphControl.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public GraphControl()
3232
private async void Chart_Loaded(object sender, RoutedEventArgs e)
3333
{
3434
// Workaround for the application freezing after unlocking at least 2 vaults
35-
// TODO Find the cause of the issue and fix it
35+
// TODO: Find the cause of the issue and fix it
3636
await Task.Delay(500);
3737

3838
Chart.Series = new ISeries[]

SecureFolderFS.Sdk/Services/IUpdateService.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ public interface IUpdateService
1616
/// <returns>A <see cref="Task"/> that represents the asynchronous operation. The value is true if updates are supported, otherwise false.</returns>
1717
Task<bool> IsSupportedAsync();
1818

19-
/// <summary>
20-
/// Initializes resources used for updating the app.
21-
/// </summary>
22-
/// <returns>A <see cref="Task"/> that represents the asynchronous operation. If successful, returns true otherwise false.</returns>
23-
Task<bool> InitializeAsync();
24-
2519
/// <summary>
2620
/// Checks whether there are available updates.
2721
/// </summary>
22+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
2823
/// <returns>A <see cref="Task"/> that represents the asynchronous operation. If available updates were found, returns true otherwise false.</returns>
29-
Task<bool> IsUpdateAvailableAsync();
24+
Task<bool> IsUpdateAvailableAsync(CancellationToken cancellationToken = default);
3025

3126
/// <summary>
3227
/// Starts all app updates in the update queue.

SecureFolderFS.Sdk/ViewModels/Controls/Banners/UpdateBannerViewModel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ public UpdateBannerViewModel()
3737
public async Task InitAsync(CancellationToken cancellationToken = default)
3838
{
3939
var updatesSupported = await UpdateService.IsSupportedAsync();
40-
var isInitialized = updatesSupported && await UpdateService.InitializeAsync();
4140

4241
return; // TODO: Implement updates
43-
if (!updatesSupported || !isInitialized)
42+
if (!updatesSupported)
4443
{
4544
await Task.Delay(800);
4645

SecureFolderFS.Sdk/ViewModels/Views/Wizard/NewVault/EncryptionWizardViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public override Task InitAsync(CancellationToken cancellationToken = default)
4848
foreach (var item in VaultService.GetFileNameCiphers())
4949
{
5050
var name = string.IsNullOrEmpty(item) ? "None" : item;
51-
FileNameCiphers.Add(new(name));
51+
FileNameCiphers.Add(new(item, name));
5252
}
5353

5454
return Task.CompletedTask;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using SecureFolderFS.Sdk.Enums;
2+
using SecureFolderFS.Sdk.Services;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
6+
namespace SecureFolderFS.UI.ServiceImplementation
7+
{
8+
/// <inheritdoc cref="IIapService"/>
9+
public sealed class DebugIapService : IIapService
10+
{
11+
/// <inheritdoc/>
12+
public Task<bool> IsOwnedAsync(IapProductType productType, CancellationToken cancellationToken = default)
13+
{
14+
return Task.FromResult(true);
15+
}
16+
17+
/// <inheritdoc/>
18+
public Task<bool> PurchaseAsync(IapProductType productType, CancellationToken cancellationToken = default)
19+
{
20+
return Task.FromResult(false);
21+
}
22+
23+
/// <inheritdoc/>
24+
public Task<string?> GetPriceAsync(IapProductType productType, CancellationToken cancellationToken = default)
25+
{
26+
return Task.FromResult<string?>(null);
27+
}
28+
}
29+
}

SecureFolderFS.WinUI/App.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using SecureFolderFS.Sdk.Services;
55
using SecureFolderFS.Sdk.Storage;
66
using SecureFolderFS.Sdk.Storage.ModifiableStorage;
7-
using SecureFolderFS.UI;
87
using SecureFolderFS.UI.Helpers;
98
using SecureFolderFS.UI.ServiceImplementation;
109
using SecureFolderFS.UI.Storage.NativeStorage;
@@ -53,7 +52,7 @@ public App()
5352
protected override void OnLaunched(LaunchActivatedEventArgs args)
5453
{
5554
// Get settings folder
56-
var settingsFolderPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, Constants.LocalSettings.SETTINGS_FOLDER_NAME);
55+
var settingsFolderPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, SecureFolderFS.UI.Constants.LocalSettings.SETTINGS_FOLDER_NAME);
5756
_ = Directory.CreateDirectory(settingsFolderPath);
5857
var settingsFolder = new NativeFolder(settingsFolderPath);
5958

@@ -103,7 +102,7 @@ private IServiceProvider ConfigureServices(IModifiableFolder settingsFolder)
103102
// Conditional (singleton) services
104103
#if DEBUG
105104
.AddSingleton<ITelemetryService, DebugTelemetryService>()
106-
.AddSingleton<IIapService, MicrosoftStoreIapService>()
105+
.AddSingleton<IIapService, DebugIapService>()
107106
#else
108107
.AddSingleton<ITelemetryService, AppCenterTelemetryService>()
109108
.AddSingleton<IIapService, MicrosoftStoreIapService>()

SecureFolderFS.WinUI/Constants.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace SecureFolderFS.WinUI
2+
{
3+
internal static class Constants
4+
{
5+
public const string IAP_SECUREFOLDERFS_PLUS_ID = "9N3GB650DVJQ";
6+
}
7+
}

SecureFolderFS.WinUI/Dialogs/PaymentDialog.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
Text="SecureFolderFS+" />
3535
</StackPanel>
3636

37-
<TextBlock FontSize="18" Text="Thank you for your interest in SecureFolderFS!" />
37+
<TextBlock FontSize="18" Text="This feature requires SecureFolderFS+" />
3838
<TextBlock Text="Thanks to your support, we can maintain and keep SecureFolderFS free for everyone!" TextWrapping="WrapWholeWords" />
3939
</StackPanel>
4040
</ContentDialog>

0 commit comments

Comments
 (0)