Skip to content

Commit f9b0475

Browse files
committed
chore: Add StoreContext extension for Android
1 parent 61041ae commit f9b0475

File tree

7 files changed

+96
-2
lines changed

7 files changed

+96
-2
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using System.Reflection;
22
using Uno.Foundation.Extensibility;
33
using Uno.UI.Xaml.Media.Imaging.Svg;
4+
using Windows.Services.Store.Internal;
45

56
[assembly: AssemblyMetadata("IsTrimmable", "True")]
67

7-
[assembly: ApiExtension(typeof(IInAppReviewExtension), typeof(InAppReviewExtension))]
8+
[assembly: ApiExtension(typeof(IStoreContextExtension), typeof(StoreContextExtension))]

src/Uno.UI-netcoremobile-only.slnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"solution": {
33
"path": "Uno.UI.sln",
44
"projects": [
5+
"AddIns\\Uno.UI.GooglePlay\\Uno.UI.GooglePlay.netcoremobile.csproj",
56
"AddIns\\Uno.UI.Lottie\\Uno.UI.Lottie.netcoremobile.csproj",
67
"AddIns\\Uno.UI.MSAL\\Uno.UI.MSAL.netcoremobile.csproj",
78
"AddIns\\Uno.UI.Svg\\Uno.UI.Svg.netcoremobile.csproj",

src/Uno.UI.sln

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Uno.UI.Runtime.Skia.X11", "
317317
EndProject
318318
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.WinUI.Graphics3DGL", "AddIns\Uno.WinUI.Graphics3DGL\Uno.WinUI.Graphics3DGL.csproj", "{0F62DA75-6AD9-4F58-B69C-D63CA9053E34}"
319319
EndProject
320+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.UI.GooglePlay.netcoremobile", "AddIns\Uno.UI.GooglePlay\Uno.UI.GooglePlay.netcoremobile.csproj", "{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}"
321+
EndProject
320322
Global
321323
GlobalSection(SolutionConfigurationPlatforms) = preSolution
322324
Debug|Any CPU = Debug|Any CPU
@@ -5772,6 +5774,48 @@ Global
57725774
{0F62DA75-6AD9-4F58-B69C-D63CA9053E34}.Release|x64.Build.0 = Release|Any CPU
57735775
{0F62DA75-6AD9-4F58-B69C-D63CA9053E34}.Release|x86.ActiveCfg = Release|Any CPU
57745776
{0F62DA75-6AD9-4F58-B69C-D63CA9053E34}.Release|x86.Build.0 = Release|Any CPU
5777+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5778+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
5779+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|ARM.ActiveCfg = Debug|Any CPU
5780+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|ARM.Build.0 = Debug|Any CPU
5781+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
5782+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|ARM64.Build.0 = Debug|Any CPU
5783+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
5784+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|iPhone.Build.0 = Debug|Any CPU
5785+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
5786+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
5787+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|x64.ActiveCfg = Debug|Any CPU
5788+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|x64.Build.0 = Debug|Any CPU
5789+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|x86.ActiveCfg = Debug|Any CPU
5790+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Debug|x86.Build.0 = Debug|Any CPU
5791+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|Any CPU.ActiveCfg = Release|Any CPU
5792+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|Any CPU.Build.0 = Release|Any CPU
5793+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|ARM.ActiveCfg = Release|Any CPU
5794+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|ARM.Build.0 = Release|Any CPU
5795+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|ARM64.ActiveCfg = Release|Any CPU
5796+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|ARM64.Build.0 = Release|Any CPU
5797+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|iPhone.ActiveCfg = Release|Any CPU
5798+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|iPhone.Build.0 = Release|Any CPU
5799+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|iPhoneSimulator.ActiveCfg = Release|Any CPU
5800+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|iPhoneSimulator.Build.0 = Release|Any CPU
5801+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|x64.ActiveCfg = Release|Any CPU
5802+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|x64.Build.0 = Release|Any CPU
5803+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|x86.ActiveCfg = Release|Any CPU
5804+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release_NoSamples|x86.Build.0 = Release|Any CPU
5805+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
5806+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|Any CPU.Build.0 = Release|Any CPU
5807+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|ARM.ActiveCfg = Release|Any CPU
5808+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|ARM.Build.0 = Release|Any CPU
5809+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|ARM64.ActiveCfg = Release|Any CPU
5810+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|ARM64.Build.0 = Release|Any CPU
5811+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|iPhone.ActiveCfg = Release|Any CPU
5812+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|iPhone.Build.0 = Release|Any CPU
5813+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
5814+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
5815+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|x64.ActiveCfg = Release|Any CPU
5816+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|x64.Build.0 = Release|Any CPU
5817+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|x86.ActiveCfg = Release|Any CPU
5818+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B}.Release|x86.Build.0 = Release|Any CPU
57755819
EndGlobalSection
57765820
GlobalSection(SolutionProperties) = preSolution
57775821
HideSolutionNode = FALSE
@@ -5916,6 +5960,7 @@ Global
59165960
{93E6D033-52E2-4C2B-A715-A9FC1F609E3D} = {995C1054-AB61-42EE-9A17-C32155BD6D13}
59175961
{37441DE3-088B-4B63-A1E2-E70E39BF4222} = {416684CF-A4E3-4079-B380-3FF0B00E433C}
59185962
{0F62DA75-6AD9-4F58-B69C-D63CA9053E34} = {E872CD33-A455-4DC4-8A87-5FEEC1C39A44}
5963+
{E6E7A247-864E-4EE4-A85F-6CDD2426FA9B} = {E872CD33-A455-4DC4-8A87-5FEEC1C39A44}
59195964
EndGlobalSection
59205965
GlobalSection(ExtensibilityGlobals) = postSolution
59215966
SolutionGuid = {9B2608F4-D82B-4B72-B399-33E822DF01D0}

src/Uno.UWP/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[assembly: InternalsVisibleTo("Uno.UI.Toolkit")]
1212
[assembly: InternalsVisibleTo("Uno.UI.Composition")]
1313
[assembly: InternalsVisibleTo("Uno.UI.Lottie")]
14+
[assembly: InternalsVisibleTo("Uno.UI.GooglePlay")]
1415
[assembly: InternalsVisibleTo("Uno.UI.Svg")]
1516
[assembly: InternalsVisibleTo("Uno.UI.MediaPlayer.Skia.Gtk")]
1617
[assembly: InternalsVisibleTo("Uno.UI.MediaPlayer.WebAssembly")]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
8+
namespace Windows.Services.Store.Internal;
9+
10+
internal interface IStoreContextExtension
11+
{
12+
Task<StoreRateAndReviewResult> RequestRateAndReviewAsync(CancellationToken token);
13+
}

src/Uno.UWP/Services/Store/StoreContext.Android.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
using System;
1+
#nullable enable
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using System.Text;
7+
using System.Threading;
58
using System.Threading.Tasks;
9+
using Uno.Foundation.Extensibility;
10+
using Uno.Foundation.Logging;
611
using Uno.UI;
712
using Windows.Foundation;
13+
using Windows.Services.Store.Internal;
814

915
namespace Windows.Services.Store;
1016

1117
public sealed partial class StoreContext
1218
{
19+
private IStoreContextExtension? _storeContextExtension;
20+
21+
partial void InitializePlatform()
22+
{
23+
if (ApiExtensibility.CreateInstance<IStoreContextExtension>(this) is { } extension)
24+
{
25+
_storeContextExtension = extension;
26+
}
27+
}
28+
1329
public IAsyncOperation<StoreProductResult> GetStoreProductForCurrentAppAsync()
1430
{
1531
return AsyncOperation.FromTask(ct =>
@@ -26,4 +42,18 @@ public IAsyncOperation<StoreProductResult> GetStoreProductForCurrentAppAsync()
2642
});
2743
});
2844
}
45+
46+
private async Task<StoreRateAndReviewResult> RequestRateAndReviewAppTaskAsync(CancellationToken cancellationToken)
47+
{
48+
if (_storeContextExtension is null)
49+
{
50+
if (this.Log().IsEnabled(LogLevel.Error))
51+
{
52+
this.Log().LogError("No StoreContext extension is available. Cannot request rate and review.");
53+
}
54+
55+
return new StoreRateAndReviewResult(StoreRateAndReviewStatus.Error);
56+
}
57+
return await _storeContextExtension.RequestRateAndReviewAsync(cancellationToken);
58+
}
2959
}

src/Uno.UWP/Services/Store/StoreContext.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ public sealed partial class StoreContext
99

1010
private StoreContext()
1111
{
12+
InitializePlatform();
1213
}
1314

15+
partial void InitializePlatform();
16+
1417
/// <summary>
1518
/// Gets a StoreContext object that can be used to access
1619
/// and manage store-related data for the current

0 commit comments

Comments
 (0)