Skip to content

Commit a591371

Browse files
committed
[PSPDFKit.Android] Update to version 4.1.0
1 parent a22f512 commit a591371

29 files changed

+683
-256
lines changed
Lines changed: 48 additions & 0 deletions
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+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using Android.Runtime;
3+
using PSPDFKit.Document;
4+
5+
namespace PSPDFKit.Instant {
6+
public sealed partial class InstantPdfDocument : PdfDocument {
7+
8+
static IntPtr id_setAutomaticLinkGenerationEnabled_Z;
9+
public override unsafe bool AutomaticLinkGenerationEnabled {
10+
get {
11+
return base.AutomaticLinkGenerationEnabled;
12+
}
13+
// Metadata.xml XPath method reference: path="/api/package[@name='com.pspdfkit.instant.document']/class[@name='InstantPdfDocument']/method[@name='setAutomaticLinkGenerationEnabled' and count(parameter)=1 and parameter[1][@type='boolean']]"
14+
[Register ("setAutomaticLinkGenerationEnabled", "(Z)V", "")]
15+
set {
16+
if (id_setAutomaticLinkGenerationEnabled_Z == IntPtr.Zero)
17+
id_setAutomaticLinkGenerationEnabled_Z = JNIEnv.GetMethodID (class_ref, "setAutomaticLinkGenerationEnabled", "(Z)V");
18+
try {
19+
JValue* __args = stackalloc JValue[1];
20+
__args[0] = new JValue (value);
21+
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setAutomaticLinkGenerationEnabled_Z, __args);
22+
} finally {
23+
}
24+
}
25+
}
26+
}
27+
}
Lines changed: 37 additions & 0 deletions
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+
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{24E33E28-51FB-40DE-8091-16D994ACD338}</ProjectGuid>
7+
<ProjectTypeGuids>{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
8+
<OutputType>Library</OutputType>
9+
<RootNamespace>PSPDFKit.Android.Instant</RootNamespace>
10+
<AssemblyName>PSPDFKit.Android.Instant</AssemblyName>
11+
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
12+
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
13+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
14+
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
15+
<AndroidClassParser>class-parse</AndroidClassParser>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug</OutputPath>
22+
<DefineConstants>DEBUG;</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
<AndroidLinkMode>None</AndroidLinkMode>
26+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
27+
<NoWarn>0109,0618,0114,0108,0672,0169</NoWarn>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugSymbols>true</DebugSymbols>
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release</OutputPath>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
<AndroidManagedSymbols>true</AndroidManagedSymbols>
37+
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
38+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
39+
<NoWarn>0109,0618,0114,0108,0672,0169</NoWarn>
40+
</PropertyGroup>
41+
<ItemGroup>
42+
<Reference Include="System" />
43+
<Reference Include="System.Xml" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="Mono.Android" />
46+
<Reference Include="Xamarin.Android.Support.Annotations">
47+
<HintPath>..\packages\Xamarin.Android.Support.Annotations.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Annotations.dll</HintPath>
48+
</Reference>
49+
<Reference Include="Xamarin.Android.Support.Compat">
50+
<HintPath>..\packages\Xamarin.Android.Support.Compat.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Compat.dll</HintPath>
51+
</Reference>
52+
<Reference Include="Xamarin.Android.Support.Core.UI">
53+
<HintPath>..\packages\Xamarin.Android.Support.Core.UI.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Core.UI.dll</HintPath>
54+
</Reference>
55+
<Reference Include="Xamarin.Android.Support.Core.Utils">
56+
<HintPath>..\packages\Xamarin.Android.Support.Core.Utils.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Core.Utils.dll</HintPath>
57+
</Reference>
58+
<Reference Include="Xamarin.Android.Support.Media.Compat">
59+
<HintPath>..\packages\Xamarin.Android.Support.Media.Compat.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Media.Compat.dll</HintPath>
60+
</Reference>
61+
<Reference Include="Xamarin.Android.Support.Fragment">
62+
<HintPath>..\packages\Xamarin.Android.Support.Fragment.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Fragment.dll</HintPath>
63+
</Reference>
64+
<Reference Include="Xamarin.Android.Support.Transition">
65+
<HintPath>..\packages\Xamarin.Android.Support.Transition.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Transition.dll</HintPath>
66+
</Reference>
67+
<Reference Include="Xamarin.Android.Support.v7.RecyclerView">
68+
<HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath>
69+
</Reference>
70+
<Reference Include="Xamarin.Android.Support.Vector.Drawable">
71+
<HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Vector.Drawable.dll</HintPath>
72+
</Reference>
73+
<Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable">
74+
<HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath>
75+
</Reference>
76+
<Reference Include="Xamarin.Android.Support.v7.AppCompat">
77+
<HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
78+
</Reference>
79+
<Reference Include="Xamarin.Android.Support.Design">
80+
<HintPath>..\packages\Xamarin.Android.Support.Design.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.Design.dll</HintPath>
81+
</Reference>
82+
<Reference Include="Xamarin.Android.Support.v7.CardView">
83+
<HintPath>..\packages\Xamarin.Android.Support.v7.CardView.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.v7.CardView.dll</HintPath>
84+
</Reference>
85+
<Reference Include="Xamarin.Android.Support.v4">
86+
<HintPath>..\packages\Xamarin.Android.Support.v4.26.0.2\lib\MonoAndroid80\Xamarin.Android.Support.v4.dll</HintPath>
87+
</Reference>
88+
</ItemGroup>
89+
<ItemGroup>
90+
<Compile Include="Properties\AssemblyInfo.cs" />
91+
<Compile Include="Additions\InstantPdfDocument.cs" />
92+
</ItemGroup>
93+
<ItemGroup>
94+
<None Include="Additions\AboutAdditions.txt" />
95+
<None Include="Jars\AboutJars.txt" />
96+
<None Include="packages.config" />
97+
</ItemGroup>
98+
<ItemGroup>
99+
<TransformFile Include="Transforms\EnumFields.xml" />
100+
<TransformFile Include="Transforms\EnumMethods.xml" />
101+
<TransformFile Include="Transforms\Metadata.xml" />
102+
</ItemGroup>
103+
<ItemGroup>
104+
<EmbeddedReferenceJar Include="Jars\okhttp-3.9.0.jar" />
105+
</ItemGroup>
106+
<ItemGroup>
107+
<ProjectReference Include="..\PSPDFKit.Android\PSPDFKit.Android.csproj">
108+
<Project>{B87BA6DF-8454-41AE-811C-B9D7B7353E5D}</Project>
109+
<Name>PSPDFKit.Android</Name>
110+
</ProjectReference>
111+
</ItemGroup>
112+
<ItemGroup>
113+
<LibraryProjectZip Include="Jars\pspdfkit-instant-4.1.0.aar" />
114+
</ItemGroup>
115+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
116+
<Import Project="..\packages\Xamarin.Android.Support.Annotations.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Annotations.targets')" />
117+
<Import Project="..\packages\Xamarin.Android.Support.Compat.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Compat.targets')" />
118+
<Import Project="..\packages\Xamarin.Android.Support.Core.UI.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Core.UI.targets')" />
119+
<Import Project="..\packages\Xamarin.Android.Support.Core.Utils.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Core.Utils.targets')" />
120+
<Import Project="..\packages\Xamarin.Android.Support.Media.Compat.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Media.Compat.targets')" />
121+
<Import Project="..\packages\Xamarin.Android.Support.Fragment.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Fragment.targets')" />
122+
<Import Project="..\packages\Xamarin.Android.Support.Transition.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Transition.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Transition.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Transition.targets')" />
123+
<Import Project="..\packages\Xamarin.Android.Support.v7.RecyclerView.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.RecyclerView.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v7.RecyclerView.targets')" />
124+
<Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Vector.Drawable.targets')" />
125+
<Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" />
126+
<Import Project="..\packages\Xamarin.Android.Support.v7.AppCompat.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v7.AppCompat.targets')" />
127+
<Import Project="..\packages\Xamarin.Android.Support.Design.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Design.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Design.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.Design.targets')" />
128+
<Import Project="..\packages\Xamarin.Android.Support.v7.CardView.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v7.CardView.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.CardView.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v7.CardView.targets')" />
129+
<Import Project="..\packages\Xamarin.Android.Support.v4.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v4.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v4.26.0.2\build\MonoAndroid80\Xamarin.Android.Support.v4.targets')" />
130+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using Android.App;
4+
5+
// Information about this assembly is defined by the following attributes.
6+
// Change them to the values specific to your project.
7+
8+
[assembly: AssemblyTitle ("PSPDFKit.Android.Instant")]
9+
[assembly: AssemblyDescription ("")]
10+
[assembly: AssemblyConfiguration ("")]
11+
[assembly: AssemblyCompany ("PSPDFKit GmbH.")]
12+
[assembly: AssemblyProduct ("")]
13+
[assembly: AssemblyCopyright ("PSPDFKit GmbH.")]
14+
[assembly: AssemblyTrademark ("")]
15+
[assembly: AssemblyCulture ("")]
16+
17+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
19+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
20+
21+
[assembly: AssemblyVersion ("4.1.0")]
22+
23+
// The following attributes are used to specify the signing key for the assembly,
24+
// if desired. See the Mono documentation for more information about signing.
25+
26+
//[assembly: AssemblyDelaySign(false)]
27+
//[assembly: AssemblyKeyFile("")]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<enum-field-mappings>
3+
<!--
4+
This example converts the constants Fragment_id, Fragment_name,
5+
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
6+
to an enum called Android.Support.V4.App.FragmentTagType with values
7+
Id, Name, and Tag.
8+
9+
<mapping clr-enum-type="Android.Support.V4.App.FragmentTagType" jni-class="android/support/v4/app/FragmentActivity$FragmentTag">
10+
<field clr-name="Id" jni-name="Fragment_id" value="1" />
11+
<field clr-name="Name" jni-name="Fragment_name" value="0" />
12+
<field clr-name="Tag" jni-name="Fragment_tag" value="2" />
13+
</type>
14+
15+
Notes:
16+
- An optional "bitfield" attribute marks the enum type with [Flags].
17+
- For Java interfaces, use "jni-interface" attribute instead of "jni-class" attribute.
18+
-->
19+
</enum-field-mappings>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<enum-method-mappings>
3+
<!--
4+
This example changes the Java method:
5+
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
6+
to be:
7+
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
8+
when bound in C#.
9+
10+
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
11+
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
12+
</mapping>
13+
14+
Notes:
15+
- For Java interfaces, use "jni-interface" attribute instead of "jni-class" attribute.
16+
- To change the type of the return value, use "return" as the parameter name.
17+
- The parameter names will be p0, p1, ... unless you provide JavaDoc file in the project.
18+
-->
19+
</enum-method-mappings>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<metadata>
3+
<!-- Remove non public Api namespaces -->
4+
<remove-node path="/api/package[contains(@name, 'com.pspdfkit.instant.framework')]" />
5+
6+
<!-- Removes any "subclass name" that ends with *Impl.* since it should not be public
7+
This matches for example "PSPDFKitActivityImpl.1" -->
8+
<remove-node path="//class['Impl' = substring(substring-before(@name,'.') , string-length(substring-before(@name,'.')) - 3)]" />
9+
10+
<!-- C# friendly namespaces -->
11+
<attr path="/api/package[@name='com.pspdfkit.instant']" name="managedName">PSPDFKit.Instant</attr>
12+
<attr path="/api/package[@name='com.pspdfkit.instant.client']" name="managedName">PSPDFKit.Instant</attr>
13+
<attr path="/api/package[@name='com.pspdfkit.instant.document']" name="managedName">PSPDFKit.Instant</attr>
14+
<attr path="/api/package[@name='com.pspdfkit.instant.exceptions']" name="managedName">PSPDFKit.Instant</attr>
15+
<attr path="/api/package[@name='com.pspdfkit.instant.listeners']" name="managedName">PSPDFKit.Instant</attr>
16+
<attr path="/api/package[@name='com.pspdfkit.instant.ui']" name="managedName">PSPDFKit.Instant</attr>
17+
18+
<!-- Removed, seems not meant to be for consumer use.-->
19+
<remove-node path="/api/package[@name='com.pspdfkit.instant.client']/class[@name='InstantDocumentDescriptor']/method[@name='getInternal' and count(parameter)=0]" />
20+
<!-- Manually bound in Additions/InstantPdfDocument.cs -->
21+
<remove-node path="/api/package[@name='com.pspdfkit.instant.document']/class[@name='InstantPdfDocument']/method[@name='setAutomaticLinkGenerationEnabled' and count(parameter)=1 and parameter[1][@type='boolean']]" />
22+
</metadata>

0 commit comments

Comments
 (0)