X-Git-Url: http://nitlanguage.org diff --git a/lib/android/native_app_glue.nit b/lib/android/native_app_glue.nit index 9e9aabf..af3c797 100644 --- a/lib/android/native_app_glue.nit +++ b/lib/android/native_app_glue.nit @@ -114,16 +114,26 @@ in "C body" `{ } `} +# An Android activity context +extern class NativeContext in "Java" `{ android.content.Context `} + super JavaObject +end + +# A wrapper of context +extern class NativeContextWrapper in "Java" `{ android.content.ContextWrapper `} + super NativeContext +end + # Android SDK's `android.app.NativeActivity`. # # Can be used to get anything related to the `Context` of the activity in Java # and as anchor to execute Java UI code. extern class NativeActivity in "Java" `{ android.app.NativeActivity `} - super JavaObject + super NativeContextWrapper end redef class App - redef init + redef fun setup do var native_app_glue = native_app_glue native_app_glue.user_data = self @@ -252,11 +262,11 @@ extern class NdkNativeActivity `{ ANativeActivity * `} # The `NativeActivity`, as in the Java object, associated to `self` fun java_native_activity: NativeActivity `{ return recv->clazz; `} - # Path to this application's internal data directory. + # Path to this application's internal data directory. fun internal_data_path: NativeString `{ return (char*)recv->internalDataPath; `} # Path to this application's external (removable/mountable) data directory. - fun external_data_path: NativeString `{ return (char*)recv->externalDataPath; `} + fun external_data_path: NativeString `{ return (char*)recv->externalDataPath; `} # The platform's SDK version code. fun sdk_version: Int `{ return recv->sdkVersion; `} @@ -291,7 +301,10 @@ extern class NativeAppGlue `{ struct android_app* `} # We use the `userData` field of the C structure to store an handle to # the associated App private fun user_data: App `{ return recv->userData; `} - private fun user_data=(val: App) `{ recv->userData = val; `} + private fun user_data=(val: App) `{ + App_incr_ref(val); + recv->userData = val; + `} # Fill this in with the function to process input events. At this point # the event has already been pre-dispatched, and it will be finished upon