This source file includes following definitions.
- display1
- display
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.gnu.emacs;
21
22 import android.app.Notification;
23 import android.app.NotificationManager;
24 import android.app.NotificationChannel;
25 import android.app.PendingIntent;
26
27 import android.content.Context;
28 import android.content.Intent;
29
30 import android.os.Build;
31
32 import android.widget.RemoteViews;
33
34
35
36
37
38
39
40
41
42
43
44
45 public final class EmacsDesktopNotification
46 {
47
48 public final String content;
49
50
51 public final String title;
52
53
54 public final String group;
55
56
57
58
59
60
61 public final String tag;
62
63
64 public final int icon;
65
66
67 public final int importance;
68
69 public
70 EmacsDesktopNotification (String title, String content,
71 String group, String tag, int icon,
72 int importance)
73 {
74 this.content = content;
75 this.title = title;
76 this.group = group;
77 this.tag = tag;
78 this.icon = icon;
79 this.importance = importance;
80 }
81
82
83
84
85
86
87
88 @SuppressWarnings ("deprecation")
89 private void
90 display1 (Context context)
91 {
92 NotificationManager manager;
93 NotificationChannel channel;
94 Notification notification;
95 Object tem;
96 RemoteViews contentView;
97 Intent intent;
98 PendingIntent pending;
99
100 tem = context.getSystemService (Context.NOTIFICATION_SERVICE);
101 manager = (NotificationManager) tem;
102
103 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
104 {
105
106
107
108 channel = new NotificationChannel (group, group, importance);
109 manager.createNotificationChannel (channel);
110
111
112 notification = (new Notification.Builder (context, group)
113 .setContentTitle (title)
114 .setContentText (content)
115 .setSmallIcon (icon)
116 .build ());
117 }
118 else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
119 notification = (new Notification.Builder (context)
120 .setContentTitle (title)
121 .setContentText (content)
122 .setSmallIcon (icon)
123 .build ());
124 else
125 {
126 notification = new Notification ();
127 notification.icon = icon;
128
129
130
131 notification.contentView
132 = contentView
133 = new RemoteViews ("org.gnu.emacs",
134 R.layout.sdk8_notifications_view);
135 contentView.setTextViewText (R.id.sdk8_notifications_title,
136 title);
137 contentView.setTextViewText (R.id.sdk8_notifications_content,
138 content);
139 }
140
141
142
143
144 intent = new Intent (context, EmacsActivity.class);
145 intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
146
147 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
148 pending = PendingIntent.getActivity (context, 0, intent,
149 PendingIntent.FLAG_IMMUTABLE);
150 else
151 pending = PendingIntent.getActivity (context, 0, intent, 0);
152
153 notification.contentIntent = pending;
154
155 manager.notify (tag, 2, notification);
156 }
157
158
159
160
161
162
163 public void
164 display ()
165 {
166 EmacsService.SERVICE.runOnUiThread (new Runnable () {
167 @Override
168 public void
169 run ()
170 {
171 display1 (EmacsService.SERVICE);
172 }
173 });
174 }
175 };