Skip to content

Commit 5777337

Browse files
committed
[Mono.Android] Import from monodroid/3e934261
(*Now* things are starting to come together...) One of the important infrastructural pieces of Xamarin.Android is Mono.Android.dll, a "binding" for the Android SDK `android.jar` file. Bindings are generated by using the `generator` tool from Java.Interop, along with tools/jnienv-gen, and various other programs. This in turn requires adding a git submodule for Java.Interop. Stitch all these pieces together so that we can take an *API description* (stored in Profiles\api-*.xml.in) and generate a binding for that API description. The generated files are located in obj\$(Configuration)\android-$(ApiLevel), and the resulting Mono.Android.dll is copied to $(topdir)\bin\$(Configuration)\xbuild-frameworks\MonoAndroid\$(XAFrameworkVersion). One SNAFU: currently, Mono.Android.csproj conditinally <Import/>s a Mono.Android.projitems file generated by Java.Interop's generator tool, which contains a list of all the generated files. When the project is first loaded, Mono.Android.projitems will not exist, so on that initial build, source code will be generated but xbuild won't re-read Mono.Android.projitems (once it exists). This will result in a failing build. Simply rebuild the project to get a valid build, or use the `make all` Makefile target.
1 parent 67e216c commit 5777337

File tree

237 files changed

+2710484
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+2710484
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "external/mono"]
22
path = external/mono
33
url = [email protected]:mono/mono.git
4+
[submodule "external/Java.Interop"]
5+
path = external/Java.Interop
6+
url = [email protected]:xamarin/Java.Interop.git

Configuration.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Windows_NT' ">Windows</HostOS>
66
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Unix' And Exists ('/Applications') ">Darwin</HostOS>
77
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Unix' ">Linux</HostOS>
8+
<ManagedRuntime Condition=" '$(ManagedRuntime)' == '' And '$(OS)' != 'Windows_NT' ">mono</ManagedRuntime>
89
<HOME Condition=" '$(HOME)' == '' ">$(HOMEDRIVE)$(HOMEPATH)</HOME>
910
<AndroidToolchainCacheDirectory Condition=" '$(AndroidToolchainCacheDirectory)' == '' ">$(HOME)\android-archives</AndroidToolchainCacheDirectory>
1011
<AndroidToolchainDirectory Condition=" '$(AndroidToolchainDirectory)' == '' ">$(HOME)\android-toolchain</AndroidToolchainDirectory>

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CONFIGURATION = Debug
22
MSBUILD = xbuild /p:Configuration=$(CONFIGURATION) $(MSBUILD_ARGS)
33

44
all:
5+
(cd src/Mono.Android && $(MSBUILD) /t:_GenerateBinding)
56
$(MSBUILD)
67

78
prepare:

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ Then, you may do one of the following:
5959

6060
2. Load `Xamarin.Android.sln` into Xamarin Studio and Build the project.
6161

62+
*Note*: The `Mono.Android` project may *fail* on the first build
63+
because it generates sources, and those sources won't exist on the
64+
initial project load. Rebuild the project should this happen.
65+
6266
# Build Output Directory Structure
6367

6468
There are two configurations, `Debug` and `Release`, controlled by the
@@ -76,4 +80,35 @@ mirrors that of the OS X Xamarin.Android.framework directory structure:
7680
* `bin\$(Configuration)\lib\xbuild\Xamarin\Android`: MSBuild-related support
7781
files and required runtimes used by the MSBuild tooling.
7882
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid`: Xamarin.Android
79-
profile assemblies and facade assemblies.
83+
profiles.
84+
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\v1.0`: Xamarin.Android
85+
Base Class Library assemblies such as `mscorlib.dll`.
86+
* `bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\*`: Contains
87+
`Mono.Android.dll` for a given Xamarin.Android `$(TargetFrameworkVersion)`.
88+
89+
# Xamarin.Android `$(TargetFrameworkVersion)`s
90+
91+
Xamarin.Android uses the MSBuild `$(TargetFrameworkVersion)` mechanism
92+
to provide a separate `Mono.Android.dll` *binding assembly* for each API
93+
level.
94+
95+
This means there is no *single* `Mono.Android.dll`, there is instead a *set*
96+
of them.
97+
98+
This complicates the "mental model" for the `Mono.Android` project, as
99+
a *project* can have only one output, not many (...within reason...).
100+
As such, building the `Mono.Android` project will only generate a single
101+
`Mono.Android.dll`.
102+
103+
To control which API level is bound, set the `$(ApiLevel)` and
104+
`$(XAFrameworkVersion)` properties. `$(ApiLevel)` is the Android API level,
105+
*usually* a number, while `$(XAFrameworkVersion)` is the Xamarin.Android
106+
`$(TargetFrameworkVersion)`.
107+
108+
The default values will target Android API-23, Android 6.0.
109+
110+
For example, to generate `Mono.Android.dll` for API-19 (Android 4.4):
111+
112+
cd src/Mono.Android
113+
xbuild /p:ApiLevel=19 /p:XAFrameworkVersion=v4.4
114+
# creates bin\Debug\lib\xbuild-frameworks\MonoAndroid\v4.4\Mono.Android.dll

Xamarin.Android.sln

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,123 @@ Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "mono-runtimes", "build-tool
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jnienv-gen", "build-tools\jnienv-gen\jnienv-gen.csproj", "{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}"
1313
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{04E3E11E-B47D-4599-8AFC-50515A95E715}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop", "external\Java.Interop\src\Java.Interop\Java.Interop.csproj", "{94BD81F7-B06F-4295-9636-F8A3B6BDC762}"
17+
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "generator", "external\Java.Interop\tools\generator\generator.csproj", "{D14A1B5C-2060-4930-92BE-F7190256C735}"
19+
EndProject
20+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Xamarin.Android.NamingCustomAttributes", "external\Java.Interop\src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.shproj", "{74598F5C-B8CC-4CE6-8EE2-AB9CA1400076}"
21+
EndProject
22+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Java.Interop.Tools.TypeNameMappings", "external\Java.Interop\src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings.shproj", "{E706B6F2-5562-4765-8F07-8CF84A797B30}"
23+
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Android", "src\Mono.Android\Mono.Android.csproj", "{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}"
25+
EndProject
1426
Global
1527
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1628
Debug|AnyCPU = Debug|AnyCPU
1729
Release|AnyCPU = Release|AnyCPU
30+
XAIntegrationDebug|Any CPU = XAIntegrationDebug|Any CPU
31+
XAIntegrationRelease|Any CPU = XAIntegrationRelease|Any CPU
32+
Debug|x86 = Debug|x86
33+
Release|x86 = Release|x86
1834
EndGlobalSection
1935
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2036
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
2137
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.Build.0 = Release|AnyCPU
2238
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
2339
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|AnyCPU.Build.0 = Debug|Any CPU
40+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
41+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
42+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
43+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
44+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|x86.ActiveCfg = Debug|Any CPU
45+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|x86.Build.0 = Debug|Any CPU
46+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|x86.ActiveCfg = Release|Any CPU
47+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|x86.Build.0 = Release|Any CPU
2448
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
2549
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|AnyCPU.Build.0 = Release|AnyCPU
2650
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
2751
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|AnyCPU.Build.0 = Debug|Any CPU
52+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
53+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
54+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
55+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
56+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|x86.ActiveCfg = Debug|Any CPU
57+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Debug|x86.Build.0 = Debug|Any CPU
58+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|x86.ActiveCfg = Release|Any CPU
59+
{E8492EFB-D14A-4F32-AA28-88848322ECEA}.Release|x86.Build.0 = Release|Any CPU
2860
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
2961
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|AnyCPU.Build.0 = Debug|Any CPU
3062
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|AnyCPU.ActiveCfg = Release|Any CPU
3163
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|AnyCPU.Build.0 = Release|Any CPU
64+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
65+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
66+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
67+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
68+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|x86.ActiveCfg = Debug|Any CPU
69+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Debug|x86.Build.0 = Debug|Any CPU
70+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|x86.ActiveCfg = Release|Any CPU
71+
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}.Release|x86.Build.0 = Release|Any CPU
3272
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
3373
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|AnyCPU.Build.0 = Debug|Any CPU
3474
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|AnyCPU.ActiveCfg = Release|Any CPU
3575
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|AnyCPU.Build.0 = Release|Any CPU
76+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
77+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
78+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
79+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
80+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|x86.ActiveCfg = Debug|Any CPU
81+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Debug|x86.Build.0 = Debug|Any CPU
82+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|x86.ActiveCfg = Release|Any CPU
83+
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}.Release|x86.Build.0 = Release|Any CPU
84+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
85+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|AnyCPU.Build.0 = Debug|Any CPU
86+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|AnyCPU.ActiveCfg = Release|Any CPU
87+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|AnyCPU.Build.0 = Release|Any CPU
88+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationDebug|Any CPU.ActiveCfg = XAIntegrationDebug|Any CPU
89+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationDebug|Any CPU.Build.0 = XAIntegrationDebug|Any CPU
90+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationRelease|Any CPU.ActiveCfg = XAIntegrationRelease|Any CPU
91+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.XAIntegrationRelease|Any CPU.Build.0 = XAIntegrationRelease|Any CPU
92+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|x86.ActiveCfg = Debug|Any CPU
93+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Debug|x86.Build.0 = Debug|Any CPU
94+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|x86.ActiveCfg = Release|Any CPU
95+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762}.Release|x86.Build.0 = Release|Any CPU
96+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|AnyCPU.ActiveCfg = Debug|x86
97+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|AnyCPU.Build.0 = Debug|x86
98+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|AnyCPU.ActiveCfg = Release|x86
99+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|AnyCPU.Build.0 = Release|x86
100+
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|x86
101+
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationDebug|Any CPU.Build.0 = Debug|x86
102+
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|x86
103+
{D14A1B5C-2060-4930-92BE-F7190256C735}.XAIntegrationRelease|Any CPU.Build.0 = Debug|x86
104+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|x86.ActiveCfg = Debug|x86
105+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Debug|x86.Build.0 = Debug|x86
106+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|x86.ActiveCfg = Release|x86
107+
{D14A1B5C-2060-4930-92BE-F7190256C735}.Release|x86.Build.0 = Release|x86
108+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
109+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|AnyCPU.Build.0 = Debug|Any CPU
110+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|AnyCPU.ActiveCfg = Release|Any CPU
111+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|AnyCPU.Build.0 = Release|Any CPU
112+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
113+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
114+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
115+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
116+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|x86.ActiveCfg = Debug|Any CPU
117+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Debug|x86.Build.0 = Debug|Any CPU
118+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|x86.ActiveCfg = Release|Any CPU
119+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.Release|x86.Build.0 = Release|Any CPU
36120
EndGlobalSection
37121
GlobalSection(NestedProjects) = preSolution
38122
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
39123
{E8492EFB-D14A-4F32-AA28-88848322ECEA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
40124
{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
41125
{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
126+
{94BD81F7-B06F-4295-9636-F8A3B6BDC762} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
127+
{D14A1B5C-2060-4930-92BE-F7190256C735} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
128+
{74598F5C-B8CC-4CE6-8EE2-AB9CA1400076} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
129+
{E706B6F2-5562-4765-8F07-8CF84A797B30} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
130+
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
42131
EndGlobalSection
43132
GlobalSection(MonoDevelopProperties) = preSolution
44133
Policies = $0

external/Java.Interop

Submodule Java.Interop added at 28fbb01
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using Android.Content;
3+
using Android.Runtime;
4+
5+
using Java.Interop;
6+
7+
#if ANDROID_5
8+
9+
namespace Android.Accounts {
10+
11+
public partial class AccountManager {
12+
13+
public static AccountManager FromContext (Context context)
14+
{
15+
return context.GetSystemService (Context.AccountService) as AccountManager;
16+
}
17+
18+
WeakReference weak_implementor_AccountsUpdated;
19+
public event EventHandler<AccountsUpdateEventArgs> AccountsUpdated {
20+
add {
21+
AndroidEventHelper.AddEventHandler<IOnAccountsUpdateListener, IOnAccountsUpdateListenerImplementor>(
22+
ref weak_implementor_AccountsUpdated,
23+
() => new IOnAccountsUpdateListenerImplementor (this),
24+
SetOnAccountsUpdatedListener,
25+
__h => __h.Handler += value);
26+
}
27+
remove {
28+
AndroidEventHelper.RemoveEventHandler<IOnAccountsUpdateListener, IOnAccountsUpdateListenerImplementor>(
29+
ref weak_implementor_AccountsUpdated,
30+
IOnAccountsUpdateListenerImplementor.__IsEmpty,
31+
SetOnAccountsUpdatedListener,
32+
__h => __h.Handler -= value);
33+
}
34+
}
35+
36+
void SetOnAccountsUpdatedListener (IOnAccountsUpdateListener value)
37+
{
38+
AddOnAccountsUpdatedListener (value, null, false);
39+
}
40+
}
41+
}
42+
43+
#endif // ANDROID_5
44+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#if ANDROID_11
2+
3+
using System;
4+
5+
using Android.Runtime;
6+
7+
namespace Android.Animation {
8+
9+
partial class Animator {
10+
11+
WeakReference dispatcher;
12+
AnimatorEventDispatcher Dispatcher {
13+
get {
14+
if (dispatcher == null || !dispatcher.IsAlive) {
15+
dispatcher = new WeakReference (new AnimatorEventDispatcher ());
16+
AddListener ((AnimatorEventDispatcher) dispatcher.Target);
17+
}
18+
return (AnimatorEventDispatcher) dispatcher.Target;
19+
}
20+
}
21+
22+
public event EventHandler AnimationCancel {
23+
add {
24+
Dispatcher.AnimationCancel += value;
25+
}
26+
remove {
27+
Dispatcher.AnimationCancel -= value;
28+
}
29+
}
30+
31+
public event EventHandler AnimationEnd {
32+
add {
33+
Dispatcher.AnimationEnd += value;
34+
}
35+
remove {
36+
Dispatcher.AnimationEnd -= value;
37+
}
38+
}
39+
40+
public event EventHandler AnimationRepeat {
41+
add {
42+
Dispatcher.AnimationRepeat += value;
43+
}
44+
remove {
45+
Dispatcher.AnimationRepeat -= value;
46+
}
47+
}
48+
49+
public event EventHandler AnimationStart {
50+
add {
51+
Dispatcher.AnimationStart += value;
52+
}
53+
remove {
54+
Dispatcher.AnimationStart -= value;
55+
}
56+
}
57+
}
58+
59+
[Register ("mono/android/animation/AnimatorEventDispatcher")]
60+
internal class AnimatorEventDispatcher : Java.Lang.Object, Animator.IAnimatorListener {
61+
62+
public AnimatorEventDispatcher ()
63+
: base (
64+
JNIEnv.StartCreateInstance ("mono/android/animation/AnimatorEventDispatcher", "()V"),
65+
JniHandleOwnership.TransferLocalRef)
66+
{
67+
JNIEnv.FinishCreateInstance (Handle, "()V");
68+
}
69+
70+
public EventHandler AnimationCancel;
71+
public EventHandler AnimationEnd;
72+
public EventHandler AnimationRepeat;
73+
public EventHandler AnimationStart;
74+
75+
public void OnAnimationCancel (Animator animation)
76+
{
77+
var h = AnimationCancel;
78+
if (h != null)
79+
h (animation, EventArgs.Empty);
80+
}
81+
82+
public void OnAnimationEnd (Animator animation)
83+
{
84+
var h = AnimationEnd;
85+
if (h != null)
86+
h (animation, EventArgs.Empty);
87+
}
88+
89+
public void OnAnimationRepeat (Animator animation)
90+
{
91+
var h = AnimationRepeat;
92+
if (h != null)
93+
h (animation, EventArgs.Empty);
94+
}
95+
96+
public void OnAnimationStart (Animator animation)
97+
{
98+
var h = AnimationStart;
99+
if (h != null)
100+
h (animation, EventArgs.Empty);
101+
}
102+
}
103+
}
104+
105+
#endif
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#if ANDROID_11
2+
3+
using System;
4+
using Android.Runtime;
5+
6+
namespace Android.Animation
7+
{
8+
public partial class AnimatorSet
9+
{
10+
private static IntPtr id_setDuration_J;
11+
[Register ("setDuration", "(J)Landroid/animation/Animator;", "GetSetDuration_JHandler")]
12+
public override Animator SetDuration (long duration)
13+
{
14+
if (id_setDuration_J == IntPtr.Zero)
15+
id_setDuration_J = JNIEnv.GetMethodID (class_ref, "setDuration", "(J)Landroid/animation/Animator;");
16+
17+
if (base.GetType () == this.ThresholdType) {
18+
return Java.Lang.Object.GetObject<AnimatorSet> (
19+
JNIEnv.CallObjectMethod (base.Handle, id_setDuration_J, new JValue (duration)),
20+
JniHandleOwnership.TransferLocalRef);
21+
} else {
22+
return Java.Lang.Object.GetObject<AnimatorSet> (
23+
JNIEnv.CallNonvirtualObjectMethod (
24+
base.Handle,
25+
this.ThresholdClass,
26+
JNIEnv.GetMethodID (ThresholdClass, "setDuration", "(J)Landroid/animation/Animator;"),
27+
new JValue (duration)),
28+
JniHandleOwnership.TransferLocalRef);
29+
}
30+
}
31+
32+
private static Delegate cb_setDuration_J;
33+
34+
private static Delegate GetSetDuration_JHandler ()
35+
{
36+
if (cb_setDuration_J == null)
37+
cb_setDuration_J = JNINativeWrapper.CreateDelegate (new Func<IntPtr, IntPtr, long, IntPtr> (n_SetDuration_J));
38+
return cb_setDuration_J;
39+
}
40+
41+
private static IntPtr n_SetDuration_J (IntPtr jnienv, IntPtr native__this, long duration)
42+
{
43+
AnimatorSet @object = Java.Lang.Object.GetObject<AnimatorSet> (native__this, JniHandleOwnership.DoNotTransfer);
44+
return JNIEnv.ToJniHandle (@object.SetDuration (duration));
45+
}
46+
}
47+
}
48+
49+
#endif

0 commit comments

Comments
 (0)