Merge: Intern new
[nit.git] / lib / android / intent / intent_api10.nit
index 00b5766..d2aa796 100644 (file)
@@ -33,7 +33,6 @@ in "Java" `{
 
 extern class NativeIntent in "Java" `{ android.content.Intent `}
        super JavaObject
-       redef type SELF: NativeIntent
 
        fun add_category(category: JavaString) in "Java" `{ recv.addCategory(category); `}
        fun add_flags(flags: Int) in "Java" `{ recv.addFlags((int)flags); `}
@@ -413,6 +412,13 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
        `}
        fun to_native_s: JavaString in "Java" `{ return recv.toString(); `}
        fun to_uri(flags: Int): JavaString in "Java" `{ return recv.toUri((int)flags); `}
+
+       # HACK for bug #845
+       redef fun new_global_ref import sys, Sys.jni_env `{
+               Sys sys = NativeIntent_sys(recv);
+               JNIEnv *env = Sys_jni_env(sys);
+               return (*env)->NewGlobalRef(env, recv);
+       `}
 end
 
 extern class NativePackageManager in "Java" `{ android.content.pm.PackageManager `}
@@ -640,8 +646,8 @@ class Intent
 
        # The general action to be performed
        #
-       # Example :
-       # ~~~
+       # ~~~nitish
+       # # TODO better example
        # intent.action = intent_action.view.to_s
        # ~~~
        fun action=(action: String)
@@ -661,8 +667,8 @@ class Intent
        # Add category to the intent
        # Only activities providing all of the requested categories will be used
        #
-       # Example :
-       # ~~~
+       # ~~~nitish
+       # # TODO better example
        # intent.add_category(intent_category.home.to_s)
        # ~~~
        # Returns `self` allowing fluent programming
@@ -714,8 +720,8 @@ class Intent
 
        # Add a flag to be used by the intent
        #
-       # Example :
-       # ~~~
+       # ~~~nitish
+       # # TODO better example
        # intent.add_flags(intent_flag.activity_new_task)
        # ~~~
        # Returns `self` allowing fluent programming
@@ -1279,7 +1285,7 @@ class Intent
        # Returns `self` allowing fluent programming
        fun []=(name: String, value: nullable Serializable): Intent
        do
-               var serialized_string = new StringOStream
+               var serialized_string = new StringWriter
                var serializer = new JsonSerializer(serialized_string)
                serializer.serialize(value)
 
@@ -1328,11 +1334,11 @@ redef extern class NativeActivity
 end
 
 # Allows user to get values with enum-like syntax : `intent_action.main`
-protected fun intent_action: Action do return once new Action
+fun intent_action: Action do return once new Action
 # Allows user to get values with enum-like syntax : `intent_category.home`
-protected fun intent_category: Category do return once new Category
+fun intent_category: Category do return once new Category
 # Allows user to get values with enum-like syntax : `intent_flag.activity_brought_to_front`
-protected fun intent_flag: Flag do return once new Flag
+fun intent_flag: Flag do return once new Flag
 
 private class StringCopyArray
        var collection = new Array[String]