@ammarahmed/notifee-react-native 7.3.0 → 7.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/android/build.gradle +35 -17
  2. package/android/schemas/app.notifee.core.database.NotifeeCoreDatabase/1.json +46 -0
  3. package/android/schemas/app.notifee.core.database.NotifeeCoreDatabase/2.json +53 -0
  4. package/android/src/main/java/app/notifee/core/AlarmPermissionBroadcastReceiver.java +19 -0
  5. package/android/src/main/java/app/notifee/core/BlockStateBroadcastReceiver.java +164 -0
  6. package/android/src/main/java/app/notifee/core/ChannelManager.java +351 -0
  7. package/android/src/main/java/app/notifee/core/ContextHolder.java +33 -0
  8. package/android/src/main/java/app/notifee/core/EventBus.java +63 -0
  9. package/android/src/main/java/app/notifee/core/EventSubscriber.java +82 -0
  10. package/android/src/main/java/app/notifee/core/ForegroundService.java +125 -0
  11. package/android/src/main/java/app/notifee/core/InitProvider.java +92 -0
  12. package/android/src/main/java/app/notifee/core/KeepForSdk.java +26 -0
  13. package/android/src/main/java/app/notifee/core/Logger.java +68 -0
  14. package/android/src/main/java/app/notifee/core/Notifee.java +533 -0
  15. package/android/src/main/java/app/notifee/core/NotifeeAlarmManager.java +256 -0
  16. package/android/src/main/java/app/notifee/core/NotificationAlarmReceiver.java +32 -0
  17. package/android/src/main/java/app/notifee/core/NotificationManager.java +903 -0
  18. package/android/src/main/java/app/notifee/core/NotificationPendingIntent.java +189 -0
  19. package/android/src/main/java/app/notifee/core/NotificationReceiverActivity.java +38 -0
  20. package/android/src/main/java/app/notifee/core/NotificationReceiverHandler.java +140 -0
  21. package/android/src/main/java/app/notifee/core/Preferences.java +79 -0
  22. package/android/src/main/java/app/notifee/core/RebootBroadcastReceiver.java +38 -0
  23. package/android/src/main/java/app/notifee/core/ReceiverService.java +268 -0
  24. package/android/src/main/java/app/notifee/core/Worker.java +87 -0
  25. package/android/src/main/java/app/notifee/core/database/NotifeeCoreDatabase.java +76 -0
  26. package/android/src/main/java/app/notifee/core/database/WorkDataDao.java +52 -0
  27. package/android/src/main/java/app/notifee/core/database/WorkDataEntity.java +68 -0
  28. package/android/src/main/java/app/notifee/core/database/WorkDataRepository.java +107 -0
  29. package/android/src/main/java/app/notifee/core/event/BlockStateEvent.java +102 -0
  30. package/android/src/main/java/app/notifee/core/event/ForegroundServiceEvent.java +48 -0
  31. package/android/src/main/java/app/notifee/core/event/InitialNotificationEvent.java +50 -0
  32. package/android/src/main/java/app/notifee/core/event/LogEvent.java +74 -0
  33. package/android/src/main/java/app/notifee/core/event/MainComponentEvent.java +33 -0
  34. package/android/src/main/java/app/notifee/core/event/NotificationEvent.java +97 -0
  35. package/android/src/main/java/app/notifee/core/interfaces/EventListener.java +39 -0
  36. package/android/src/main/java/app/notifee/core/interfaces/MethodCallResult.java +27 -0
  37. package/android/src/main/java/app/notifee/core/model/ChannelGroupModel.java +48 -0
  38. package/android/src/main/java/app/notifee/core/model/ChannelModel.java +123 -0
  39. package/android/src/main/java/app/notifee/core/model/IntervalTriggerModel.java +63 -0
  40. package/android/src/main/java/app/notifee/core/model/NotificationAndroidActionModel.java +125 -0
  41. package/android/src/main/java/app/notifee/core/model/NotificationAndroidModel.java +654 -0
  42. package/android/src/main/java/app/notifee/core/model/NotificationAndroidPressActionModel.java +146 -0
  43. package/android/src/main/java/app/notifee/core/model/NotificationAndroidStyleModel.java +341 -0
  44. package/android/src/main/java/app/notifee/core/model/NotificationModel.java +72 -0
  45. package/android/src/main/java/app/notifee/core/model/TimestampTriggerModel.java +163 -0
  46. package/android/src/main/java/app/notifee/core/model/package-info.java +4 -0
  47. package/android/src/main/java/app/notifee/core/utility/AlarmUtils.java +52 -0
  48. package/android/src/main/java/app/notifee/core/utility/Callbackable.java +12 -0
  49. package/android/src/main/java/app/notifee/core/utility/ColorUtils.java +62 -0
  50. package/android/src/main/java/app/notifee/core/utility/ExtendedListenableFuture.java +84 -0
  51. package/android/src/main/java/app/notifee/core/utility/IntentUtils.java +136 -0
  52. package/android/src/main/java/app/notifee/core/utility/ObjectUtils.java +187 -0
  53. package/android/src/main/java/app/notifee/core/utility/PowerManagerUtils.java +334 -0
  54. package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +309 -0
  55. package/android/src/main/java/app/notifee/core/utility/TextUtils.java +28 -0
  56. package/android/src/main/java/app/notifee/core/utility/package-info.java +4 -0
  57. package/dist/types/Notification.d.ts +8 -1
  58. package/dist/types/Notification.js +6 -0
  59. package/dist/types/Notification.js.map +1 -1
  60. package/dist/version.d.ts +1 -1
  61. package/jest-mock.js +7 -4
  62. package/package.json +1 -3
  63. package/src/types/Notification.ts +8 -0
  64. package/src/version.ts +1 -1
  65. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar +0 -0
  66. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.md5 +0 -1
  67. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha1 +0 -1
  68. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha256 +0 -1
  69. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha512 +0 -1
  70. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom +0 -9
  71. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.md5 +0 -1
  72. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha1 +0 -1
  73. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha256 +0 -1
  74. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha512 +0 -1
  75. package/android/libs/app/notifee/core/maven-metadata.xml +0 -13
  76. package/android/libs/app/notifee/core/maven-metadata.xml.md5 +0 -1
  77. package/android/libs/app/notifee/core/maven-metadata.xml.sha1 +0 -1
  78. package/android/libs/app/notifee/core/maven-metadata.xml.sha256 +0 -1
  79. package/android/libs/app/notifee/core/maven-metadata.xml.sha512 +0 -1
@@ -0,0 +1,654 @@
1
+ package app.notifee.core.model;
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import android.app.Notification;
21
+ import android.graphics.Color;
22
+ import android.os.Bundle;
23
+ import androidx.annotation.Keep;
24
+ import androidx.annotation.NonNull;
25
+ import androidx.annotation.Nullable;
26
+ import androidx.core.app.NotificationCompat;
27
+ import androidx.core.app.NotificationManagerCompat;
28
+ import app.notifee.core.Logger;
29
+ import app.notifee.core.utility.ObjectUtils;
30
+ import app.notifee.core.utility.ResourceUtils;
31
+ import java.util.ArrayList;
32
+ import java.util.Objects;
33
+
34
+ @Keep
35
+ public class NotificationAndroidModel {
36
+ private static final String TAG = "NotificationAndroidModel";
37
+ private Bundle mNotificationAndroidBundle;
38
+
39
+ private NotificationAndroidModel(Bundle bundle) {
40
+ mNotificationAndroidBundle = bundle;
41
+ }
42
+
43
+ public static NotificationAndroidModel fromBundle(Bundle bundle) {
44
+ return new NotificationAndroidModel(bundle);
45
+ }
46
+
47
+ public @Nullable ArrayList<NotificationAndroidActionModel> getActions() {
48
+ if (mNotificationAndroidBundle.containsKey("actions")) {
49
+ ArrayList<Bundle> actionBundles =
50
+ Objects.requireNonNull(mNotificationAndroidBundle.getParcelableArrayList("actions"));
51
+ ArrayList<NotificationAndroidActionModel> actions = new ArrayList<>(actionBundles.size());
52
+
53
+ for (Bundle actionBundle : actionBundles) {
54
+ actions.add(NotificationAndroidActionModel.fromBundle(actionBundle));
55
+ }
56
+
57
+ return actions;
58
+ }
59
+
60
+ return null;
61
+ }
62
+
63
+ /**
64
+ * Gets whether the notification is for a foreground service
65
+ *
66
+ * @return Boolean
67
+ */
68
+ public Boolean getAsForegroundService() {
69
+ return mNotificationAndroidBundle.getBoolean("asForegroundService", false);
70
+ }
71
+
72
+ /**
73
+ * Gets if the notification should light up the screen when displayed
74
+ *
75
+ * @return Boolean
76
+ */
77
+ public Boolean getLightUpScreen() {
78
+ return mNotificationAndroidBundle.getBoolean("lightUpScreen", false);
79
+ }
80
+
81
+ /**
82
+ * Gets whether the notification can be auto cancelled
83
+ *
84
+ * @return Boolean
85
+ */
86
+ public Boolean getAutoCancel() {
87
+ return mNotificationAndroidBundle.getBoolean("autoCancel", false);
88
+ }
89
+
90
+ /**
91
+ * Gets the badge icon type for the notification
92
+ *
93
+ * @return Integer
94
+ */
95
+ public @Nullable Integer getBadgeIconType() {
96
+ if (mNotificationAndroidBundle.containsKey("badgeIconType")) {
97
+
98
+ return ObjectUtils.getInt(mNotificationAndroidBundle.get("badgeIconType"));
99
+ }
100
+
101
+ return NotificationCompat.BADGE_ICON_LARGE;
102
+ }
103
+
104
+ /**
105
+ * Gets the channel ID for the notification, returns an empty string if none is available
106
+ *
107
+ * @return String
108
+ */
109
+ public @NonNull String getChannelId() {
110
+ if (mNotificationAndroidBundle.containsKey("channelId")) {
111
+ return Objects.requireNonNull(mNotificationAndroidBundle.getString("channelId"));
112
+ }
113
+
114
+ return "";
115
+ }
116
+
117
+ /**
118
+ * Gets the notification category
119
+ *
120
+ * @return String
121
+ */
122
+ public @Nullable String getCategory() {
123
+ return mNotificationAndroidBundle.getString("category");
124
+ }
125
+
126
+ /**
127
+ * Gets the parsed notification color
128
+ *
129
+ * @return Integer
130
+ */
131
+ public @Nullable Integer getColor() {
132
+ if (mNotificationAndroidBundle.containsKey("color")) {
133
+ return Color.parseColor(mNotificationAndroidBundle.getString("color"));
134
+ }
135
+
136
+ return null;
137
+ }
138
+
139
+ /**
140
+ * Gets whether the notification is colorized
141
+ *
142
+ * @return Boolean
143
+ */
144
+ public Boolean getColorized() {
145
+ return mNotificationAndroidBundle.getBoolean("colorized", false);
146
+ }
147
+
148
+ /**
149
+ * Gets whether the notification chronometer should count down
150
+ *
151
+ * @return Boolean
152
+ */
153
+ public Boolean getChronometerCountDown() {
154
+ if (mNotificationAndroidBundle.containsKey("chronometerDirection")) {
155
+ String direction = mNotificationAndroidBundle.getString("chronometerDirection");
156
+ return direction != null && direction.equals("down");
157
+ }
158
+
159
+ return false;
160
+ }
161
+
162
+ /**
163
+ * Gets the notification defaults (for API < 26)
164
+ *
165
+ * @param hasCustomSound A flag to indicate if notificaiton has a custom sound and has successfuly
166
+ * resolved
167
+ * @return Integer
168
+ */
169
+ public Integer getDefaults(Boolean hasCustomSound) {
170
+ String TAG = "NotificationManager";
171
+ Integer defaults = null;
172
+
173
+ if (mNotificationAndroidBundle.containsKey("defaults")) {
174
+ ArrayList<Integer> defaultsArray = mNotificationAndroidBundle.getIntegerArrayList("defaults");
175
+
176
+ for (Integer integer : Objects.requireNonNull(defaultsArray)) {
177
+ if (defaults == null) {
178
+ defaults = integer;
179
+ } else {
180
+ defaults |= integer;
181
+ }
182
+ }
183
+ } else {
184
+ defaults = Notification.DEFAULT_ALL;
185
+ }
186
+
187
+ if (hasCustomSound) {
188
+ defaults &= ~Notification.DEFAULT_SOUND;
189
+ }
190
+
191
+ if (!mNotificationAndroidBundle.containsKey("vibrationPattern")) {
192
+ defaults &= ~Notification.DEFAULT_VIBRATE;
193
+ }
194
+
195
+ if (mNotificationAndroidBundle.containsKey("lights")) {
196
+ defaults &= ~Notification.DEFAULT_LIGHTS;
197
+ }
198
+
199
+ return defaults;
200
+ }
201
+
202
+ /**
203
+ * Gets the notification tag
204
+ *
205
+ * @return String
206
+ */
207
+ public @Nullable String getTag() {
208
+ return mNotificationAndroidBundle.getString("tag");
209
+ }
210
+
211
+ /**
212
+ * Gets the notification group key
213
+ *
214
+ * @return String
215
+ */
216
+ public @Nullable String getGroup() {
217
+ return mNotificationAndroidBundle.getString("groupId");
218
+ }
219
+
220
+ /**
221
+ * Gets the group alert behaviour for a notification
222
+ *
223
+ * @return int
224
+ */
225
+ public int getGroupAlertBehaviour() {
226
+ if (mNotificationAndroidBundle.containsKey("groupAlertBehavior")) {
227
+ return ObjectUtils.getInt(mNotificationAndroidBundle.get("groupAlertBehavior"));
228
+ }
229
+
230
+ return NotificationCompat.GROUP_ALERT_ALL;
231
+ }
232
+
233
+ /**
234
+ * Gets whether the notification is the group summary
235
+ *
236
+ * @return Boolean
237
+ */
238
+ public Boolean getGroupSummary() {
239
+ return mNotificationAndroidBundle.getBoolean("groupSummary", false);
240
+ }
241
+
242
+ /**
243
+ * Gets the input history of the notification
244
+ *
245
+ * @return CharSequence[]
246
+ */
247
+ public @Nullable CharSequence[] getInputHistory() {
248
+ if (mNotificationAndroidBundle.containsKey("inputHistory")) {
249
+ ArrayList<String> inputHistoryArray =
250
+ mNotificationAndroidBundle.getStringArrayList("inputHistory");
251
+ return Objects.requireNonNull(inputHistoryArray)
252
+ .toArray(new CharSequence[inputHistoryArray.size()]);
253
+ }
254
+
255
+ return null;
256
+ }
257
+
258
+ /**
259
+ * Returns true if the notification has a large icon field
260
+ *
261
+ * @return Boolean
262
+ */
263
+ public Boolean hasLargeIcon() {
264
+ return mNotificationAndroidBundle.containsKey("largeIcon");
265
+ }
266
+
267
+ /** Returns the large icon string */
268
+ public String getLargeIcon() {
269
+ if (hasLargeIcon()) {
270
+ return Objects.requireNonNull(mNotificationAndroidBundle.getString("largeIcon"));
271
+ }
272
+
273
+ return null;
274
+ }
275
+
276
+ /** Returns the large icon string */
277
+ public Boolean getCircularLargeIcon() {
278
+ return Objects.requireNonNull(
279
+ mNotificationAndroidBundle.getBoolean("circularLargeIcon", false));
280
+ }
281
+
282
+ /**
283
+ * Gets the light output for the notification
284
+ *
285
+ * @return ArrayList<Integer>
286
+ */
287
+ public @Nullable ArrayList<Integer> getLights() {
288
+ if (mNotificationAndroidBundle.containsKey("lights")) {
289
+ try {
290
+ ArrayList<?> lightList =
291
+ Objects.requireNonNull(mNotificationAndroidBundle.getParcelableArrayList("lights"));
292
+ String rawColor = (String) lightList.get(0);
293
+
294
+ ArrayList<Integer> lights = new ArrayList<>(3);
295
+ lights.add(Color.parseColor(rawColor));
296
+ lights.add((Integer) lightList.get(1));
297
+ lights.add((Integer) lightList.get(2));
298
+
299
+ return lights;
300
+ } catch (Exception e) {
301
+ Logger.e(
302
+ TAG,
303
+ "getLights -> Failed to parse lights");
304
+ return null;
305
+ }
306
+ }
307
+
308
+ return null;
309
+ }
310
+
311
+ /**
312
+ * Gets whether the notification is for local devices only
313
+ *
314
+ * @return Boolean
315
+ */
316
+ public Boolean getLocalOnly() {
317
+ return mNotificationAndroidBundle.getBoolean("localOnly", false);
318
+ }
319
+
320
+ /**
321
+ * Gets a custom set number for the device notification count
322
+ *
323
+ * @return Integer
324
+ */
325
+ public Integer getNumber() {
326
+ if (mNotificationAndroidBundle.containsKey("badgeCount")) {
327
+ return ObjectUtils.getInt(mNotificationAndroidBundle.get("badgeCount"));
328
+ }
329
+
330
+ return null;
331
+ }
332
+
333
+ /**
334
+ * Gets whether this notification is ongoing
335
+ *
336
+ * @return Boolean
337
+ */
338
+ public Boolean getOngoing() {
339
+ return mNotificationAndroidBundle.getBoolean("ongoing", false);
340
+ }
341
+
342
+ /**
343
+ * Gets whether this notification should loop the sound
344
+ *
345
+ * @return Boolean
346
+ */
347
+ public Boolean getLoopSound() {
348
+ return mNotificationAndroidBundle.getBoolean("loopSound", false);
349
+ }
350
+
351
+ /**
352
+ * Gets an array of flags
353
+ *
354
+ * @return int[]
355
+ */
356
+ public int[] getFlags() {
357
+ if (!mNotificationAndroidBundle.containsKey("flags")) {
358
+ return null;
359
+ }
360
+
361
+ ArrayList<?> flagsArrayList =
362
+ Objects.requireNonNull(mNotificationAndroidBundle.getParcelableArrayList("flags"));
363
+
364
+ int[] flagsArray = new int[flagsArrayList.size()];
365
+
366
+ for (int i = 0; i < flagsArrayList.size(); i++) {
367
+ flagsArray[i] = ObjectUtils.getInt(flagsArrayList.get(i));
368
+ }
369
+
370
+ return flagsArray;
371
+ }
372
+
373
+ /**
374
+ * Gets whether this notification should only alert once if updated
375
+ *
376
+ * @return Boolean
377
+ */
378
+ public Boolean getOnlyAlertOnce() {
379
+ return mNotificationAndroidBundle.getBoolean("onlyAlertOnce", false);
380
+ }
381
+
382
+ /**
383
+ * Returns true if the notification has a fullScreenAction
384
+ *
385
+ * @return Boolean
386
+ */
387
+ public Boolean hasFullScreenAction() {
388
+ return mNotificationAndroidBundle.containsKey("fullScreenAction");
389
+ }
390
+
391
+ /**
392
+ * Gets an pressAction bundle for the notification
393
+ *
394
+ * @return Bundle or null
395
+ */
396
+ public @Nullable Bundle getPressAction() {
397
+ return mNotificationAndroidBundle.getBundle("pressAction");
398
+ }
399
+
400
+ /**
401
+ * Returns a notification full screen action
402
+ *
403
+ * @return NotificationAndroidFullScreenActionModel
404
+ */
405
+ public @Nullable NotificationAndroidPressActionModel getFullScreenAction() {
406
+ if (!hasFullScreenAction()) {
407
+ return null;
408
+ }
409
+
410
+ return NotificationAndroidPressActionModel.fromBundle(
411
+ mNotificationAndroidBundle.getBundle("fullScreenAction"));
412
+ }
413
+
414
+ /**
415
+ * JS uses the same API as importance for priority so we dont confuse users. This maps importance
416
+ * to a priority flag.
417
+ *
418
+ * @return int
419
+ */
420
+ public int getPriority() {
421
+ if (!mNotificationAndroidBundle.containsKey("importance")) {
422
+ return NotificationCompat.PRIORITY_DEFAULT;
423
+ }
424
+
425
+ int importance = ObjectUtils.getInt(mNotificationAndroidBundle.get("importance"));
426
+ switch (importance) {
427
+ case NotificationManagerCompat.IMPORTANCE_HIGH:
428
+ return NotificationCompat.PRIORITY_HIGH;
429
+ case NotificationManagerCompat.IMPORTANCE_MIN:
430
+ return NotificationCompat.PRIORITY_LOW;
431
+ case NotificationManagerCompat.IMPORTANCE_NONE:
432
+ return NotificationCompat.PRIORITY_MIN;
433
+ case NotificationManagerCompat.IMPORTANCE_DEFAULT:
434
+ default:
435
+ return NotificationCompat.PRIORITY_DEFAULT;
436
+ }
437
+ }
438
+
439
+ /**
440
+ * Gets a AndroidProgress class for the current notification
441
+ *
442
+ * @return AndroidProgress
443
+ */
444
+ public @Nullable AndroidProgress getProgress() {
445
+ if (mNotificationAndroidBundle.containsKey("progress")) {
446
+ Bundle progressBundle =
447
+ Objects.requireNonNull(mNotificationAndroidBundle.getBundle("progress"));
448
+
449
+ return new AndroidProgress(
450
+ ObjectUtils.getInt(progressBundle.get("max")),
451
+ ObjectUtils.getInt(progressBundle.get("current")),
452
+ progressBundle.getBoolean("indeterminate", false));
453
+ }
454
+
455
+ return null;
456
+ }
457
+
458
+ /**
459
+ * Gets the shortcut ID for the notification
460
+ *
461
+ * @return String
462
+ */
463
+ public @Nullable String getShortcutId() {
464
+ return mNotificationAndroidBundle.getString("shortcutId");
465
+ }
466
+
467
+ /**
468
+ * Gets whether this notification should show the timestamp
469
+ *
470
+ * @return Boolean
471
+ */
472
+ public Boolean getShowTimestamp() {
473
+ return mNotificationAndroidBundle.getBoolean("showTimestamp", false);
474
+ }
475
+
476
+ /**
477
+ * Gets the small icon resource id from its string name, or null if the icon is missing from the
478
+ * device.
479
+ */
480
+ public @Nullable Integer getSmallIcon() {
481
+ if (!mNotificationAndroidBundle.containsKey("smallIcon")) {
482
+ return null;
483
+ }
484
+
485
+ String rawIcon = mNotificationAndroidBundle.getString("smallIcon");
486
+ int smallIconId = ResourceUtils.getImageResourceId(rawIcon);
487
+
488
+ if (smallIconId == 0) {
489
+ Logger.d(
490
+ "NotificationAndroidModel",
491
+ String.format("Notification small icon '%s' could not be found", rawIcon));
492
+ return null;
493
+ }
494
+
495
+ return smallIconId;
496
+ }
497
+
498
+ /**
499
+ * Gets the small icon & it's level, or null if the icon is missing from the device.
500
+ *
501
+ * @return ArrayList<Integer>
502
+ */
503
+ public @Nullable Integer getSmallIconLevel() {
504
+ if (!mNotificationAndroidBundle.containsKey("smallIconLevel")) {
505
+ return null;
506
+ }
507
+
508
+ return mNotificationAndroidBundle.getInt("smallIconLevel");
509
+ }
510
+
511
+ /**
512
+ * Gets the sort key
513
+ *
514
+ * @return String
515
+ */
516
+ public @Nullable String getSortKey() {
517
+ return mNotificationAndroidBundle.getString("sortKey");
518
+ }
519
+
520
+ /**
521
+ * Returns whether the notification has any styles
522
+ *
523
+ * @return Boolean
524
+ */
525
+ public Boolean hasStyle() {
526
+ return mNotificationAndroidBundle.containsKey("style");
527
+ }
528
+
529
+ /**
530
+ * Returns a task containing a notification style
531
+ *
532
+ * @return ListenableFuture<NotificationCompat.Style>
533
+ */
534
+ public @Nullable NotificationAndroidStyleModel getStyle() {
535
+ if (!hasStyle()) {
536
+ return null;
537
+ }
538
+
539
+ return NotificationAndroidStyleModel.fromBundle(mNotificationAndroidBundle.getBundle("style"));
540
+ }
541
+
542
+ /**
543
+ * Gets the ticker text
544
+ *
545
+ * @return String
546
+ */
547
+ public @Nullable String getTicker() {
548
+ return mNotificationAndroidBundle.getString("ticker");
549
+ }
550
+
551
+ /**
552
+ * Gets the timeout after ms, -1 if none exists
553
+ *
554
+ * @return long
555
+ */
556
+ public @Nullable Long getTimeoutAfter() {
557
+ if (mNotificationAndroidBundle.containsKey("timeoutAfter")) {
558
+ return ObjectUtils.getLong(mNotificationAndroidBundle.get("timeoutAfter"));
559
+ }
560
+
561
+ return null;
562
+ }
563
+
564
+ /**
565
+ * Gets whether the chronometer should be shown
566
+ *
567
+ * @return Boolean
568
+ */
569
+ public Boolean getShowChronometer() {
570
+ return mNotificationAndroidBundle.getBoolean("showChronometer", false);
571
+ }
572
+
573
+ public @Nullable String getSound() {
574
+ if (!mNotificationAndroidBundle.containsKey("sound")) {
575
+ return null;
576
+ }
577
+
578
+ return mNotificationAndroidBundle.getString("sound");
579
+ }
580
+
581
+ /**
582
+ * Gets an array vibration pattern for the notification, or empty if not provided
583
+ *
584
+ * @return long[]
585
+ */
586
+ public long[] getVibrationPattern() {
587
+ if (!mNotificationAndroidBundle.containsKey("vibrationPattern")) {
588
+ return new long[0];
589
+ }
590
+
591
+ ArrayList<?> vibrationPattern =
592
+ Objects.requireNonNull(
593
+ mNotificationAndroidBundle.getParcelableArrayList("vibrationPattern"));
594
+
595
+ long[] vibrateArray = new long[vibrationPattern.size()];
596
+
597
+ for (int i = 0; i < vibrationPattern.size(); i++) {
598
+ Integer value = (Integer) vibrationPattern.get(i);
599
+ vibrateArray[i] = value.longValue();
600
+ }
601
+
602
+ return vibrateArray;
603
+ }
604
+
605
+ /**
606
+ * Gets the notification visibility
607
+ *
608
+ * @return int
609
+ */
610
+ public int getVisibility() {
611
+ if (mNotificationAndroidBundle.containsKey("visibility")) {
612
+ return ObjectUtils.getInt(mNotificationAndroidBundle.get("visibility"));
613
+ }
614
+
615
+ return NotificationCompat.VISIBILITY_PRIVATE;
616
+ }
617
+
618
+ /**
619
+ * Gets the notification timestamp, or -1 if not provided
620
+ *
621
+ * @return long
622
+ */
623
+ public long getTimestamp() {
624
+ if (mNotificationAndroidBundle.containsKey("timestamp")) {
625
+ return ObjectUtils.getLong(mNotificationAndroidBundle.get("timestamp"));
626
+ }
627
+
628
+ return -1;
629
+ }
630
+
631
+ public static class AndroidProgress {
632
+ int max;
633
+ int current;
634
+ boolean indeterminate;
635
+
636
+ AndroidProgress(int max, int current, boolean indeterminate) {
637
+ this.max = max;
638
+ this.current = current;
639
+ this.indeterminate = indeterminate;
640
+ }
641
+
642
+ public int getMax() {
643
+ return max;
644
+ }
645
+
646
+ public int getCurrent() {
647
+ return current;
648
+ }
649
+
650
+ public boolean getIndeterminate() {
651
+ return indeterminate;
652
+ }
653
+ }
654
+ }