1 # This file is part of NIT (http://www.nitlanguage.org).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Native Java classes for notifications
18 module native_notification
is android_api_min
11
20 import android
::assets_and_resources
23 import android.content.Context;
24 import android.app.NotificationManager;
25 import android.app.Notification;
28 redef class NativeActivity
29 fun notification_manager
: NativeNotificationManager in "Java" `{
30 return (NotificationManager)recv.getSystemService(Context.NOTIFICATION_SERVICE);
34 extern class NativeNotificationManager in "Java" `{ android.app.NotificationManager `}
36 fun notify(tag: JavaString, id: Int, notif: NativeNotification) in "Java" `{
37 recv
.notify
(tag
, (int
)id
, notif
);
40 fun cancel(tag: JavaString, id: Int) in "Java" `{ recv.cancel(tag, (int)id); `}
42 fun cancel_all
in "Java" `{ recv.cancelAll(); `}
45 extern class NativeNotification in "Java" `{ android.app.Notification `}
48 extern class NativeNotificationBuilder in "Java" `{ android.app.Notification$Builder `}
50 new (context: NativeActivity) in "Java" `{ return new Notification.Builder(context); `}
52 fun create
: NativeNotification in "Java" `{
53 // Deprecated since API 16, which introduces `build
`,
54 // refinement and global compilation should prevent warnings.
55 return recv.getNotification();
58 fun title
=(value
: JavaString) in "Java" `{ recv.setContentTitle(value); `}
60 fun text=(value: JavaString) in "Java" `{ recv.setContentText(value); `}
62 fun ticker
=(value
: JavaString) in "Java" `{ recv.setTicker(value); `}
64 fun small_icon=(value: Int) in "Java" `{ recv.setSmallIcon((int)value); `}
66 fun auto_cancel
=(value
: Bool) in "Java" `{ recv.setAutoCancel(value); `}
68 fun number=(value: Int) in "Java" `{ recv.setNumber((int)value); `}
70 fun ongoing
=(value
: Bool) in "Java" `{ recv.setOngoing(value); `}