-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
237 changed files
with
2,710,484 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "external/mono"] | ||
path = external/mono | ||
url = git@github.com:mono/mono.git | ||
[submodule "external/Java.Interop"] | ||
path = external/Java.Interop | ||
url = git@github.com:xamarin/Java.Interop.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Java.Interop
added at
28fbb0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using Android.Content; | ||
using Android.Runtime; | ||
|
||
using Java.Interop; | ||
|
||
#if ANDROID_5 | ||
|
||
namespace Android.Accounts { | ||
|
||
public partial class AccountManager { | ||
|
||
public static AccountManager FromContext (Context context) | ||
{ | ||
return context.GetSystemService (Context.AccountService) as AccountManager; | ||
} | ||
|
||
WeakReference weak_implementor_AccountsUpdated; | ||
public event EventHandler<AccountsUpdateEventArgs> AccountsUpdated { | ||
add { | ||
AndroidEventHelper.AddEventHandler<IOnAccountsUpdateListener, IOnAccountsUpdateListenerImplementor>( | ||
ref weak_implementor_AccountsUpdated, | ||
() => new IOnAccountsUpdateListenerImplementor (this), | ||
SetOnAccountsUpdatedListener, | ||
__h => __h.Handler += value); | ||
} | ||
remove { | ||
AndroidEventHelper.RemoveEventHandler<IOnAccountsUpdateListener, IOnAccountsUpdateListenerImplementor>( | ||
ref weak_implementor_AccountsUpdated, | ||
IOnAccountsUpdateListenerImplementor.__IsEmpty, | ||
SetOnAccountsUpdatedListener, | ||
__h => __h.Handler -= value); | ||
} | ||
} | ||
|
||
void SetOnAccountsUpdatedListener (IOnAccountsUpdateListener value) | ||
{ | ||
AddOnAccountsUpdatedListener (value, null, false); | ||
} | ||
} | ||
} | ||
|
||
#endif // ANDROID_5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#if ANDROID_11 | ||
|
||
using System; | ||
|
||
using Android.Runtime; | ||
|
||
namespace Android.Animation { | ||
|
||
partial class Animator { | ||
|
||
WeakReference dispatcher; | ||
AnimatorEventDispatcher Dispatcher { | ||
get { | ||
if (dispatcher == null || !dispatcher.IsAlive) { | ||
dispatcher = new WeakReference (new AnimatorEventDispatcher ()); | ||
AddListener ((AnimatorEventDispatcher) dispatcher.Target); | ||
} | ||
return (AnimatorEventDispatcher) dispatcher.Target; | ||
} | ||
} | ||
|
||
public event EventHandler AnimationCancel { | ||
add { | ||
Dispatcher.AnimationCancel += value; | ||
} | ||
remove { | ||
Dispatcher.AnimationCancel -= value; | ||
} | ||
} | ||
|
||
public event EventHandler AnimationEnd { | ||
add { | ||
Dispatcher.AnimationEnd += value; | ||
} | ||
remove { | ||
Dispatcher.AnimationEnd -= value; | ||
} | ||
} | ||
|
||
public event EventHandler AnimationRepeat { | ||
add { | ||
Dispatcher.AnimationRepeat += value; | ||
} | ||
remove { | ||
Dispatcher.AnimationRepeat -= value; | ||
} | ||
} | ||
|
||
public event EventHandler AnimationStart { | ||
add { | ||
Dispatcher.AnimationStart += value; | ||
} | ||
remove { | ||
Dispatcher.AnimationStart -= value; | ||
} | ||
} | ||
} | ||
|
||
[Register ("mono/android/animation/AnimatorEventDispatcher")] | ||
internal class AnimatorEventDispatcher : Java.Lang.Object, Animator.IAnimatorListener { | ||
|
||
public AnimatorEventDispatcher () | ||
: base ( | ||
JNIEnv.StartCreateInstance ("mono/android/animation/AnimatorEventDispatcher", "()V"), | ||
JniHandleOwnership.TransferLocalRef) | ||
{ | ||
JNIEnv.FinishCreateInstance (Handle, "()V"); | ||
} | ||
|
||
public EventHandler AnimationCancel; | ||
public EventHandler AnimationEnd; | ||
public EventHandler AnimationRepeat; | ||
public EventHandler AnimationStart; | ||
|
||
public void OnAnimationCancel (Animator animation) | ||
{ | ||
var h = AnimationCancel; | ||
if (h != null) | ||
h (animation, EventArgs.Empty); | ||
} | ||
|
||
public void OnAnimationEnd (Animator animation) | ||
{ | ||
var h = AnimationEnd; | ||
if (h != null) | ||
h (animation, EventArgs.Empty); | ||
} | ||
|
||
public void OnAnimationRepeat (Animator animation) | ||
{ | ||
var h = AnimationRepeat; | ||
if (h != null) | ||
h (animation, EventArgs.Empty); | ||
} | ||
|
||
public void OnAnimationStart (Animator animation) | ||
{ | ||
var h = AnimationStart; | ||
if (h != null) | ||
h (animation, EventArgs.Empty); | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#if ANDROID_11 | ||
|
||
using System; | ||
using Android.Runtime; | ||
|
||
namespace Android.Animation | ||
{ | ||
public partial class AnimatorSet | ||
{ | ||
private static IntPtr id_setDuration_J; | ||
[Register ("setDuration", "(J)Landroid/animation/Animator;", "GetSetDuration_JHandler")] | ||
public override Animator SetDuration (long duration) | ||
{ | ||
if (id_setDuration_J == IntPtr.Zero) | ||
id_setDuration_J = JNIEnv.GetMethodID (class_ref, "setDuration", "(J)Landroid/animation/Animator;"); | ||
|
||
if (base.GetType () == this.ThresholdType) { | ||
return Java.Lang.Object.GetObject<AnimatorSet> ( | ||
JNIEnv.CallObjectMethod (base.Handle, id_setDuration_J, new JValue (duration)), | ||
JniHandleOwnership.TransferLocalRef); | ||
} else { | ||
return Java.Lang.Object.GetObject<AnimatorSet> ( | ||
JNIEnv.CallNonvirtualObjectMethod ( | ||
base.Handle, | ||
this.ThresholdClass, | ||
JNIEnv.GetMethodID (ThresholdClass, "setDuration", "(J)Landroid/animation/Animator;"), | ||
new JValue (duration)), | ||
JniHandleOwnership.TransferLocalRef); | ||
} | ||
} | ||
|
||
private static Delegate cb_setDuration_J; | ||
|
||
private static Delegate GetSetDuration_JHandler () | ||
{ | ||
if (cb_setDuration_J == null) | ||
cb_setDuration_J = JNINativeWrapper.CreateDelegate (new Func<IntPtr, IntPtr, long, IntPtr> (n_SetDuration_J)); | ||
return cb_setDuration_J; | ||
} | ||
|
||
private static IntPtr n_SetDuration_J (IntPtr jnienv, IntPtr native__this, long duration) | ||
{ | ||
AnimatorSet @object = Java.Lang.Object.GetObject<AnimatorSet> (native__this, JniHandleOwnership.DoNotTransfer); | ||
return JNIEnv.ToJniHandle (@object.SetDuration (duration)); | ||
} | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.