Skip to content

Commit 26e9746

Browse files
committed
[User Model] Split Android.Binding project which contains 4 aar files, into 4 binding projects each with their own aar file.
1 parent 5cf2eb2 commit 26e9746

37 files changed

+641
-31
lines changed

OneSignal.sln

+43-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignalSDK.DotNet.Android
88
EndProject
99
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneSignalSDK.DotNet", "OneSignalSDK.DotNet\OneSignalSDK.DotNet.csproj", "{D0FE8BC3-4B5F-45CC-B9F2-1795CB136BB0}"
1010
EndProject
11-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneSignalSDK.DotNet.Android.Binding", "OneSignalSDK.DotNet.Android.Binding\OneSignalSDK.DotNet.Android.Binding.csproj", "{9144F592-91B9-4ACA-BC3C-D771F8319996}"
11+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneSignalSDK.DotNet.Android.Core.Binding", "OneSignalSDK.DotNet.Android.Core.Binding\OneSignalSDK.DotNet.Android.Core.Binding.csproj", "{9144F592-91B9-4ACA-BC3C-D771F8319996}"
1212
EndProject
1313
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneSignalSDK.DotNet.iOS.Binding", "OneSignalSDK.DotNet.iOS.Binding\OneSignalSDK.DotNet.iOS.Binding.csproj", "{967EAABD-4A79-4762-9848-0D5530AA1FA5}"
1414
EndProject
@@ -27,6 +27,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignalNotificationServic
2727
EndProject
2828
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignalLiveActivity.Binding", "Samples\OneSignalLiveActivity.Binding\OneSignalLiveActivity.Binding.csproj", "{EDBB9AC8-010F-4D1E-814A-C7D1D1E64DE9}"
2929
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignalSDK.DotNet.Android.InAppMessages.Binding", "OneSignalSDK.DotNet.Android.InAppMessages.Binding\OneSignalSDK.DotNet.Android.InAppMessages.Binding.csproj", "{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}"
31+
EndProject
32+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignalSDK.DotNet.Android.Location.Binding", "OneSignalSDK.DotNet.Android.Location.Binding\OneSignalSDK.DotNet.Android.Location.Binding.csproj", "{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}"
33+
EndProject
34+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignalSDK.DotNet.Android.Notifications.Binding", "OneSignalSDK.DotNet.Android.Notifications.Binding\OneSignalSDK.DotNet.Android.Notifications.Binding.csproj", "{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}"
35+
EndProject
3036
Global
3137
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3238
Debug|Any CPU = Debug|Any CPU
@@ -145,6 +151,42 @@ Global
145151
{EDBB9AC8-010F-4D1E-814A-C7D1D1E64DE9}.Release|iPhone.Build.0 = Release|iPhone
146152
{EDBB9AC8-010F-4D1E-814A-C7D1D1E64DE9}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
147153
{EDBB9AC8-010F-4D1E-814A-C7D1D1E64DE9}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
154+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
155+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
156+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
157+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Debug|iPhone.Build.0 = Debug|Any CPU
158+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
159+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
160+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
161+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Release|Any CPU.Build.0 = Release|Any CPU
162+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Release|iPhone.ActiveCfg = Release|Any CPU
163+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Release|iPhone.Build.0 = Release|Any CPU
164+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
165+
{C6878B4B-E50C-4CE3-8A72-6AEEBCAECC8C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
166+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
167+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
168+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Debug|iPhone.ActiveCfg = Debug|Any CPU
169+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Debug|iPhone.Build.0 = Debug|Any CPU
170+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
171+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
172+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
173+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Release|Any CPU.Build.0 = Release|Any CPU
174+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Release|iPhone.ActiveCfg = Release|Any CPU
175+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Release|iPhone.Build.0 = Release|Any CPU
176+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
177+
{7E6C2A41-0512-492B-B6D4-D904D8DB0FB9}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
178+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
179+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Debug|Any CPU.Build.0 = Debug|Any CPU
180+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Debug|iPhone.ActiveCfg = Debug|Any CPU
181+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Debug|iPhone.Build.0 = Debug|Any CPU
182+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
183+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
184+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Release|Any CPU.ActiveCfg = Release|Any CPU
185+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Release|Any CPU.Build.0 = Release|Any CPU
186+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Release|iPhone.ActiveCfg = Release|Any CPU
187+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Release|iPhone.Build.0 = Release|Any CPU
188+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
189+
{C3A89BD5-ABBE-4F91-8C02-7723A49BF042}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
148190
EndGlobalSection
149191
GlobalSection(SolutionProperties) = preSolution
150192
HideSolutionNode = FALSE

OneSignalSDK.DotNet.Android.Binding/OneSignalSDK.DotNet.Android.Binding.csproj renamed to OneSignalSDK.DotNet.Android.Core.Binding/OneSignalSDK.DotNet.Android.Core.Binding.csproj

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
<TargetFramework>net6.0-android</TargetFramework>
77
<IsBindingProject>true</IsBindingProject>
88
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
9-
<Nullable>enable</Nullable>
109
<ImplicitUsings>enable</ImplicitUsings>
11-
<RootNamespace>OneSignalSDK.DotNet.Android.Binding</RootNamespace>
10+
<RootNamespace>OneSignalSDK.DotNet.Android.Core.Binding</RootNamespace>
1211
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
1312
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
14-
<AssemblyName>OneSignalSDK.DotNet.Android.Binding</AssemblyName>
13+
<AssemblyName>OneSignalSDK.DotNet.Android.Core.Binding</AssemblyName>
1514
<AndroidSdkBuildToolsVersion Condition="'$(AndroidSdkBuildToolsVersion)' == ''">28.0.3</AndroidSdkBuildToolsVersion>
1615
<AndroidTlsProvider></AndroidTlsProvider>
1716
<AndroidClassParser>class-parse</AndroidClassParser>
@@ -54,11 +53,8 @@
5453
</ItemGroup>
5554
<ItemGroup>
5655
<LibraryProjectZip Include="Jars\core-release.aar" />
57-
<ReferenceJar Include="Jars\in-app-messages-release.aar" />
58-
<ReferenceJar Include="Jars\location-release.aar" />
59-
<ReferenceJar Include="Jars\notifications-release.aar" />
6056
</ItemGroup>
6157
<ItemGroup>
62-
<PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.8.0" />
58+
<PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.8.0.1" />
6359
</ItemGroup>
6460
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Additions allow you to add arbitrary C# to the generated classes
2+
before they are compiled. This can be helpful for providing convenience
3+
methods or adding pure C# classes.
4+
5+
== Adding Methods to Generated Classes ==
6+
7+
Let's say the library being bound has a Rectangle class with a constructor
8+
that takes an x and y position, and a width and length size. It will look like
9+
this:
10+
11+
public partial class Rectangle
12+
{
13+
public Rectangle (int x, int y, int width, int height)
14+
{
15+
// JNI bindings
16+
}
17+
}
18+
19+
Imagine we want to add a constructor to this class that takes a Point and
20+
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
21+
with a partial class containing our new method:
22+
23+
public partial class Rectangle
24+
{
25+
public Rectangle (Point location, Size size) :
26+
this (location.X, location.Y, size.Width, size.Height)
27+
{
28+
}
29+
}
30+
31+
At compile time, the additions class will be added to the generated class
32+
and the final assembly will a Rectangle class with both constructors.
33+
34+
35+
== Adding C# Classes ==
36+
37+
Another thing that can be done is adding fully C# managed classes to the
38+
generated library. In the above example, let's assume that there isn't a
39+
Point class available in Java or our library. The one we create doesn't need
40+
to interact with Java, so we'll create it like a normal class in C#.
41+
42+
By adding a Point.cs file with this class, it will end up in the binding library:
43+
44+
public class Point
45+
{
46+
public int X { get; set; }
47+
public int Y { get; set; }
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
This directory is for Android .jars.
2+
3+
There are 4 types of jars that are supported:
4+
5+
== Input Jar and Embedded Jar ==
6+
7+
This is the jar that bindings should be generated for.
8+
9+
For example, if you were binding the Google Maps library, this would
10+
be Google's "maps.jar".
11+
12+
The difference between EmbeddedJar and InputJar is, EmbeddedJar is to be
13+
embedded in the resulting dll as EmbeddedResource, while InputJar is not.
14+
There are couple of reasons you wouldn't like to embed the target jar
15+
in your dll (the ones that could be internally loaded by <uses-library>
16+
feature e.g. maps.jar, or you cannot embed jars that are under some
17+
proprietary license).
18+
19+
Set the build action for these jars in the properties page to "InputJar".
20+
21+
22+
== Reference Jar and Embedded Reference Jar ==
23+
24+
These are jars that are referenced by the input jar. C# bindings will
25+
not be created for these jars. These jars will be used to resolve
26+
types used by the input jar.
27+
28+
NOTE: Do not add "android.jar" as a reference jar. It will be added automatically
29+
based on the Target Framework selected.
30+
31+
Set the build action for these jars in the properties page to "ReferenceJar".
32+
33+
"EmbeddedJar" works like "ReferenceJar", but like "EmbeddedJar", it is
34+
embedded in your dll. But at application build time, they are not included
35+
in the final apk, like ReferenceJar files.
36+
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<TargetFramework>net6.0-android</TargetFramework>
7+
<IsBindingProject>true</IsBindingProject>
8+
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
9+
<ImplicitUsings>enable</ImplicitUsings>
10+
<RootNamespace>OneSignalSDK.DotNet.Android.InAppMessages.Binding</RootNamespace>
11+
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
12+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
13+
<AssemblyName>OneSignalSDK.DotNet.Android.InAppMessages.Binding</AssemblyName>
14+
<AndroidSdkBuildToolsVersion Condition="'$(AndroidSdkBuildToolsVersion)' == ''">28.0.3</AndroidSdkBuildToolsVersion>
15+
<AndroidTlsProvider></AndroidTlsProvider>
16+
<AndroidClassParser>class-parse</AndroidClassParser>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug</OutputPath>
23+
<DefineConstants>DEBUG;</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
<AndroidLinkMode>None</AndroidLinkMode>
27+
<ConsolePause>false</ConsolePause>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugSymbols>true</DebugSymbols>
31+
<DebugType>full</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release</OutputPath>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
37+
<ConsolePause>false</ConsolePause>
38+
</PropertyGroup>
39+
<ItemGroup>
40+
<Reference Include="System" />
41+
<Reference Include="System.Xml" />
42+
<Reference Include="System.Core" />
43+
<Reference Include="Mono.Android" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<None Include="Additions\AboutAdditions.txt" />
47+
<None Include="Jars\AboutJars.txt" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<TransformFile Include="Transforms\EnumFields.xml" />
51+
<TransformFile Include="Transforms\EnumMethods.xml" />
52+
<TransformFile Include="Transforms\Metadata.xml" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<LibraryProjectZip Include="Jars\in-app-messages-release.aar" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.8.0.1" />
59+
</ItemGroup>
60+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<enum-field-mappings>
2+
<!--
3+
This example converts the constants Fragment_id, Fragment_name,
4+
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
5+
to an enum called Android.Support.V4.App.FragmentTagType with values
6+
Id, Name, and Tag.
7+
8+
<mapping clr-enum-type="Android.Support.V4.App.FragmentTagType" jni-class="android/support/v4/app/FragmentActivity$FragmentTag">
9+
<field clr-name="Id" jni-name="Fragment_id" value="1" />
10+
<field clr-name="Name" jni-name="Fragment_name" value="0" />
11+
<field clr-name="Tag" jni-name="Fragment_tag" value="2" />
12+
</type>
13+
14+
Notes:
15+
- An optional "bitfield" attribute marks the enum type with [Flags].
16+
- For Java interfaces, use "jni-interface" attribute instead of "jni-class" attribute.
17+
-->
18+
</enum-field-mappings>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<enum-method-mappings>
2+
<!--
3+
This example changes the Java method:
4+
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
5+
to be:
6+
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
7+
when bound in C#.
8+
9+
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
10+
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
11+
</mapping>
12+
13+
Notes:
14+
- For Java interfaces, use "jni-interface" attribute instead of "jni-class" attribute.
15+
- To change the type of the return value, use "return" as the parameter name.
16+
- The parameter names will be p0, p1, ... unless you provide JavaDoc file in the project.
17+
-->
18+
</enum-method-mappings>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<metadata>
2+
<attr path="/api/package[@name='com.onesignal.inAppMessages']" name="managedName">Com.OneSignal.Android.InAppMessages</attr>
3+
</metadata>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Additions allow you to add arbitrary C# to the generated classes
2+
before they are compiled. This can be helpful for providing convenience
3+
methods or adding pure C# classes.
4+
5+
== Adding Methods to Generated Classes ==
6+
7+
Let's say the library being bound has a Rectangle class with a constructor
8+
that takes an x and y position, and a width and length size. It will look like
9+
this:
10+
11+
public partial class Rectangle
12+
{
13+
public Rectangle (int x, int y, int width, int height)
14+
{
15+
// JNI bindings
16+
}
17+
}
18+
19+
Imagine we want to add a constructor to this class that takes a Point and
20+
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
21+
with a partial class containing our new method:
22+
23+
public partial class Rectangle
24+
{
25+
public Rectangle (Point location, Size size) :
26+
this (location.X, location.Y, size.Width, size.Height)
27+
{
28+
}
29+
}
30+
31+
At compile time, the additions class will be added to the generated class
32+
and the final assembly will a Rectangle class with both constructors.
33+
34+
35+
== Adding C# Classes ==
36+
37+
Another thing that can be done is adding fully C# managed classes to the
38+
generated library. In the above example, let's assume that there isn't a
39+
Point class available in Java or our library. The one we create doesn't need
40+
to interact with Java, so we'll create it like a normal class in C#.
41+
42+
By adding a Point.cs file with this class, it will end up in the binding library:
43+
44+
public class Point
45+
{
46+
public int X { get; set; }
47+
public int Y { get; set; }
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
This directory is for Android .jars.
2+
3+
There are 4 types of jars that are supported:
4+
5+
== Input Jar and Embedded Jar ==
6+
7+
This is the jar that bindings should be generated for.
8+
9+
For example, if you were binding the Google Maps library, this would
10+
be Google's "maps.jar".
11+
12+
The difference between EmbeddedJar and InputJar is, EmbeddedJar is to be
13+
embedded in the resulting dll as EmbeddedResource, while InputJar is not.
14+
There are couple of reasons you wouldn't like to embed the target jar
15+
in your dll (the ones that could be internally loaded by <uses-library>
16+
feature e.g. maps.jar, or you cannot embed jars that are under some
17+
proprietary license).
18+
19+
Set the build action for these jars in the properties page to "InputJar".
20+
21+
22+
== Reference Jar and Embedded Reference Jar ==
23+
24+
These are jars that are referenced by the input jar. C# bindings will
25+
not be created for these jars. These jars will be used to resolve
26+
types used by the input jar.
27+
28+
NOTE: Do not add "android.jar" as a reference jar. It will be added automatically
29+
based on the Target Framework selected.
30+
31+
Set the build action for these jars in the properties page to "ReferenceJar".
32+
33+
"EmbeddedJar" works like "ReferenceJar", but like "EmbeddedJar", it is
34+
embedded in your dll. But at application build time, they are not included
35+
in the final apk, like ReferenceJar files.
36+
37+

0 commit comments

Comments
 (0)