From 3196ca4dede052f197ccc6ccfaeef1a35bab11b2 Mon Sep 17 00:00:00 2001 From: Vivek Ayer Date: Thu, 11 Feb 2016 13:04:59 -0800 Subject: [PATCH] Android: add barebones binding solution Adding a barebones android binding solution that should be used in conjunction with OneSignal-Android-SDK to enable Xamarin.Android support. --- .../OneSignal.Android.Binding.sln | 17 ++++++ .../OneSignal.Android.Binding.userprefs | 16 ++++++ .../Additions/AboutAdditions.txt | 48 ++++++++++++++++ .../Jars/AboutJars.txt | 37 +++++++++++++ .../OneSignal.Android.Binding.csproj | 55 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 28 ++++++++++ .../Transforms/EnumFields.xml | 18 ++++++ .../Transforms/EnumMethods.xml | 18 ++++++ .../Transforms/Metadata.xml | 9 +++ 9 files changed, 246 insertions(+) create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding.sln create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding.userprefs create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding/Additions/AboutAdditions.txt create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding/Jars/AboutJars.txt create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding/OneSignal.Android.Binding.csproj create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding/Properties/AssemblyInfo.cs create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumFields.xml create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumMethods.xml create mode 100644 OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/Metadata.xml diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding.sln b/OneSignal.Android.Binding/OneSignal.Android.Binding.sln new file mode 100644 index 00000000..b3bc7170 --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignal.Android.Binding", "OneSignal.Android.Binding\OneSignal.Android.Binding.csproj", "{9144F592-91B9-4ACA-BC3C-D771F8319996}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9144F592-91B9-4ACA-BC3C-D771F8319996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9144F592-91B9-4ACA-BC3C-D771F8319996}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9144F592-91B9-4ACA-BC3C-D771F8319996}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9144F592-91B9-4ACA-BC3C-D771F8319996}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding.userprefs b/OneSignal.Android.Binding/OneSignal.Android.Binding.userprefs new file mode 100644 index 00000000..b2c058b4 --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding.userprefs @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding/Additions/AboutAdditions.txt b/OneSignal.Android.Binding/OneSignal.Android.Binding/Additions/AboutAdditions.txt new file mode 100644 index 00000000..c511f1d4 --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding/Additions/AboutAdditions.txt @@ -0,0 +1,48 @@ +Additions allow you to add arbitrary C# to the generated classes +before they are compiled. This can be helpful for providing convenience +methods or adding pure C# classes. + +== Adding Methods to Generated Classes == + +Let's say the library being bound has a Rectangle class with a constructor +that takes an x and y position, and a width and length size. It will look like +this: + +public partial class Rectangle +{ + public Rectangle (int x, int y, int width, int height) + { + // JNI bindings + } +} + +Imagine we want to add a constructor to this class that takes a Point and +Size structure instead of 4 ints. We can add a new file called Rectangle.cs +with a partial class containing our new method: + +public partial class Rectangle +{ + public Rectangle (Point location, Size size) : + this (location.X, location.Y, size.Width, size.Height) + { + } +} + +At compile time, the additions class will be added to the generated class +and the final assembly will a Rectangle class with both constructors. + + +== Adding C# Classes == + +Another thing that can be done is adding fully C# managed classes to the +generated library. In the above example, let's assume that there isn't a +Point class available in Java or our library. The one we create doesn't need +to interact with Java, so we'll create it like a normal class in C#. + +By adding a Point.cs file with this class, it will end up in the binding library: + +public class Point +{ + public int X { get; set; } + public int Y { get; set; } +} diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding/Jars/AboutJars.txt b/OneSignal.Android.Binding/OneSignal.Android.Binding/Jars/AboutJars.txt new file mode 100644 index 00000000..320a154b --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding/Jars/AboutJars.txt @@ -0,0 +1,37 @@ +This directory is for Android .jars. + +There are 4 types of jars that are supported: + +== Input Jar and Embedded Jar == + +This is the jar that bindings should be generated for. + +For example, if you were binding the Google Maps library, this would +be Google's "maps.jar". + +The difference between EmbeddedJar and InputJar is, EmbeddedJar is to be +embedded in the resulting dll as EmbeddedResource, while InputJar is not. +There are couple of reasons you wouldn't like to embed the target jar +in your dll (the ones that could be internally loaded by +feature e.g. maps.jar, or you cannot embed jars that are under some +proprietary license). + +Set the build action for these jars in the properties page to "InputJar". + + +== Reference Jar and Embedded Reference Jar == + +These are jars that are referenced by the input jar. C# bindings will +not be created for these jars. These jars will be used to resolve +types used by the input jar. + +NOTE: Do not add "android.jar" as a reference jar. It will be added automatically +based on the Target Framework selected. + +Set the build action for these jars in the properties page to "ReferenceJar". + +"EmbeddedJar" works like "ReferenceJar", but like "EmbeddedJar", it is +embedded in your dll. But at application build time, they are not included +in the final apk, like ReferenceJar files. + + diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding/OneSignal.Android.Binding.csproj b/OneSignal.Android.Binding/OneSignal.Android.Binding/OneSignal.Android.Binding.csproj new file mode 100644 index 00000000..24c94481 --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding/OneSignal.Android.Binding.csproj @@ -0,0 +1,55 @@ + + + + Debug + AnyCPU + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {9144F592-91B9-4ACA-BC3C-D771F8319996} + Library + OneSignal.Android.Binding + Resources + Assets + True + OneSignal.Android.Binding + v6.0 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + None + false + + + full + true + bin\Release + prompt + 4 + false + false + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding/Properties/AssemblyInfo.cs b/OneSignal.Android.Binding/OneSignal.Android.Binding/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..343e8e16 --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding/Properties/AssemblyInfo.cs @@ -0,0 +1,28 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using Android.App; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("OneSignal.Android.Binding")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("vivek")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.0")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumFields.xml b/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumFields.xml new file mode 100644 index 00000000..e9af0eeb --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumFields.xml @@ -0,0 +1,18 @@ + + + diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumMethods.xml b/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumMethods.xml new file mode 100644 index 00000000..2efa8146 --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/EnumMethods.xml @@ -0,0 +1,18 @@ + + + diff --git a/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/Metadata.xml b/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/Metadata.xml new file mode 100644 index 00000000..68cddb00 --- /dev/null +++ b/OneSignal.Android.Binding/OneSignal.Android.Binding/Transforms/Metadata.xml @@ -0,0 +1,9 @@ + + +