1 /* |
|
2 BEEM is a videoconference application on the Android Platform. |
|
3 |
|
4 Copyright (C) 2009 by Frederic-Charles Barthelery, |
|
5 Jean-Manuel Da Silva, |
|
6 Nikita Kozlov, |
|
7 Philippe Lago, |
|
8 Jean Baptiste Vergely, |
|
9 Vincent Veronis. |
|
10 |
|
11 This file is part of BEEM. |
|
12 |
|
13 BEEM is free software: you can redistribute it and/or modify |
|
14 it under the terms of the GNU General Public License as published by |
|
15 the Free Software Foundation, either version 3 of the License, or |
|
16 (at your option) any later version. |
|
17 |
|
18 BEEM is distributed in the hope that it will be useful, |
|
19 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 GNU General Public License for more details. |
|
22 |
|
23 You should have received a copy of the GNU General Public License |
|
24 along with BEEM. If not, see <http://www.gnu.org/licenses/>. |
|
25 |
|
26 Please send bug reports with examples or suggestions to |
|
27 contact@beem-project.com or http://dev.beem-project.com/ |
|
28 */ |
|
29 |
|
30 package com.beem.project.beem.ui; |
|
31 |
|
32 import android.app.Notification; |
|
33 import android.app.NotificationManager; |
|
34 import android.app.PendingIntent; |
|
35 import android.content.Context; |
|
36 import android.content.Intent; |
|
37 import android.widget.RemoteViews; |
|
38 |
|
39 import com.beem.project.beem.R; |
|
40 |
|
41 /** |
|
42 * SingletonClass notification. |
|
43 * @author Vincent V. <marseille@beem-project.com> |
|
44 */ |
|
45 public class BeemNotification extends Notification { |
|
46 |
|
47 private static Context mContext; |
|
48 private NotificationManager mNotificationManager; |
|
49 |
|
50 private static BeemNotification instance = null; |
|
51 |
|
52 /** |
|
53 * Constructor. |
|
54 */ |
|
55 protected BeemNotification(Context c) { |
|
56 super(); |
|
57 mContext = c; |
|
58 mNotificationManager = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); |
|
59 Intent notificationIntent = new Intent(); |
|
60 contentIntent = PendingIntent.getActivity(c, (int) System.currentTimeMillis(), notificationIntent, |
|
61 PendingIntent.FLAG_UPDATE_CURRENT); |
|
62 icon = R.drawable.beem_status_icon; |
|
63 flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; |
|
64 contentView = new RemoteViews(mContext.getPackageName(), R.layout.notification); |
|
65 contentView.setTextViewText(R.id.pseudo, "Beem"); |
|
66 } |
|
67 |
|
68 public static void BindNotification(Context c) { |
|
69 if (instance == null) { |
|
70 instance = new BeemNotification(c); |
|
71 } |
|
72 instance.contentView.setTextViewText(R.id.msgstatus, "TODO: X messages unread"); |
|
73 instance.mNotificationManager.notify(R.string.app_name, instance); |
|
74 |
|
75 } |
|
76 |
|
77 public static void StartSyncNotification(Context c) { |
|
78 if (instance == null) { |
|
79 instance = new BeemNotification(c); |
|
80 } |
|
81 instance.icon = R.drawable.ic_menu_sync; |
|
82 instance.mNotificationManager.notify(R.string.app_name, instance); |
|
83 } |
|
84 |
|
85 public static void StopSyncNotification(Context c) { |
|
86 if (instance == null) { |
|
87 instance = new BeemNotification(c); |
|
88 } |
|
89 instance.icon = R.drawable.beem_status_icon; |
|
90 instance.mNotificationManager.notify(R.string.app_name, instance); |
|
91 } |
|
92 |
|
93 public void deleteNotification(int id) { |
|
94 mNotificationManager.cancel(id); |
|
95 } |
|
96 |
|
97 } |
|