Merge: example: add 24 game task of Rosetta code
[nit.git] / lib / android / intent / intent_api16.nit
1 # This file is part of NIT (http://www.nitlanguage.org).
2 #
3 # Copyright 2014 Frédéric Vachon <fredvac@gmail.com>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Refines intent module to add API 16 services
18 module intent_api16 is android_api_min 16
19
20 import intent_api15
21
22 in "Java" `{
23 import android.content.Intent;
24 import android.net.Uri;
25 `}
26
27 redef extern class NativeIntent
28 fun set_data_and_normalize(data_uri: JavaString): NativeIntent in "Java" `{ return self.setDataAndNormalize(Uri.parse(data_uri)); `}
29 fun set_data_and_type_and_normalize(data_uri: JavaString, type_: JavaString): NativeIntent in "Java" `{ return self.setDataAndTypeAndNormalize(Uri.parse(data_uri), type_); `}
30 fun set_mime_type_and_normalize(mime_type: JavaString): NativeIntent in "Java" `{ return self.setTypeAndNormalize(mime_type); `}
31 end
32
33 redef class Extra
34 fun html_text: JavaString in "Java" `{ return Intent.EXTRA_HTML_TEXT; `}
35 end
36
37 redef class Flag
38 fun receiver_foreground: Int in "Java" `{ return Intent.FLAG_RECEIVER_FOREGROUND; `}
39 end
40
41 redef class Intent
42 fun set_data_and_normalize(data_uri: String): Intent
43 do
44 sys.jni_env.push_local_frame(1)
45 intent.set_data_and_normalize(data_uri.to_java_string)
46 sys.jni_env.pop_local_frame
47 return self
48 end
49
50 fun set_data_and_type_and_normalize(data_uri: String, type_name: String): Intent
51 do
52 sys.jni_env.push_local_frame(2)
53 intent.set_data_and_type_and_normalize(data_uri.to_java_string, type_name.to_java_string)
54 sys.jni_env.pop_local_frame
55 return self
56 end
57
58 fun set_mime_type_and_normalize(mime_type: String): Intent
59 do
60 sys.jni_env.push_local_frame(1)
61 intent.set_mime_type_and_normalize(mime_type.to_java_string)
62 sys.jni_env.pop_local_frame
63 return self
64 end
65 end