@@ -161,11 +161,55 @@ public void sendToNotificationCentre(Bundle bundle) {
161
161
title = context .getPackageManager ().getApplicationLabel (appInfo ).toString ();
162
162
}
163
163
164
+ int priority = NotificationCompat .PRIORITY_HIGH ;
165
+ final String priorityString = bundle .getString ("priority" );
166
+
167
+ if (priorityString != null ) {
168
+ switch (priorityString .toLowerCase ()) {
169
+ case "max" :
170
+ priority = NotificationCompat .PRIORITY_MAX ;
171
+ break ;
172
+ case "high" :
173
+ priority = NotificationCompat .PRIORITY_HIGH ;
174
+ break ;
175
+ case "low" :
176
+ priority = NotificationCompat .PRIORITY_LOW ;
177
+ break ;
178
+ case "min" :
179
+ priority = NotificationCompat .PRIORITY_MIN ;
180
+ break ;
181
+ case "default" :
182
+ priority = NotificationCompat .PRIORITY_DEFAULT ;
183
+ break ;
184
+ default :
185
+ priority = NotificationCompat .PRIORITY_HIGH ;
186
+ }
187
+ }
188
+
189
+ int visibility = NotificationCompat .VISIBILITY_PRIVATE ;
190
+ final String visibilityString = bundle .getString ("visibility" );
191
+
192
+ if (visibilityString != null ) {
193
+ switch (visibilityString .toLowerCase ()) {
194
+ case "private" :
195
+ visibility = NotificationCompat .VISIBILITY_PRIVATE ;
196
+ break ;
197
+ case "public" :
198
+ visibility = NotificationCompat .VISIBILITY_PUBLIC ;
199
+ break ;
200
+ case "secret" :
201
+ visibility = NotificationCompat .VISIBILITY_SECRET ;
202
+ break ;
203
+ default :
204
+ visibility = NotificationCompat .VISIBILITY_PRIVATE ;
205
+ }
206
+ }
207
+
164
208
NotificationCompat .Builder notification = new NotificationCompat .Builder (context , NOTIFICATION_CHANNEL_ID )
165
209
.setContentTitle (title )
166
210
.setTicker (bundle .getString ("ticker" ))
167
- .setVisibility (NotificationCompat . VISIBILITY_PRIVATE )
168
- .setPriority (NotificationCompat . PRIORITY_HIGH )
211
+ .setVisibility (visibility )
212
+ .setPriority (priority )
169
213
.setAutoCancel (bundle .getBoolean ("autoCancel" , true ));
170
214
171
215
String group = bundle .getString ("group" );
@@ -492,7 +536,39 @@ private void checkOrCreateChannel(NotificationManager manager) {
492
536
if (manager == null )
493
537
return ;
494
538
495
- int importance = NotificationManager .IMPORTANCE_DEFAULT ;
539
+ Bundle bundle = new Bundle ();
540
+
541
+ int importance = NotificationManager .IMPORTANCE_HIGH ;
542
+ final String importanceString = bundle .getString ("importance" );
543
+
544
+ if (importanceString != null ) {
545
+ switch (importanceString .toLowerCase ()) {
546
+ case "default" :
547
+ importance = NotificationManager .IMPORTANCE_DEFAULT ;
548
+ break ;
549
+ case "max" :
550
+ importance = NotificationManager .IMPORTANCE_MAX ;
551
+ break ;
552
+ case "high" :
553
+ importance = NotificationManager .IMPORTANCE_HIGH ;
554
+ break ;
555
+ case "low" :
556
+ importance = NotificationManager .IMPORTANCE_LOW ;
557
+ break ;
558
+ case "min" :
559
+ importance = NotificationManager .IMPORTANCE_MIN ;
560
+ break ;
561
+ case "none" :
562
+ importance = NotificationManager .IMPORTANCE_NONE ;
563
+ break ;
564
+ case "unspecified" :
565
+ importance = NotificationManager .IMPORTANCE_UNSPECIFIED ;
566
+ break ;
567
+ default :
568
+ importance = NotificationManager .IMPORTANCE_HIGH ;
569
+ }
570
+ }
571
+
496
572
NotificationChannel channel = new NotificationChannel (NOTIFICATION_CHANNEL_ID , this .config .getChannelName (), importance );
497
573
channel .setDescription (this .config .getChannelDescription ());
498
574
channel .enableLights (true );
0 commit comments