Skip to content

Commit

Permalink
add intercom
Browse files Browse the repository at this point in the history
  • Loading branch information
realZhangChi committed Apr 19, 2023
1 parent 66e65c5 commit 0465495
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
/src/WeChat/**/*.aar
/src/DialogX/**/*.aar
/src/PhotoEditor/**/*.aar
/src/Intercom/**/*.aar
.idea/
**/.DS_Store
20 changes: 20 additions & 0 deletions MauiBinding.sln
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PhotoEditor", "PhotoEditor"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PhotoEditor", "src\PhotoEditor\PhotoEditor\PhotoEditor.csproj", "{6CB73F49-5F0F-4A0E-8445-B7DF971206A5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Intercom", "Intercom", "{2076B393-B4E0-40DF-BFA5-CB3240C901A1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Android", "Android", "{200B59BC-D3AE-4246-9D58-065476FA09B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntercomSdkBase", "src\Intercom\Android\IntercomSdkBase\IntercomSdkBase.csproj", "{EEE29163-19A0-4387-B859-76B905BF2630}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntercomSdk", "src\Intercom\Android\IntercomSdk\IntercomSdk.csproj", "{ED0B8E92-C039-4F48-8664-E3D762C64594}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -201,6 +209,14 @@ Global
{6CB73F49-5F0F-4A0E-8445-B7DF971206A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CB73F49-5F0F-4A0E-8445-B7DF971206A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CB73F49-5F0F-4A0E-8445-B7DF971206A5}.Release|Any CPU.Build.0 = Release|Any CPU
{EEE29163-19A0-4387-B859-76B905BF2630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEE29163-19A0-4387-B859-76B905BF2630}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEE29163-19A0-4387-B859-76B905BF2630}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEE29163-19A0-4387-B859-76B905BF2630}.Release|Any CPU.Build.0 = Release|Any CPU
{ED0B8E92-C039-4F48-8664-E3D762C64594}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED0B8E92-C039-4F48-8664-E3D762C64594}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED0B8E92-C039-4F48-8664-E3D762C64594}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED0B8E92-C039-4F48-8664-E3D762C64594}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -245,6 +261,10 @@ Global
{0BEF6D6F-6C3A-42F6-8AEA-953F08645603} = {D90C3D34-C53C-44EB-A0C5-2ECDFA3C2532}
{D13DFF5D-6C74-4A75-8BFC-4E20C13F7566} = {79968845-C170-45B7-AEFC-0D5BFA3DD64B}
{6CB73F49-5F0F-4A0E-8445-B7DF971206A5} = {D13DFF5D-6C74-4A75-8BFC-4E20C13F7566}
{2076B393-B4E0-40DF-BFA5-CB3240C901A1} = {79968845-C170-45B7-AEFC-0D5BFA3DD64B}
{200B59BC-D3AE-4246-9D58-065476FA09B0} = {2076B393-B4E0-40DF-BFA5-CB3240C901A1}
{EEE29163-19A0-4387-B859-76B905BF2630} = {200B59BC-D3AE-4246-9D58-065476FA09B0}
{ED0B8E92-C039-4F48-8664-E3D762C64594} = {200B59BC-D3AE-4246-9D58-065476FA09B0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5E6D9B10-AA5C-45F6-A8F2-3C896718F3A6}
Expand Down
48 changes: 48 additions & 0 deletions src/Intercom/Android/IntercomSdk/Additions/AboutAdditions.txt
Original file line number Diff line number Diff line change
@@ -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; }
}
20 changes: 20 additions & 0 deletions src/Intercom/Android/IntercomSdk/IntercomSdk.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup>
<Version>14.2.0</Version>
<Description>Maui binding library for Intercom Sdk.</Description>
<PackageId>$(PackageIdPrefix).Android.IntercomSdk</PackageId>
<Title>$(PackageIdPrefix).Android.IntercomSdk</Title>
<AssemblyName>$(PackageIdPrefix).Android.$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Xamarin.Firebase.Messaging" Version="123.1.1.1" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/Intercom/Android/IntercomSdk/NativeAsset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://repo1.maven.org/maven2/io/intercom/android/intercom-sdk/14.2.0/intercom-sdk-14.2.0.aar
intercom-sdk.aar
14 changes: 14 additions & 0 deletions src/Intercom/Android/IntercomSdk/Transforms/EnumFields.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<enum-field-mappings>
<!--
This example converts the constants Fragment_id, Fragment_name,
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
to an enum called Android.Support.V4.App.FragmentTagType with values
Id, Name, and Tag.
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
<field jni-name="Fragment_name" clr-name="Name" value="0" />
<field jni-name="Fragment_id" clr-name="Id" value="1" />
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
</mapping>
-->
</enum-field-mappings>
13 changes: 13 additions & 0 deletions src/Intercom/Android/IntercomSdk/Transforms/EnumMethods.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<enum-method-mappings>
<!--
This example changes the Java method:
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
to be:
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
when bound in C#.
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
</mapping>
-->
</enum-method-mappings>
9 changes: 9 additions & 0 deletions src/Intercom/Android/IntercomSdk/Transforms/Metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<metadata>
<!--
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
-->
</metadata>
48 changes: 48 additions & 0 deletions src/Intercom/Android/IntercomSdkBase/Additions/AboutAdditions.txt
Original file line number Diff line number Diff line change
@@ -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; }
}
17 changes: 17 additions & 0 deletions src/Intercom/Android/IntercomSdkBase/IntercomSdkBase.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup>
<Version>14.2.0</Version>
<Description>Maui binding library for Intercom Sdk Base.</Description>
<PackageId>$(PackageIdPrefix).Android.IntercomSdkBase</PackageId>
<Title>$(PackageIdPrefix).Android.IntercomSdkBase</Title>
<AssemblyName>$(PackageIdPrefix).Android.$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>

</Project>
2 changes: 2 additions & 0 deletions src/Intercom/Android/IntercomSdkBase/NativeAsset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://repo1.maven.org/maven2/io/intercom/android/intercom-sdk-base/14.2.0/intercom-sdk-base-14.2.0.aar
intercom-sdk-base.aar
14 changes: 14 additions & 0 deletions src/Intercom/Android/IntercomSdkBase/Transforms/EnumFields.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<enum-field-mappings>
<!--
This example converts the constants Fragment_id, Fragment_name,
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
to an enum called Android.Support.V4.App.FragmentTagType with values
Id, Name, and Tag.
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
<field jni-name="Fragment_name" clr-name="Name" value="0" />
<field jni-name="Fragment_id" clr-name="Id" value="1" />
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
</mapping>
-->
</enum-field-mappings>
13 changes: 13 additions & 0 deletions src/Intercom/Android/IntercomSdkBase/Transforms/EnumMethods.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<enum-method-mappings>
<!--
This example changes the Java method:
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
to be:
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
when bound in C#.
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
</mapping>
-->
</enum-method-mappings>
41 changes: 41 additions & 0 deletions src/Intercom/Android/IntercomSdkBase/Transforms/Metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<metadata>
<!--
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
-->
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.actions')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.activities')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.annotations')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.api')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.blocks')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.conversation')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.exceptions')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.inbox')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.lightbox')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.logger')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.metrics')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.middleware')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.models')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.operator')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.overlay')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.persistence')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.spans')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.state')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.store')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.transforms')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.user')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.utilities')]" />
<remove-node path="/api/package[starts-with(@name, 'io.intercom.android.sdk.views')]" />
<remove-node path="/api/package[@name='io.intercom.android.sdk.identity']/*[starts-with(@name, 'AppConfig')]" />
<remove-node path="/api/package[@name='io.intercom.android.sdk.identity']/class[@name='AppIdentity']" />
<remove-node path="/api/package[@name='io.intercom.android.sdk.identity']/class[@name='UserIdentity']" />
<remove-node path="/api/package[@name='io.intercom.android.sdk']/class[@name='Injector']" />
<remove-node path="/api/package[@name='io.intercom.android.sdk']/class[starts-with(@name, 'IntercomPushManager')]" />
<remove-node path="//*[@deprecated='deprecated']" />
<attr path="/api/package[@name='io.intercom.android.sdk']" name="managedName">Xamarin.Android.Intercom</attr>
<attr path="/api/package[@name='io.intercom.android.sdk.identity']" name="managedName">Xamarin.Android.Intercom.Identity</attr>
<attr path="/api/package[@name='io.intercom.android.sdk.push']" name="managedName">Xamarin.Android.Intercom.Push</attr>
</metadata>

0 comments on commit 0465495

Please sign in to comment.