@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.
- package/android/build.gradle +35 -17
- package/android/schemas/app.notifee.core.database.NotifeeCoreDatabase/1.json +46 -0
- package/android/schemas/app.notifee.core.database.NotifeeCoreDatabase/2.json +53 -0
- package/android/src/main/java/app/notifee/core/AlarmPermissionBroadcastReceiver.java +19 -0
- package/android/src/main/java/app/notifee/core/BlockStateBroadcastReceiver.java +164 -0
- package/android/src/main/java/app/notifee/core/ChannelManager.java +351 -0
- package/android/src/main/java/app/notifee/core/ContextHolder.java +33 -0
- package/android/src/main/java/app/notifee/core/EventBus.java +63 -0
- package/android/src/main/java/app/notifee/core/EventSubscriber.java +82 -0
- package/android/src/main/java/app/notifee/core/ForegroundService.java +125 -0
- package/android/src/main/java/app/notifee/core/InitProvider.java +92 -0
- package/android/src/main/java/app/notifee/core/KeepForSdk.java +26 -0
- package/android/src/main/java/app/notifee/core/Logger.java +68 -0
- package/android/src/main/java/app/notifee/core/Notifee.java +533 -0
- package/android/src/main/java/app/notifee/core/NotifeeAlarmManager.java +256 -0
- package/android/src/main/java/app/notifee/core/NotificationAlarmReceiver.java +32 -0
- package/android/src/main/java/app/notifee/core/NotificationManager.java +903 -0
- package/android/src/main/java/app/notifee/core/NotificationPendingIntent.java +189 -0
- package/android/src/main/java/app/notifee/core/NotificationReceiverActivity.java +38 -0
- package/android/src/main/java/app/notifee/core/NotificationReceiverHandler.java +140 -0
- package/android/src/main/java/app/notifee/core/Preferences.java +79 -0
- package/android/src/main/java/app/notifee/core/RebootBroadcastReceiver.java +38 -0
- package/android/src/main/java/app/notifee/core/ReceiverService.java +268 -0
- package/android/src/main/java/app/notifee/core/Worker.java +87 -0
- package/android/src/main/java/app/notifee/core/database/NotifeeCoreDatabase.java +76 -0
- package/android/src/main/java/app/notifee/core/database/WorkDataDao.java +52 -0
- package/android/src/main/java/app/notifee/core/database/WorkDataEntity.java +68 -0
- package/android/src/main/java/app/notifee/core/database/WorkDataRepository.java +107 -0
- package/android/src/main/java/app/notifee/core/event/BlockStateEvent.java +102 -0
- package/android/src/main/java/app/notifee/core/event/ForegroundServiceEvent.java +48 -0
- package/android/src/main/java/app/notifee/core/event/InitialNotificationEvent.java +50 -0
- package/android/src/main/java/app/notifee/core/event/LogEvent.java +74 -0
- package/android/src/main/java/app/notifee/core/event/MainComponentEvent.java +33 -0
- package/android/src/main/java/app/notifee/core/event/NotificationEvent.java +97 -0
- package/android/src/main/java/app/notifee/core/interfaces/EventListener.java +39 -0
- package/android/src/main/java/app/notifee/core/interfaces/MethodCallResult.java +27 -0
- package/android/src/main/java/app/notifee/core/model/ChannelGroupModel.java +48 -0
- package/android/src/main/java/app/notifee/core/model/ChannelModel.java +123 -0
- package/android/src/main/java/app/notifee/core/model/IntervalTriggerModel.java +63 -0
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidActionModel.java +125 -0
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidModel.java +654 -0
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidPressActionModel.java +146 -0
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidStyleModel.java +341 -0
- package/android/src/main/java/app/notifee/core/model/NotificationModel.java +72 -0
- package/android/src/main/java/app/notifee/core/model/TimestampTriggerModel.java +163 -0
- package/android/src/main/java/app/notifee/core/model/package-info.java +4 -0
- package/android/src/main/java/app/notifee/core/utility/AlarmUtils.java +52 -0
- package/android/src/main/java/app/notifee/core/utility/Callbackable.java +12 -0
- package/android/src/main/java/app/notifee/core/utility/ColorUtils.java +62 -0
- package/android/src/main/java/app/notifee/core/utility/ExtendedListenableFuture.java +84 -0
- package/android/src/main/java/app/notifee/core/utility/IntentUtils.java +136 -0
- package/android/src/main/java/app/notifee/core/utility/ObjectUtils.java +187 -0
- package/android/src/main/java/app/notifee/core/utility/PowerManagerUtils.java +334 -0
- package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +309 -0
- package/android/src/main/java/app/notifee/core/utility/TextUtils.java +28 -0
- package/android/src/main/java/app/notifee/core/utility/package-info.java +4 -0
- package/dist/types/Notification.d.ts +8 -1
- package/dist/types/Notification.js +6 -0
- package/dist/types/Notification.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/jest-mock.js +7 -4
- package/package.json +1 -3
- package/src/types/Notification.ts +8 -0
- package/src/version.ts +1 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar +0 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.md5 +0 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha1 +0 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha256 +0 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha512 +0 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom +0 -9
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.md5 +0 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha1 +0 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha256 +0 -1
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha512 +0 -1
- package/android/libs/app/notifee/core/maven-metadata.xml +0 -13
- package/android/libs/app/notifee/core/maven-metadata.xml.md5 +0 -1
- package/android/libs/app/notifee/core/maven-metadata.xml.sha1 +0 -1
- package/android/libs/app/notifee/core/maven-metadata.xml.sha256 +0 -1
- package/android/libs/app/notifee/core/maven-metadata.xml.sha512 +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
package app.notifee.core.event;
|
|
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.os.Bundle;
|
|
21
|
+
import androidx.annotation.Nullable;
|
|
22
|
+
import app.notifee.core.KeepForSdk;
|
|
23
|
+
import app.notifee.core.interfaces.MethodCallResult;
|
|
24
|
+
import app.notifee.core.utility.ObjectUtils;
|
|
25
|
+
import java.util.HashMap;
|
|
26
|
+
import java.util.Map;
|
|
27
|
+
|
|
28
|
+
@KeepForSdk
|
|
29
|
+
public class BlockStateEvent {
|
|
30
|
+
@KeepForSdk public static final int TYPE_APP_BLOCKED = 4;
|
|
31
|
+
|
|
32
|
+
@KeepForSdk public static final int TYPE_CHANNEL_BLOCKED = 5;
|
|
33
|
+
|
|
34
|
+
@KeepForSdk public static final int TYPE_CHANNEL_GROUP_BLOCKED = 6;
|
|
35
|
+
|
|
36
|
+
private int type;
|
|
37
|
+
|
|
38
|
+
private boolean blocked;
|
|
39
|
+
|
|
40
|
+
private @Nullable Bundle channelOrGroupBundle;
|
|
41
|
+
|
|
42
|
+
private MethodCallResult<Void> result;
|
|
43
|
+
|
|
44
|
+
private boolean completed = false;
|
|
45
|
+
|
|
46
|
+
public BlockStateEvent(
|
|
47
|
+
int type,
|
|
48
|
+
@Nullable Bundle channelOrGroupBundle,
|
|
49
|
+
boolean blocked,
|
|
50
|
+
MethodCallResult<Void> result) {
|
|
51
|
+
this.type = type;
|
|
52
|
+
this.result = result;
|
|
53
|
+
this.blocked = blocked;
|
|
54
|
+
this.channelOrGroupBundle = channelOrGroupBundle;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@KeepForSdk
|
|
58
|
+
public void setCompletionResult() {
|
|
59
|
+
if (!completed) {
|
|
60
|
+
completed = true;
|
|
61
|
+
result.onComplete(null, null);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@KeepForSdk
|
|
66
|
+
public int getType() {
|
|
67
|
+
return type;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@KeepForSdk
|
|
71
|
+
public boolean isBlocked() {
|
|
72
|
+
return blocked;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Nullable
|
|
76
|
+
@KeepForSdk
|
|
77
|
+
public Bundle getChannelOrGroupBundle() {
|
|
78
|
+
return channelOrGroupBundle;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public Map<String, Object> toMap() {
|
|
82
|
+
Map<String, Object> blockStateEventMap = new HashMap<>();
|
|
83
|
+
Map<String, Object> blockStateEventDetailMap = new HashMap<>();
|
|
84
|
+
blockStateEventMap.put("type", type);
|
|
85
|
+
|
|
86
|
+
if (type == BlockStateEvent.TYPE_CHANNEL_BLOCKED
|
|
87
|
+
|| type == BlockStateEvent.TYPE_CHANNEL_GROUP_BLOCKED) {
|
|
88
|
+
String mapKey = type == BlockStateEvent.TYPE_CHANNEL_BLOCKED ? "channel" : "channelGroup";
|
|
89
|
+
if (channelOrGroupBundle != null) {
|
|
90
|
+
blockStateEventDetailMap.put(mapKey, ObjectUtils.bundleToMap(channelOrGroupBundle));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (type == BlockStateEvent.TYPE_APP_BLOCKED) {
|
|
95
|
+
blockStateEventDetailMap.put("blocked", isBlocked());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
blockStateEventMap.put("detail", blockStateEventDetailMap);
|
|
99
|
+
|
|
100
|
+
return blockStateEventMap;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package app.notifee.core.event;
|
|
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 app.notifee.core.KeepForSdk;
|
|
21
|
+
import app.notifee.core.interfaces.MethodCallResult;
|
|
22
|
+
import app.notifee.core.model.NotificationModel;
|
|
23
|
+
|
|
24
|
+
@KeepForSdk
|
|
25
|
+
public class ForegroundServiceEvent {
|
|
26
|
+
private final NotificationModel notification;
|
|
27
|
+
private MethodCallResult<Void> result;
|
|
28
|
+
private boolean completed = false;
|
|
29
|
+
|
|
30
|
+
public ForegroundServiceEvent(
|
|
31
|
+
NotificationModel notificationModel, MethodCallResult<Void> result) {
|
|
32
|
+
this.notification = notificationModel;
|
|
33
|
+
this.result = result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@KeepForSdk
|
|
37
|
+
public NotificationModel getNotification() {
|
|
38
|
+
return notification;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@KeepForSdk
|
|
42
|
+
public void setCompletionResult() {
|
|
43
|
+
if (!completed) {
|
|
44
|
+
completed = true;
|
|
45
|
+
result.onComplete(null, null);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package app.notifee.core.event;
|
|
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.os.Bundle;
|
|
21
|
+
import app.notifee.core.model.NotificationModel;
|
|
22
|
+
import java.util.HashMap;
|
|
23
|
+
import java.util.Map;
|
|
24
|
+
|
|
25
|
+
public class InitialNotificationEvent {
|
|
26
|
+
|
|
27
|
+
private NotificationModel notificationModel;
|
|
28
|
+
private Bundle extras;
|
|
29
|
+
|
|
30
|
+
public InitialNotificationEvent(NotificationModel notificationModel, Bundle extras) {
|
|
31
|
+
this.notificationModel = notificationModel;
|
|
32
|
+
this.extras = extras;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public NotificationModel getNotificationModel() {
|
|
36
|
+
return notificationModel;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public Bundle getExtras() {
|
|
40
|
+
return extras;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public Map<String, Object> toMap() {
|
|
44
|
+
Map<String, Object> initialNotificationEventMap = new HashMap<>();
|
|
45
|
+
initialNotificationEventMap.put("notificationModel", notificationModel.toBundle());
|
|
46
|
+
initialNotificationEventMap.put("extras", extras);
|
|
47
|
+
|
|
48
|
+
return initialNotificationEventMap;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
package app.notifee.core.event;
|
|
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 androidx.annotation.NonNull;
|
|
21
|
+
import app.notifee.core.KeepForSdk;
|
|
22
|
+
|
|
23
|
+
@KeepForSdk
|
|
24
|
+
public class LogEvent {
|
|
25
|
+
@KeepForSdk public static final String LEVEL_ERROR = "error";
|
|
26
|
+
@KeepForSdk public static final String LEVEL_WARN = "warn";
|
|
27
|
+
@KeepForSdk public static final String LEVEL_INFO = "info";
|
|
28
|
+
@KeepForSdk public static final String LEVEL_VERBOSE = "verbose";
|
|
29
|
+
@KeepForSdk public static final String LEVEL_DEBUG = "debug";
|
|
30
|
+
|
|
31
|
+
private final String tag;
|
|
32
|
+
private final String level;
|
|
33
|
+
private final String message;
|
|
34
|
+
private final Throwable throwable;
|
|
35
|
+
|
|
36
|
+
public LogEvent(@NonNull String level, @NonNull String tag, String message) {
|
|
37
|
+
this.tag = tag;
|
|
38
|
+
this.level = level;
|
|
39
|
+
this.message = message;
|
|
40
|
+
this.throwable = null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public LogEvent(@NonNull String level, @NonNull String tag, String message, Throwable throwable) {
|
|
44
|
+
this.tag = tag;
|
|
45
|
+
this.level = level;
|
|
46
|
+
this.message = message;
|
|
47
|
+
this.throwable = throwable;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Logging TAG, used for filtering purposes.
|
|
52
|
+
*
|
|
53
|
+
* @return String
|
|
54
|
+
*/
|
|
55
|
+
@KeepForSdk
|
|
56
|
+
public String getTag() {
|
|
57
|
+
return tag;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@KeepForSdk
|
|
61
|
+
public String getLevel() {
|
|
62
|
+
return level;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@KeepForSdk
|
|
66
|
+
public String getMessage() {
|
|
67
|
+
return message;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@KeepForSdk
|
|
71
|
+
public Throwable getThrowable() {
|
|
72
|
+
return throwable;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package app.notifee.core.event;
|
|
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 androidx.annotation.NonNull;
|
|
21
|
+
|
|
22
|
+
public class MainComponentEvent {
|
|
23
|
+
|
|
24
|
+
private String mainComponent;
|
|
25
|
+
|
|
26
|
+
public MainComponentEvent(@NonNull String mainComponent) {
|
|
27
|
+
this.mainComponent = mainComponent;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public String getMainComponent() {
|
|
31
|
+
return mainComponent;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
package app.notifee.core.event;
|
|
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.os.Bundle;
|
|
21
|
+
import androidx.annotation.Nullable;
|
|
22
|
+
import app.notifee.core.KeepForSdk;
|
|
23
|
+
import app.notifee.core.model.NotificationModel;
|
|
24
|
+
import app.notifee.core.utility.ObjectUtils;
|
|
25
|
+
import java.util.HashMap;
|
|
26
|
+
import java.util.Map;
|
|
27
|
+
|
|
28
|
+
@KeepForSdk
|
|
29
|
+
public class NotificationEvent {
|
|
30
|
+
@KeepForSdk public static final int TYPE_DISMISSED = 0;
|
|
31
|
+
|
|
32
|
+
@KeepForSdk public static final int TYPE_PRESS = 1;
|
|
33
|
+
|
|
34
|
+
@KeepForSdk public static final int TYPE_ACTION_PRESS = 2;
|
|
35
|
+
|
|
36
|
+
@KeepForSdk public static final int TYPE_DELIVERED = 3;
|
|
37
|
+
|
|
38
|
+
@KeepForSdk public static final int TYPE_TRIGGER_NOTIFICATION_CREATED = 7;
|
|
39
|
+
|
|
40
|
+
@KeepForSdk public static final int TYPE_FG_ALREADY_EXIST = 8;
|
|
41
|
+
|
|
42
|
+
private final int type;
|
|
43
|
+
private final Bundle extras;
|
|
44
|
+
private final NotificationModel notification;
|
|
45
|
+
|
|
46
|
+
public NotificationEvent(int type, NotificationModel bundle) {
|
|
47
|
+
this.type = type;
|
|
48
|
+
this.notification = bundle;
|
|
49
|
+
this.extras = null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public NotificationEvent(int type, NotificationModel bundle, Bundle extras) {
|
|
53
|
+
this.type = type;
|
|
54
|
+
this.notification = bundle;
|
|
55
|
+
this.extras = extras;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@KeepForSdk
|
|
59
|
+
public int getType() {
|
|
60
|
+
return type;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@KeepForSdk
|
|
64
|
+
public NotificationModel getNotification() {
|
|
65
|
+
return notification;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public Map<String, Object> toMap() {
|
|
69
|
+
Map<String, Object> eventMap = new HashMap<>();
|
|
70
|
+
Map<String, Object> eventDetailMap = new HashMap<>();
|
|
71
|
+
eventMap.put("type", type);
|
|
72
|
+
|
|
73
|
+
eventDetailMap.put("notification", ObjectUtils.bundleToMap(notification.toBundle()));
|
|
74
|
+
|
|
75
|
+
if (extras != null) {
|
|
76
|
+
Bundle pressAction = extras.getBundle("press_action");
|
|
77
|
+
if (pressAction != null) {
|
|
78
|
+
eventDetailMap.put("press_action", ObjectUtils.bundleToMap(pressAction));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
String input = extras.getString("input");
|
|
82
|
+
if (input != null) {
|
|
83
|
+
eventDetailMap.put("input", input);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
eventMap.put("detail", eventDetailMap);
|
|
88
|
+
|
|
89
|
+
return eventMap;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@KeepForSdk
|
|
93
|
+
@Nullable
|
|
94
|
+
public Bundle getExtras() {
|
|
95
|
+
return extras;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package app.notifee.core.interfaces;
|
|
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 app.notifee.core.KeepForSdk;
|
|
21
|
+
import app.notifee.core.event.BlockStateEvent;
|
|
22
|
+
import app.notifee.core.event.ForegroundServiceEvent;
|
|
23
|
+
import app.notifee.core.event.LogEvent;
|
|
24
|
+
import app.notifee.core.event.NotificationEvent;
|
|
25
|
+
|
|
26
|
+
@KeepForSdk
|
|
27
|
+
public interface EventListener {
|
|
28
|
+
@KeepForSdk
|
|
29
|
+
void onNotificationEvent(NotificationEvent notificationEvent);
|
|
30
|
+
|
|
31
|
+
@KeepForSdk
|
|
32
|
+
void onLogEvent(LogEvent logEvent);
|
|
33
|
+
|
|
34
|
+
@KeepForSdk
|
|
35
|
+
void onBlockStateEvent(BlockStateEvent blockStateEvent);
|
|
36
|
+
|
|
37
|
+
@KeepForSdk
|
|
38
|
+
void onForegroundServiceEvent(ForegroundServiceEvent foregroundServiceEvent);
|
|
39
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package app.notifee.core.interfaces;
|
|
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 androidx.annotation.Nullable;
|
|
21
|
+
import app.notifee.core.KeepForSdk;
|
|
22
|
+
|
|
23
|
+
@KeepForSdk
|
|
24
|
+
public interface MethodCallResult<T> {
|
|
25
|
+
@KeepForSdk
|
|
26
|
+
void onComplete(@Nullable Exception error, T result);
|
|
27
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.os.Bundle;
|
|
21
|
+
import androidx.annotation.NonNull;
|
|
22
|
+
import androidx.annotation.Nullable;
|
|
23
|
+
import java.util.Objects;
|
|
24
|
+
|
|
25
|
+
public class ChannelGroupModel {
|
|
26
|
+
|
|
27
|
+
private final Bundle mChannelGroupBundle;
|
|
28
|
+
|
|
29
|
+
private ChannelGroupModel(Bundle bundle) {
|
|
30
|
+
this.mChannelGroupBundle = bundle;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public static ChannelGroupModel fromBundle(Bundle bundle) {
|
|
34
|
+
return new ChannelGroupModel(bundle);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public @NonNull String getId() {
|
|
38
|
+
return Objects.requireNonNull(mChannelGroupBundle.getString("id"));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public @NonNull String getName() {
|
|
42
|
+
return Objects.requireNonNull(mChannelGroupBundle.getString("name"));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public @Nullable String getDescription() {
|
|
46
|
+
return mChannelGroupBundle.getString("description");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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.graphics.Color;
|
|
21
|
+
import android.os.Bundle;
|
|
22
|
+
import androidx.annotation.NonNull;
|
|
23
|
+
import androidx.annotation.Nullable;
|
|
24
|
+
import androidx.core.app.NotificationCompat;
|
|
25
|
+
import androidx.core.app.NotificationManagerCompat;
|
|
26
|
+
import app.notifee.core.utility.ObjectUtils;
|
|
27
|
+
import java.util.ArrayList;
|
|
28
|
+
import java.util.Objects;
|
|
29
|
+
|
|
30
|
+
public class ChannelModel {
|
|
31
|
+
|
|
32
|
+
private final Bundle mChannelBundle;
|
|
33
|
+
|
|
34
|
+
private ChannelModel(Bundle bundle) {
|
|
35
|
+
this.mChannelBundle = bundle;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public static ChannelModel fromBundle(@NonNull Bundle bundle) {
|
|
39
|
+
return new ChannelModel(bundle);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public @NonNull String getId() {
|
|
43
|
+
return Objects.requireNonNull(mChannelBundle.getString("id"));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public @NonNull String getName() {
|
|
47
|
+
return Objects.requireNonNull(mChannelBundle.getString("name"));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public Boolean getBadge() {
|
|
51
|
+
return mChannelBundle.getBoolean("badge", true);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public Boolean getBypassDnd() {
|
|
55
|
+
return mChannelBundle.getBoolean("bypassDnd", false);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public @Nullable String getDescription() {
|
|
59
|
+
return mChannelBundle.getString("description");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public Boolean getLights() {
|
|
63
|
+
return mChannelBundle.getBoolean("lights", true);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public Boolean getVibration() {
|
|
67
|
+
return mChannelBundle.getBoolean("vibration", true);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public @Nullable String getGroupId() {
|
|
71
|
+
return mChannelBundle.getString("groupId");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public Integer getImportance() {
|
|
75
|
+
if (mChannelBundle.containsKey("importance")) {
|
|
76
|
+
return ObjectUtils.getInt(mChannelBundle.get("importance"));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return NotificationManagerCompat.IMPORTANCE_DEFAULT;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public @Nullable Integer getLightColor() {
|
|
83
|
+
if (mChannelBundle.containsKey("lightColor")) {
|
|
84
|
+
return Color.parseColor(mChannelBundle.getString("lightColor"));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public int getVisibility() {
|
|
91
|
+
if (mChannelBundle.containsKey("visibility")) {
|
|
92
|
+
return ObjectUtils.getInt(mChannelBundle.get("visibility"));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return NotificationCompat.VISIBILITY_PRIVATE;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public long[] getVibrationPattern() {
|
|
99
|
+
if (!mChannelBundle.containsKey("vibrationPattern")) {
|
|
100
|
+
return new long[0];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
ArrayList vibrationPattern =
|
|
104
|
+
Objects.requireNonNull(mChannelBundle.getParcelableArrayList("vibrationPattern"));
|
|
105
|
+
|
|
106
|
+
long[] vibrateArray = new long[vibrationPattern.size()];
|
|
107
|
+
|
|
108
|
+
for (int i = 0; i < vibrationPattern.size(); i++) {
|
|
109
|
+
Integer value = (Integer) vibrationPattern.get(i);
|
|
110
|
+
vibrateArray[i] = value.longValue();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return vibrateArray;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public @Nullable String getSound() {
|
|
117
|
+
if (!mChannelBundle.containsKey("sound")) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return mChannelBundle.getString("sound");
|
|
122
|
+
}
|
|
123
|
+
}
|