react-native-notify-kit 9.1.21 → 9.2.0
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/README.md +6 -2
- package/RNNotifee.podspec +1 -0
- package/android/build.gradle +67 -35
- package/android/proguard-rules.pro +14 -1
- package/android/schemas/app.notifee.core.database.NotifeeCoreDatabase/1.json +44 -0
- package/android/schemas/app.notifee.core.database.NotifeeCoreDatabase/2.json +51 -0
- package/android/src/androidTest/java/app/notifee/core/ExampleInstrumentedTest.java +25 -0
- package/android/src/androidTest/java/app/notifee/core/database/NotifeeCoreDatabaseTest.java +55 -0
- package/android/src/main/AndroidManifest.xml +71 -4
- package/android/src/main/java/app/notifee/core/AlarmPermissionBroadcastReceiver.java +25 -0
- package/android/src/main/java/app/notifee/core/BlockStateBroadcastReceiver.java +164 -0
- package/android/src/main/java/app/notifee/core/ChannelManager.java +350 -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 +347 -0
- package/android/src/main/java/app/notifee/core/InitProvider.java +93 -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 +570 -0
- package/android/src/main/java/app/notifee/core/NotifeeAlarmManager.java +352 -0
- package/android/src/main/java/app/notifee/core/NotificationAlarmReceiver.java +42 -0
- package/android/src/main/java/app/notifee/core/NotificationManager.java +939 -0
- package/android/src/main/java/app/notifee/core/NotificationPendingIntent.java +191 -0
- package/android/src/main/java/app/notifee/core/NotificationReceiverActivity.java +39 -0
- package/android/src/main/java/app/notifee/core/NotificationReceiverHandler.java +144 -0
- package/android/src/main/java/app/notifee/core/Preferences.java +79 -0
- package/android/src/main/java/app/notifee/core/RebootBroadcastReceiver.java +39 -0
- package/android/src/main/java/app/notifee/core/ReceiverService.java +281 -0
- package/android/src/main/java/app/notifee/core/Worker.java +87 -0
- package/android/src/main/java/app/notifee/core/database/NotifeeCoreDatabase.java +77 -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 +107 -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 +126 -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 +688 -0
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidPressActionModel.java +150 -0
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidStyleModel.java +336 -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 +206 -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 +146 -0
- package/android/src/main/java/app/notifee/core/utility/ObjectUtils.java +191 -0
- package/android/src/main/java/app/notifee/core/utility/PowerManagerUtils.java +338 -0
- package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +308 -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/android/src/test/java/app/notifee/core/model/NotificationAndroidPressActionModelTest.java +56 -0
- package/android/src/test/java/app/notifee/core/model/TimestampTriggerModelTest.java +44 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/version.ts +1 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar +0 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.md5 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha1 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha256 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha512 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.module +0 -146
- package/android/libs/app/notifee/core/202108261754/core-202108261754.module.md5 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.module.sha1 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.module.sha256 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.module.sha512 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom +0 -64
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.md5 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha1 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha256 +0 -1
- package/android/libs/app/notifee/core/202108261754/core-202108261754.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,308 @@
|
|
|
1
|
+
package app.notifee.core.utility;
|
|
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.content.Context;
|
|
21
|
+
import android.graphics.Bitmap;
|
|
22
|
+
import android.graphics.Canvas;
|
|
23
|
+
import android.graphics.Color;
|
|
24
|
+
import android.graphics.Paint;
|
|
25
|
+
import android.graphics.PorterDuff;
|
|
26
|
+
import android.graphics.PorterDuffXfermode;
|
|
27
|
+
import android.graphics.Rect;
|
|
28
|
+
import android.media.RingtoneManager;
|
|
29
|
+
import android.net.Uri;
|
|
30
|
+
import android.util.TypedValue;
|
|
31
|
+
import androidx.annotation.NonNull;
|
|
32
|
+
import androidx.annotation.Nullable;
|
|
33
|
+
import app.notifee.core.ContextHolder;
|
|
34
|
+
import app.notifee.core.Logger;
|
|
35
|
+
import com.facebook.common.executors.CallerThreadExecutor;
|
|
36
|
+
import com.facebook.common.references.CloseableReference;
|
|
37
|
+
import com.facebook.datasource.DataSource;
|
|
38
|
+
import com.facebook.drawee.backends.pipeline.Fresco;
|
|
39
|
+
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
|
|
40
|
+
import com.facebook.imagepipeline.image.CloseableImage;
|
|
41
|
+
import com.facebook.imagepipeline.request.ImageRequest;
|
|
42
|
+
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
43
|
+
import com.google.common.util.concurrent.ListenableFuture;
|
|
44
|
+
import com.google.common.util.concurrent.SettableFuture;
|
|
45
|
+
import java.util.HashMap;
|
|
46
|
+
import java.util.Map;
|
|
47
|
+
|
|
48
|
+
public class ResourceUtils {
|
|
49
|
+
private static final String TAG = "ResourceUtils";
|
|
50
|
+
private static final String LOCAL_RESOURCE_SCHEME = "res";
|
|
51
|
+
private static volatile Map<String, Integer> sResourceIdCache;
|
|
52
|
+
|
|
53
|
+
public static Map<String, Integer> getResourceIdCache() {
|
|
54
|
+
if (sResourceIdCache == null) {
|
|
55
|
+
synchronized (ResourceUtils.class) {
|
|
56
|
+
if (sResourceIdCache == null) {
|
|
57
|
+
sResourceIdCache = new HashMap<>();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return sResourceIdCache;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public static Uri getImageSourceUri(String source) {
|
|
65
|
+
try {
|
|
66
|
+
Uri uri = Uri.parse(source);
|
|
67
|
+
// verify a scheme is set,
|
|
68
|
+
// so that relative uri (used by static resources) are not handled
|
|
69
|
+
if (uri.getScheme() == null) {
|
|
70
|
+
return getResourceDrawableUri(source);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return uri;
|
|
74
|
+
} catch (Exception e) {
|
|
75
|
+
return getResourceDrawableUri(source);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public static Uri getResourceDrawableUri(@Nullable String name) {
|
|
80
|
+
int resId = getResourceIdByName(name, "drawable");
|
|
81
|
+
return resId > 0
|
|
82
|
+
? new Uri.Builder().scheme(LOCAL_RESOURCE_SCHEME).path(String.valueOf(resId)).build()
|
|
83
|
+
: Uri.EMPTY;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns a circular Bitmap from another bitmap. The original bitmap can be any shape.
|
|
88
|
+
*
|
|
89
|
+
* @param bitmap
|
|
90
|
+
* @return Bitmap
|
|
91
|
+
*/
|
|
92
|
+
public static Bitmap getCircularBitmap(Bitmap bitmap) {
|
|
93
|
+
Bitmap output;
|
|
94
|
+
Rect srcRect, dstRect;
|
|
95
|
+
float r;
|
|
96
|
+
final int width = bitmap.getWidth();
|
|
97
|
+
final int height = bitmap.getHeight();
|
|
98
|
+
|
|
99
|
+
if (width > height) {
|
|
100
|
+
output = Bitmap.createBitmap(height, height, Bitmap.Config.ARGB_8888);
|
|
101
|
+
int left = (width - height) / 2;
|
|
102
|
+
int right = left + height;
|
|
103
|
+
srcRect = new Rect(left, 0, right, height);
|
|
104
|
+
dstRect = new Rect(0, 0, height, height);
|
|
105
|
+
r = height / 2;
|
|
106
|
+
} else {
|
|
107
|
+
output = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888);
|
|
108
|
+
int top = (height - width) / 2;
|
|
109
|
+
int bottom = top + width;
|
|
110
|
+
srcRect = new Rect(0, top, width, bottom);
|
|
111
|
+
dstRect = new Rect(0, 0, width, width);
|
|
112
|
+
r = width / 2;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
final Canvas canvas = new Canvas(output);
|
|
116
|
+
|
|
117
|
+
final int color = Color.RED;
|
|
118
|
+
final Paint paint = new Paint();
|
|
119
|
+
|
|
120
|
+
paint.setAntiAlias(true);
|
|
121
|
+
canvas.drawARGB(0, 0, 0, 0);
|
|
122
|
+
paint.setColor(color);
|
|
123
|
+
canvas.drawCircle(r, r, r, paint);
|
|
124
|
+
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
|
125
|
+
canvas.drawBitmap(bitmap, srcRect, dstRect, paint);
|
|
126
|
+
|
|
127
|
+
return output;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Returns a Bitmap from any given HTTP image URL, or local resource.
|
|
132
|
+
*
|
|
133
|
+
* @param imageUrl
|
|
134
|
+
* @return Bitmap or null if the image failed to load
|
|
135
|
+
*/
|
|
136
|
+
public static ListenableFuture<Bitmap> getImageBitmapFromUrl(String imageUrl) {
|
|
137
|
+
Uri imageUri;
|
|
138
|
+
final SettableFuture<Bitmap> bitmapTCS = SettableFuture.create();
|
|
139
|
+
|
|
140
|
+
if (!imageUrl.contains("/")) {
|
|
141
|
+
String imageResourceUrl = getImageResourceUrl(imageUrl);
|
|
142
|
+
if (imageResourceUrl == null) {
|
|
143
|
+
bitmapTCS.set(null);
|
|
144
|
+
return bitmapTCS;
|
|
145
|
+
}
|
|
146
|
+
imageUri = getImageSourceUri(imageResourceUrl);
|
|
147
|
+
} else {
|
|
148
|
+
imageUri = getImageSourceUri(imageUrl);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(imageUri).build();
|
|
152
|
+
|
|
153
|
+
// TODO(helenaford): handle destroying of fresco after use in background state
|
|
154
|
+
// Needed when the app is killed, and the Fresco hasn't yet been initialized by React Native
|
|
155
|
+
if (!Fresco.hasBeenInitialized()) {
|
|
156
|
+
Logger.w(TAG, "Fresco initializing natively by Notifee");
|
|
157
|
+
|
|
158
|
+
// TODO(helenaford): expand on this to initialize with a custom imagePipelineConfig
|
|
159
|
+
Fresco.initialize(ContextHolder.getApplicationContext());
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
DataSource<CloseableReference<CloseableImage>> dataSource =
|
|
163
|
+
Fresco.getImagePipeline()
|
|
164
|
+
.fetchDecodedImage(imageRequest, ContextHolder.getApplicationContext());
|
|
165
|
+
|
|
166
|
+
dataSource.subscribe(
|
|
167
|
+
new BaseBitmapDataSubscriber() {
|
|
168
|
+
@Override
|
|
169
|
+
protected void onNewResultImpl(@Nullable Bitmap bitmap) {
|
|
170
|
+
bitmapTCS.set(bitmap);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@Override
|
|
174
|
+
protected void onFailureImpl(
|
|
175
|
+
@NonNull DataSource<CloseableReference<CloseableImage>> dataSource) {
|
|
176
|
+
Logger.e(TAG, "Failed to load an image: " + imageUrl, dataSource.getFailureCause());
|
|
177
|
+
bitmapTCS.set(null);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
CallerThreadExecutor.getInstance());
|
|
181
|
+
|
|
182
|
+
return bitmapTCS;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Returns a resource path for a local resource
|
|
187
|
+
*
|
|
188
|
+
* @param icon
|
|
189
|
+
* @return
|
|
190
|
+
*/
|
|
191
|
+
private static String getImageResourceUrl(String icon) {
|
|
192
|
+
int resourceId = getResourceIdByName(icon, "mipmap");
|
|
193
|
+
|
|
194
|
+
if (resourceId == 0) {
|
|
195
|
+
resourceId = getResourceIdByName(icon, "drawable");
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (resourceId == 0) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return resourceId > 0
|
|
203
|
+
? new Uri.Builder()
|
|
204
|
+
.scheme(LOCAL_RESOURCE_SCHEME)
|
|
205
|
+
.path(String.valueOf(resourceId))
|
|
206
|
+
.build()
|
|
207
|
+
.toString()
|
|
208
|
+
: Uri.EMPTY.toString();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Gets a resource ID by name.
|
|
213
|
+
*
|
|
214
|
+
* @param resourceName
|
|
215
|
+
* @return integer or 0 if not found
|
|
216
|
+
*/
|
|
217
|
+
public static int getImageResourceId(String resourceName) {
|
|
218
|
+
int resourceId = getResourceIdByName(resourceName, "mipmap");
|
|
219
|
+
if (resourceId == 0) {
|
|
220
|
+
resourceId = getResourceIdByName(resourceName, "drawable");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return resourceId;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Attempts to find a resource id by name and type */
|
|
227
|
+
private static int getResourceIdByName(String name, String type) {
|
|
228
|
+
if (name == null || name.isEmpty()) {
|
|
229
|
+
return 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
name = name.toLowerCase().replace("-", "_");
|
|
233
|
+
|
|
234
|
+
String key = name + "_" + type;
|
|
235
|
+
|
|
236
|
+
synchronized (ResourceUtils.class) {
|
|
237
|
+
if (getResourceIdCache().containsKey(key)) {
|
|
238
|
+
// noinspection ConstantConditions
|
|
239
|
+
return getResourceIdCache().get(key);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
Context context = ContextHolder.getApplicationContext();
|
|
243
|
+
String packageName = context.getPackageName();
|
|
244
|
+
|
|
245
|
+
int id = context.getResources().getIdentifier(name, type, packageName);
|
|
246
|
+
getResourceIdCache().put(key, id);
|
|
247
|
+
return id;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
public static @Nullable String getSoundName(Uri sound) {
|
|
252
|
+
if (sound == null) return null;
|
|
253
|
+
if (sound.toString().contains("android.resource")) {
|
|
254
|
+
String soundFile = sound.getLastPathSegment();
|
|
255
|
+
try {
|
|
256
|
+
int resourceId = Integer.valueOf(soundFile);
|
|
257
|
+
Logger.e(
|
|
258
|
+
TAG,
|
|
259
|
+
"Loaded sound by resource id. New app builds will fail to play sound. Create a new"
|
|
260
|
+
+ " channel to resolve. Issue #341");
|
|
261
|
+
if (resourceId != 0) {
|
|
262
|
+
TypedValue value = new TypedValue();
|
|
263
|
+
Context context = ContextHolder.getApplicationContext();
|
|
264
|
+
context.getResources().getValue(resourceId, value, true);
|
|
265
|
+
|
|
266
|
+
CharSequence soundString = value.string;
|
|
267
|
+
if (soundString != null || soundString.length() > 0) {
|
|
268
|
+
return soundString.toString().replace("res/raw/", "");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
} catch (NumberFormatException nfe) {
|
|
272
|
+
// This implies the sound URI last path segment was by file name, not resourceId
|
|
273
|
+
// They were by resourceId prior to issue #341 where we learned that leads to unstable URIs
|
|
274
|
+
// Now we verify the file exists but use the file name from the raw directory
|
|
275
|
+
// We still attempt to resolve by resourceId above to gracefully handle URIs created via our
|
|
276
|
+
// previous behavior
|
|
277
|
+
return soundFile;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// TODO parse system sounds
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
public static @Nullable Uri getSoundUri(String sound) {
|
|
286
|
+
Context context = ContextHolder.getApplicationContext();
|
|
287
|
+
if (sound == null) {
|
|
288
|
+
return null;
|
|
289
|
+
} else if (sound.contains("://")) {
|
|
290
|
+
return Uri.parse(sound);
|
|
291
|
+
} else if (sound.equalsIgnoreCase("default")) {
|
|
292
|
+
return RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
|
293
|
+
} else {
|
|
294
|
+
// The API user is attempting to set a sound by file name, verify it exists
|
|
295
|
+
int soundResourceId = getResourceIdByName(sound, "raw");
|
|
296
|
+
if (soundResourceId == 0 && sound.contains(".")) {
|
|
297
|
+
soundResourceId = getResourceIdByName(sound.substring(0, sound.lastIndexOf('.')), "raw");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (soundResourceId == 0) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Use the actual sound name vs the resource ID, to obtain a stable URI, Issue #341
|
|
305
|
+
return Uri.parse("android.resource://" + context.getPackageName() + "/raw/" + sound);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package app.notifee.core.utility;
|
|
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.text.Spanned;
|
|
21
|
+
import androidx.core.text.HtmlCompat;
|
|
22
|
+
|
|
23
|
+
public class TextUtils {
|
|
24
|
+
|
|
25
|
+
public static Spanned fromHtml(String text) {
|
|
26
|
+
return HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY);
|
|
27
|
+
}
|
|
28
|
+
}
|
package/android/src/test/java/app/notifee/core/model/NotificationAndroidPressActionModelTest.java
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package app.notifee.core.model;
|
|
2
|
+
|
|
3
|
+
import static org.junit.Assert.assertEquals;
|
|
4
|
+
import static org.junit.Assert.assertNull;
|
|
5
|
+
|
|
6
|
+
import android.os.Bundle;
|
|
7
|
+
import org.junit.Test;
|
|
8
|
+
import org.junit.runner.RunWith;
|
|
9
|
+
import org.robolectric.RobolectricTestRunner;
|
|
10
|
+
|
|
11
|
+
@RunWith(RobolectricTestRunner.class)
|
|
12
|
+
public class NotificationAndroidPressActionModelTest {
|
|
13
|
+
|
|
14
|
+
@Test
|
|
15
|
+
public void getLaunchActivity_defaultId_noLaunchActivity_returnsDefault() {
|
|
16
|
+
Bundle bundle = new Bundle();
|
|
17
|
+
bundle.putString("id", "default");
|
|
18
|
+
|
|
19
|
+
NotificationAndroidPressActionModel model =
|
|
20
|
+
NotificationAndroidPressActionModel.fromBundle(bundle);
|
|
21
|
+
|
|
22
|
+
assertEquals(
|
|
23
|
+
"when id is 'default' and launchActivity is not set, should return 'default'",
|
|
24
|
+
"default",
|
|
25
|
+
model.getLaunchActivity());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Test
|
|
29
|
+
public void getLaunchActivity_defaultId_explicitLaunchActivity_returnsExplicit() {
|
|
30
|
+
Bundle bundle = new Bundle();
|
|
31
|
+
bundle.putString("id", "default");
|
|
32
|
+
bundle.putString("launchActivity", "com.example.CustomActivity");
|
|
33
|
+
|
|
34
|
+
NotificationAndroidPressActionModel model =
|
|
35
|
+
NotificationAndroidPressActionModel.fromBundle(bundle);
|
|
36
|
+
|
|
37
|
+
assertEquals(
|
|
38
|
+
"when id is 'default' and launchActivity is explicitly set, should return the explicit"
|
|
39
|
+
+ " value",
|
|
40
|
+
"com.example.CustomActivity",
|
|
41
|
+
model.getLaunchActivity());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Test
|
|
45
|
+
public void getLaunchActivity_nonDefaultId_noLaunchActivity_returnsNull() {
|
|
46
|
+
Bundle bundle = new Bundle();
|
|
47
|
+
bundle.putString("id", "custom-action");
|
|
48
|
+
|
|
49
|
+
NotificationAndroidPressActionModel model =
|
|
50
|
+
NotificationAndroidPressActionModel.fromBundle(bundle);
|
|
51
|
+
|
|
52
|
+
assertNull(
|
|
53
|
+
"when id is not 'default' and launchActivity is not set, should return null",
|
|
54
|
+
model.getLaunchActivity());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package app.notifee.core.model;
|
|
2
|
+
|
|
3
|
+
import static org.junit.Assert.assertEquals;
|
|
4
|
+
import static org.junit.Assert.assertNull;
|
|
5
|
+
|
|
6
|
+
import android.os.Bundle;
|
|
7
|
+
import org.junit.Before;
|
|
8
|
+
import org.junit.Test;
|
|
9
|
+
|
|
10
|
+
public class TimestampTriggerModelTest {
|
|
11
|
+
private TimestampTriggerModel mTimestampTriggerModel = null;
|
|
12
|
+
|
|
13
|
+
@Before
|
|
14
|
+
public void before() {
|
|
15
|
+
Bundle trigger = new Bundle();
|
|
16
|
+
Bundle triggerComponents = new Bundle();
|
|
17
|
+
triggerComponents.putInt("minute", 1);
|
|
18
|
+
triggerComponents.putInt("hour", 1);
|
|
19
|
+
triggerComponents.putInt("day", 1);
|
|
20
|
+
triggerComponents.putInt("month", 12);
|
|
21
|
+
triggerComponents.putInt("weekday", 3);
|
|
22
|
+
triggerComponents.putInt("weekdayOrdinal", 2);
|
|
23
|
+
|
|
24
|
+
// The ISO 8601 week date of the year.
|
|
25
|
+
triggerComponents.putInt("weekOfYear", 24);
|
|
26
|
+
// The week number of the months.
|
|
27
|
+
triggerComponents.putInt("weekOfMonth", 2);
|
|
28
|
+
|
|
29
|
+
trigger.putBundle("components", triggerComponents);
|
|
30
|
+
mTimestampTriggerModel = TimestampTriggerModel.fromBundle(trigger);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Test
|
|
34
|
+
public void testBundleValues() {
|
|
35
|
+
assertEquals(
|
|
36
|
+
"with no 'repeatFrequency', interval should be -1",
|
|
37
|
+
-1,
|
|
38
|
+
mTimestampTriggerModel.getInterval());
|
|
39
|
+
assertNull(
|
|
40
|
+
"with no 'repeatFrequency', TimeUnit should be null", mTimestampTriggerModel.getTimeUnit());
|
|
41
|
+
assertEquals(
|
|
42
|
+
"with no 'repeatFrequency', delay should be 0", 0, mTimestampTriggerModel.getDelay());
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "9.
|
|
1
|
+
export declare const version = "9.2.0";
|
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-notify-kit",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"author": "Marco Crupi",
|
|
5
5
|
"description": "Maintained Notifee-compatible fork for React Native — advanced local notifications for Android & iOS.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"validate:all:ts": "tsc --project ./",
|
|
10
10
|
"build": "genversion --es6 --semi src/version.ts && tsc",
|
|
11
|
-
"build:clean": "rimraf android/
|
|
11
|
+
"build:clean": "rimraf android/build && rimraf ios/build && rimraf dist",
|
|
12
12
|
"build:watch": "tsc --watch",
|
|
13
13
|
"prepare": "yarn run build",
|
|
14
14
|
"prepublishOnly": "cd ../.. && yarn run build:core",
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '9.
|
|
2
|
+
export const version = '9.2.0';
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
6a7a27d06bb47e3256e43cf89f697a06
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1ebff59e51ed59546bebeda601ffa872dc45e282
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4f0ed80e12c0b1679841d2f61c273f67302ae5cae5a2ffdd8ed4dae8b21492e0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3582b2abd061836f15873af1a2c01e234ff1b98162b39626befc7b1bbcb969e131c1ce9eed51a22d3dfc26cd135987a5846ed8a455dec89a51077d4d818ec590
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"formatVersion": "1.1",
|
|
3
|
-
"component": {
|
|
4
|
-
"group": "app.notifee",
|
|
5
|
-
"module": "core",
|
|
6
|
-
"version": "202108261754",
|
|
7
|
-
"attributes": {
|
|
8
|
-
"org.gradle.status": "release"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"createdBy": {
|
|
12
|
-
"gradle": {
|
|
13
|
-
"version": "8.9"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"variants": [
|
|
17
|
-
{
|
|
18
|
-
"name": "releaseVariantReleaseApiPublication",
|
|
19
|
-
"attributes": {
|
|
20
|
-
"org.gradle.category": "library",
|
|
21
|
-
"org.gradle.dependency.bundling": "external",
|
|
22
|
-
"org.gradle.libraryelements": "aar",
|
|
23
|
-
"org.gradle.usage": "java-api"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": [
|
|
26
|
-
{
|
|
27
|
-
"group": "androidx.annotation",
|
|
28
|
-
"module": "annotation",
|
|
29
|
-
"version": {
|
|
30
|
-
"requires": "1.3.0"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"group": "androidx.concurrent",
|
|
35
|
-
"module": "concurrent-futures",
|
|
36
|
-
"version": {
|
|
37
|
-
"requires": "1.1.0"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"group": "androidx.work",
|
|
42
|
-
"module": "work-runtime",
|
|
43
|
-
"version": {
|
|
44
|
-
"requires": "2.11.1"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"group": "org.greenrobot",
|
|
49
|
-
"module": "eventbus",
|
|
50
|
-
"version": {
|
|
51
|
-
"requires": "3.3.1"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"files": [
|
|
56
|
-
{
|
|
57
|
-
"name": "core-202108261754.aar",
|
|
58
|
-
"url": "core-202108261754.aar",
|
|
59
|
-
"size": 111312,
|
|
60
|
-
"sha512": "3582b2abd061836f15873af1a2c01e234ff1b98162b39626befc7b1bbcb969e131c1ce9eed51a22d3dfc26cd135987a5846ed8a455dec89a51077d4d818ec590",
|
|
61
|
-
"sha256": "4f0ed80e12c0b1679841d2f61c273f67302ae5cae5a2ffdd8ed4dae8b21492e0",
|
|
62
|
-
"sha1": "1ebff59e51ed59546bebeda601ffa872dc45e282",
|
|
63
|
-
"md5": "6a7a27d06bb47e3256e43cf89f697a06"
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"name": "releaseVariantReleaseRuntimePublication",
|
|
69
|
-
"attributes": {
|
|
70
|
-
"org.gradle.category": "library",
|
|
71
|
-
"org.gradle.dependency.bundling": "external",
|
|
72
|
-
"org.gradle.libraryelements": "aar",
|
|
73
|
-
"org.gradle.usage": "java-runtime"
|
|
74
|
-
},
|
|
75
|
-
"dependencies": [
|
|
76
|
-
{
|
|
77
|
-
"group": "com.facebook.fresco",
|
|
78
|
-
"module": "fresco",
|
|
79
|
-
"version": {
|
|
80
|
-
"requires": "2.6.0"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"group": "com.google.guava",
|
|
85
|
-
"module": "guava",
|
|
86
|
-
"version": {
|
|
87
|
-
"requires": "33.5.0-android"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"group": "androidx.core",
|
|
92
|
-
"module": "core",
|
|
93
|
-
"version": {
|
|
94
|
-
"requires": "1.6.0"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"group": "androidx.room",
|
|
99
|
-
"module": "room-runtime",
|
|
100
|
-
"version": {
|
|
101
|
-
"requires": "2.8.4"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"group": "androidx.annotation",
|
|
106
|
-
"module": "annotation",
|
|
107
|
-
"version": {
|
|
108
|
-
"requires": "1.3.0"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"group": "androidx.concurrent",
|
|
113
|
-
"module": "concurrent-futures",
|
|
114
|
-
"version": {
|
|
115
|
-
"requires": "1.1.0"
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
"group": "androidx.work",
|
|
120
|
-
"module": "work-runtime",
|
|
121
|
-
"version": {
|
|
122
|
-
"requires": "2.11.1"
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"group": "org.greenrobot",
|
|
127
|
-
"module": "eventbus",
|
|
128
|
-
"version": {
|
|
129
|
-
"requires": "3.3.1"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
"files": [
|
|
134
|
-
{
|
|
135
|
-
"name": "core-202108261754.aar",
|
|
136
|
-
"url": "core-202108261754.aar",
|
|
137
|
-
"size": 111312,
|
|
138
|
-
"sha512": "3582b2abd061836f15873af1a2c01e234ff1b98162b39626befc7b1bbcb969e131c1ce9eed51a22d3dfc26cd135987a5846ed8a455dec89a51077d4d818ec590",
|
|
139
|
-
"sha256": "4f0ed80e12c0b1679841d2f61c273f67302ae5cae5a2ffdd8ed4dae8b21492e0",
|
|
140
|
-
"sha1": "1ebff59e51ed59546bebeda601ffa872dc45e282",
|
|
141
|
-
"md5": "6a7a27d06bb47e3256e43cf89f697a06"
|
|
142
|
-
}
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ec7b2604f6c5d14387879e78f32d6fb4
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
95aaa0381cd97f59c145f1c4f3468070cbd99ae4
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5ba89e66e16caa67126861cdc91ea0331c68ed3bbd160ce8022ad1960e53644c
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
8ecfdf95ee33bebdef0a8a2864c0d2bc2b0f351d029ce17e03b700d15b254ce4f01463e251d9481e71066bb118bf23f806c02ac386e076af5088949f3802e137
|