@nativescript-community/ui-image 4.3.26 → 4.3.28
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/CHANGELOG.md +10 -0
- package/index.android.d.ts +3 -3
- package/index.android.js +16 -13
- package/index.d.ts +3 -3
- package/index.ios.d.ts +3 -3
- package/index.ios.js +19 -14
- package/package.json +2 -2
- package/platforms/android/java/com/nativescript/image/DraweeView.java +46 -24
- package/platforms/android/ui_image.aar +0 -0
- package/typings/objc!SDWebImage.d.ts +1688 -1429
- package/platforms/ios/src/Info.plist +0 -0
- package/platforms/ios/src/NImage.h +0 -7
- package/platforms/ios/src/NSImageDecodeSizeTransformer.h +0 -11
- package/platforms/ios/src/NSImageDecodeSizeTransformer.m +0 -44
- package/platforms/ios/src/NSImageRoundAsCircleTransformer.h +0 -8
- package/platforms/ios/src/NSImageRoundAsCircleTransformer.m +0 -40
- package/platforms/ios/src/NSImageRoundCornerTransformer.h +0 -13
- package/platforms/ios/src/NSImageRoundCornerTransformer.m +0 -59
- package/platforms/ios/src/module.modulemap +0 -5
- package/vue/index.mjs +0 -8
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [4.3.28](https://github.com/nativescript-community/ui-image/compare/v4.3.27...v4.3.28) (2024-01-23)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* **android:** improvement for future N ([f8e10f5](https://github.com/nativescript-community/ui-image/commit/f8e10f56945dbb76800d9fd90f2c6bd40966423f))
|
11
|
+
|
12
|
+
## [4.3.27](https://github.com/nativescript-community/ui-image/compare/v4.3.26...v4.3.27) (2023-11-24)
|
13
|
+
|
14
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
15
|
+
|
6
16
|
## [4.3.26](https://github.com/nativescript-community/ui-image/compare/v4.3.25...v4.3.26) (2023-11-24)
|
7
17
|
|
8
18
|
**Note:** Version bump only for package @nativescript-community/ui-image
|
package/index.android.d.ts
CHANGED
@@ -10,8 +10,8 @@ export declare class ImagePipeline {
|
|
10
10
|
isInDiskCache(uri: string | android.net.Uri): boolean;
|
11
11
|
isInBitmapMemoryCache(uri: string | android.net.Uri): boolean;
|
12
12
|
evictFromMemoryCache(uri: string | android.net.Uri): void;
|
13
|
-
evictFromDiskCache(uri: string | android.net.Uri): void
|
14
|
-
evictFromCache(uri: string | android.net.Uri): void
|
13
|
+
evictFromDiskCache(uri: string | android.net.Uri): Promise<void>;
|
14
|
+
evictFromCache(uri: string | android.net.Uri): Promise<void>;
|
15
15
|
clearCaches(): void;
|
16
16
|
clearMemoryCaches(): void;
|
17
17
|
clearDiskCaches(): void;
|
@@ -75,7 +75,7 @@ export declare class Img extends ImageBase {
|
|
75
75
|
updateViewSize(imageInfo: any): void;
|
76
76
|
disposeNativeView(): void;
|
77
77
|
get cacheKey(): string | globalAndroid.net.Uri;
|
78
|
-
updateImageUri(): void
|
78
|
+
updateImageUri(): Promise<void>;
|
79
79
|
controllerListener: com.facebook.drawee.controller.ControllerListener<com.facebook.imagepipeline.image.ImageInfo>;
|
80
80
|
protected initImage(): Promise<void>;
|
81
81
|
private updateHierarchy;
|
package/index.android.js
CHANGED
@@ -8,7 +8,7 @@ let initialized = false;
|
|
8
8
|
let initializeConfig;
|
9
9
|
export function initialize(config) {
|
10
10
|
if (!initialized) {
|
11
|
-
const context = Utils.
|
11
|
+
const context = Utils.android.getApplicationContext();
|
12
12
|
if (!context) {
|
13
13
|
initializeConfig = config;
|
14
14
|
return;
|
@@ -72,7 +72,7 @@ function getUri(src, asNative = true) {
|
|
72
72
|
if (Utils.isFileOrResourcePath(imagePath)) {
|
73
73
|
if (imagePath.indexOf(Utils.RESOURCE_PREFIX) === 0) {
|
74
74
|
const resName = imagePath.substring(Utils.RESOURCE_PREFIX.length);
|
75
|
-
const identifier = Utils.
|
75
|
+
const identifier = Utils.android.resources.getDrawableId(resName);
|
76
76
|
if (0 < identifier) {
|
77
77
|
const netUri = new android.net.Uri.Builder().scheme(com.facebook.common.util.UriUtil.LOCAL_RESOURCE_SCHEME).path(java.lang.String.valueOf(identifier)).build();
|
78
78
|
if (asNative) {
|
@@ -113,10 +113,10 @@ export class ImagePipeline {
|
|
113
113
|
evictFromMemoryCache(uri) {
|
114
114
|
this._android.evictFromMemoryCache(this.toUri(uri));
|
115
115
|
}
|
116
|
-
evictFromDiskCache(uri) {
|
116
|
+
async evictFromDiskCache(uri) {
|
117
117
|
this._android.evictFromDiskCache(this.toUri(uri));
|
118
118
|
}
|
119
|
-
evictFromCache(uri) {
|
119
|
+
async evictFromCache(uri) {
|
120
120
|
this._android.evictFromCache(this.toUri(uri));
|
121
121
|
}
|
122
122
|
clearCaches() {
|
@@ -360,14 +360,14 @@ export class Img extends ImageBase {
|
|
360
360
|
}
|
361
361
|
return undefined;
|
362
362
|
}
|
363
|
-
updateImageUri() {
|
363
|
+
async updateImageUri() {
|
364
364
|
const imagePipeLine = getImagePipeline();
|
365
365
|
const cacheKey = this.cacheKey;
|
366
366
|
const src = this.src;
|
367
367
|
if (cacheKey) {
|
368
368
|
// const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
|
369
369
|
// // if (isInCache) {
|
370
|
-
imagePipeLine.evictFromCache(cacheKey);
|
370
|
+
await imagePipeLine.evictFromCache(cacheKey);
|
371
371
|
// }
|
372
372
|
}
|
373
373
|
this.src = null;
|
@@ -448,7 +448,7 @@ export class Img extends ImageBase {
|
|
448
448
|
if (src) {
|
449
449
|
let drawable;
|
450
450
|
if (src instanceof ImageSource) {
|
451
|
-
drawable = new android.graphics.drawable.BitmapDrawable(Utils.
|
451
|
+
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), src.android);
|
452
452
|
this.updateViewSize(src.android);
|
453
453
|
}
|
454
454
|
else if (Utils.isFontIconURI(src)) {
|
@@ -457,7 +457,7 @@ export class Img extends ImageBase {
|
|
457
457
|
// support sync mode only
|
458
458
|
const font = this.style.fontInternal;
|
459
459
|
const color = this.style.color;
|
460
|
-
drawable = new android.graphics.drawable.BitmapDrawable(Utils.
|
460
|
+
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
|
461
461
|
}
|
462
462
|
}
|
463
463
|
if (drawable) {
|
@@ -682,7 +682,7 @@ export class Img extends ImageBase {
|
|
682
682
|
const bottomRightRadius = this.roundBottomRightRadius || 0;
|
683
683
|
const bottomLeftRadius = this.roundBottomLeftRadius || 0;
|
684
684
|
if (topLeftRadius || topRightRadius || bottomRightRadius || bottomLeftRadius) {
|
685
|
-
builder.setCornersRadii(topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius);
|
685
|
+
builder.setCornersRadii(Utils.layout.toDevicePixels(topLeftRadius), Utils.layout.toDevicePixels(topRightRadius), Utils.layout.toDevicePixels(bottomRightRadius), Utils.layout.toDevicePixels(bottomLeftRadius));
|
686
686
|
}
|
687
687
|
this.nativeImageViewProtected.setHierarchy(builder.build());
|
688
688
|
if (!this.mNeedRequestImage) {
|
@@ -699,7 +699,7 @@ export class Img extends ImageBase {
|
|
699
699
|
// support sync mode only
|
700
700
|
const font = this.style.fontInternal;
|
701
701
|
const color = this.style.color;
|
702
|
-
drawable = new android.graphics.drawable.BitmapDrawable(Utils.
|
702
|
+
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
|
703
703
|
}
|
704
704
|
}
|
705
705
|
else if (Utils.isFileOrResourcePath(path)) {
|
@@ -712,7 +712,7 @@ export class Img extends ImageBase {
|
|
712
712
|
}
|
713
713
|
}
|
714
714
|
else {
|
715
|
-
drawable = new android.graphics.drawable.BitmapDrawable(Utils.
|
715
|
+
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), path.android);
|
716
716
|
}
|
717
717
|
return drawable;
|
718
718
|
}
|
@@ -720,14 +720,17 @@ export class Img extends ImageBase {
|
|
720
720
|
const img = ImageSource.fromFileSync(localFilePath);
|
721
721
|
let drawable = null;
|
722
722
|
if (img) {
|
723
|
-
drawable = new android.graphics.drawable.BitmapDrawable(Utils.
|
723
|
+
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), img.android);
|
724
724
|
}
|
725
725
|
return drawable;
|
726
726
|
}
|
727
727
|
getDrawableFromResource(resourceName) {
|
728
|
-
const
|
728
|
+
const application = Utils.android.getApplication();
|
729
|
+
const resources = application.getResources();
|
730
|
+
const identifier = resources.getIdentifier(resourceName.substring(Utils.RESOURCE_PREFIX.length), 'drawable', application.getPackageName());
|
729
731
|
// we return the identifier to allow Fresco to handle memory / caching
|
730
732
|
return identifier;
|
733
|
+
// return Utils.android.getApplicationContext().getDrawable(identifier);
|
731
734
|
}
|
732
735
|
startAnimating() {
|
733
736
|
if (this.nativeImageViewProtected) {
|
package/index.d.ts
CHANGED
@@ -55,7 +55,7 @@ export class Img extends View {
|
|
55
55
|
/**
|
56
56
|
* Removes all images with the specified Uri from the memory or/and disk and reinitialize the 'src'.
|
57
57
|
*/
|
58
|
-
updateImageUri()
|
58
|
+
async updateImageUri();
|
59
59
|
|
60
60
|
/**
|
61
61
|
* Start image animation
|
@@ -378,12 +378,12 @@ export class ImagePipeline {
|
|
378
378
|
/**
|
379
379
|
* Removes all images with the specified Uri from disk cache.
|
380
380
|
*/
|
381
|
-
evictFromDiskCache(uri: string): void;
|
381
|
+
async evictFromDiskCache(uri: string): void;
|
382
382
|
|
383
383
|
/**
|
384
384
|
* Removes all images with the specified Uri from all the caches (memory and disk).
|
385
385
|
*/
|
386
|
-
evictFromCache(uri: string): void;
|
386
|
+
async evictFromCache(uri: string): void;
|
387
387
|
|
388
388
|
/**
|
389
389
|
* Clear all the caches (memory and disk).
|
package/index.ios.d.ts
CHANGED
@@ -20,8 +20,8 @@ export declare class ImagePipeline {
|
|
20
20
|
isInDiskCache(key: string): boolean;
|
21
21
|
isInBitmapMemoryCache(key: string): boolean;
|
22
22
|
evictFromMemoryCache(key: string): void;
|
23
|
-
evictFromDiskCache(key: string): void
|
24
|
-
evictFromCache(key: string): void
|
23
|
+
evictFromDiskCache(key: string): Promise<void>;
|
24
|
+
evictFromCache(key: string): Promise<void>;
|
25
25
|
clearCaches(): void;
|
26
26
|
clearMemoryCaches(): void;
|
27
27
|
clearDiskCaches(): void;
|
@@ -43,7 +43,7 @@ export declare class Img extends ImageBase {
|
|
43
43
|
createNativeView(): UIImageView;
|
44
44
|
_setNativeClipToBounds(): void;
|
45
45
|
onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
|
46
|
-
updateImageUri(): void
|
46
|
+
updateImageUri(): Promise<void>;
|
47
47
|
_setNativeImage(nativeImage: UIImage, animated?: boolean): void;
|
48
48
|
private handleImageLoaded;
|
49
49
|
private onLoadProgress;
|
package/index.ios.js
CHANGED
@@ -89,14 +89,15 @@ export class ImagePipeline {
|
|
89
89
|
evictFromMemoryCache(key) {
|
90
90
|
this.mIos.removeImageFromMemoryForKey(key);
|
91
91
|
}
|
92
|
-
evictFromDiskCache(key) {
|
93
|
-
|
92
|
+
async evictFromDiskCache(key) {
|
93
|
+
return new Promise((resolve) => {
|
94
|
+
this.mIos.removeImageForKeyCacheTypeCompletion(key, 1 /* SDImageCacheType.Disk */, resolve);
|
95
|
+
});
|
94
96
|
}
|
95
|
-
evictFromCache(key) {
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
// this.mIos.removeImageForKeyWithCompletion(getUri(uri).absoluteString, null);
|
97
|
+
async evictFromCache(key) {
|
98
|
+
return new Promise((resolve) => {
|
99
|
+
this.mIos.removeImageForKeyCacheTypeCompletion(key, 3 /* SDImageCacheType.All */, resolve);
|
100
|
+
});
|
100
101
|
}
|
101
102
|
clearCaches() {
|
102
103
|
this.mIos.clearMemory();
|
@@ -265,10 +266,10 @@ export class Img extends ImageBase {
|
|
265
266
|
const viewRatio = width / height;
|
266
267
|
if (viewRatio < ratio) {
|
267
268
|
widthMeasureSpec = layout.makeMeasureSpec(width, layout.EXACTLY);
|
268
|
-
heightMeasureSpec = layout.makeMeasureSpec(
|
269
|
+
heightMeasureSpec = layout.makeMeasureSpec(width / ratio, layout.EXACTLY);
|
269
270
|
}
|
270
271
|
else {
|
271
|
-
widthMeasureSpec = layout.makeMeasureSpec(
|
272
|
+
widthMeasureSpec = layout.makeMeasureSpec(height * ratio, layout.EXACTLY);
|
272
273
|
heightMeasureSpec = layout.makeMeasureSpec(height, layout.EXACTLY);
|
273
274
|
}
|
274
275
|
}
|
@@ -278,18 +279,18 @@ export class Img extends ImageBase {
|
|
278
279
|
}
|
279
280
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
280
281
|
}
|
281
|
-
updateImageUri() {
|
282
|
+
async updateImageUri() {
|
282
283
|
const imagePipeLine = getImagePipeline();
|
283
284
|
const src = this.src;
|
284
285
|
if (!(src instanceof ImageSource)) {
|
285
286
|
const cachekKey = this.mCacheKey || getUri(src).absoluteString;
|
286
287
|
// const isInCache = imagePipeLine.isInBitmapMemoryCache(cachekKey);
|
287
288
|
// if (isInCache) {
|
288
|
-
imagePipeLine.evictFromCache(cachekKey);
|
289
|
+
await imagePipeLine.evictFromCache(cachekKey);
|
289
290
|
// }
|
290
291
|
}
|
291
292
|
this.src = null;
|
292
|
-
// ensure we clear the image as
|
293
|
+
// ensure we clear the image as
|
293
294
|
this._setNativeImage(null, false);
|
294
295
|
this.src = src;
|
295
296
|
}
|
@@ -378,6 +379,10 @@ export class Img extends ImageBase {
|
|
378
379
|
const uri = getUri(src);
|
379
380
|
this.isLoading = true;
|
380
381
|
let options = 2048 /* SDWebImageOptions.ScaleDownLargeImages */ | 1024 /* SDWebImageOptions.AvoidAutoSetImage */;
|
382
|
+
if (this.placeholderImageUri) {
|
383
|
+
this.placeholderImage = this.getUIImage(this.placeholderImageUri);
|
384
|
+
this._setNativeImage(this.placeholderImage, animate);
|
385
|
+
}
|
381
386
|
if (this.noCache) {
|
382
387
|
// const key = uri.absoluteString;
|
383
388
|
// const imagePipeLine = getImagePipeline();
|
@@ -445,8 +450,8 @@ export class Img extends ImageBase {
|
|
445
450
|
this.initImage();
|
446
451
|
}
|
447
452
|
[_c = placeholderImageUriProperty.setNative]() {
|
448
|
-
this.placeholderImage = this.getUIImage(this.placeholderImageUri);
|
449
|
-
this.initImage();
|
453
|
+
// this.placeholderImage = this.getUIImage(this.placeholderImageUri);
|
454
|
+
// this.initImage();
|
450
455
|
}
|
451
456
|
[failureImageUriProperty.setNative]() {
|
452
457
|
// this.updateHierarchy();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-image",
|
3
|
-
"version": "4.3.
|
3
|
+
"version": "4.3.28",
|
4
4
|
"description": "Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.",
|
5
5
|
"main": "./index",
|
6
6
|
"sideEffects": false,
|
@@ -44,5 +44,5 @@
|
|
44
44
|
},
|
45
45
|
"license": "Apache-2.0",
|
46
46
|
"readmeFilename": "README.md",
|
47
|
-
"gitHead": "
|
47
|
+
"gitHead": "482d5862d487c81f0ae413887f9ae3070c549772"
|
48
48
|
}
|
@@ -123,34 +123,40 @@ public class DraweeView extends SimpleDraweeView {
|
|
123
123
|
mLegacyVisibilityHandlingEnabled = legacyVisibilityHandlingEnabled;
|
124
124
|
}
|
125
125
|
|
126
|
-
|
127
|
-
public void updateOutlineProvider() {
|
126
|
+
public void updateOutlineProvider() {
|
128
127
|
Drawable drawable = getBackground();
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
128
|
+
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
129
|
+
// we try to support N setting outline provider now
|
130
|
+
if (!isUsingOutlineProvider && getOutlineProvider() != null) {
|
131
|
+
// already handled somewhere else
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
if (drawable instanceof BorderDrawable && (android.os.Build.VERSION.SDK_INT >= 33 || ((BorderDrawable)drawable).hasUniformBorderRadius())) {
|
135
|
+
setOutlineProvider(new ViewOutlineProvider() {
|
136
|
+
@Override
|
137
|
+
public void getOutline(View view, Outline outline) {
|
138
|
+
Drawable drawable = getBackground();
|
139
|
+
if (drawable instanceof BorderDrawable) {
|
140
|
+
BorderDrawable borderDrawable = (BorderDrawable) drawable;
|
141
|
+
// that if test is only needed until N BorderDrawable is updated to do it
|
142
|
+
if (borderDrawable.hasUniformBorderRadius()) {
|
143
|
+
// outlineRect.set(borderDrawable.getBounds());
|
144
|
+
outline.setRoundRect(borderDrawable.getBounds(), borderDrawable.getBorderBottomLeftRadius());
|
145
|
+
} else {
|
146
|
+
drawable.getOutline(outline);
|
147
|
+
}
|
141
148
|
} else {
|
142
|
-
|
149
|
+
outline.setRect(100, 100, view.getWidth() - 200, view.getHeight() - 200);
|
143
150
|
}
|
144
|
-
} else {
|
145
|
-
outline.setRect(100, 100, view.getWidth() - 200, view.getHeight() - 200);
|
146
151
|
}
|
147
|
-
}
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
setOutlineProvider(null);
|
153
|
-
setClipToOutline(false);
|
152
|
+
});
|
153
|
+
setClipToOutline(true);
|
154
|
+
isUsingOutlineProvider = true;
|
155
|
+
// } else if (android.os.Build.VERSION.SDK_INT >= 21) {
|
156
|
+
// isUsingOutlineProvider = false;
|
157
|
+
// setOutlineProvider(null);
|
158
|
+
// setClipToOutline(false);
|
159
|
+
}
|
154
160
|
}
|
155
161
|
}
|
156
162
|
|
@@ -293,6 +299,22 @@ public class DraweeView extends SimpleDraweeView {
|
|
293
299
|
}
|
294
300
|
|
295
301
|
ImageRequest request = requestBuilder.build();
|
302
|
+
|
303
|
+
// if (object != null && object.optBoolean("async") == false) {
|
304
|
+
// DataSource<CloseableReference<CloseableImage>> dataSource =
|
305
|
+
// imagePipeline.fetchImageFromBitmapCache(imageRequest, uri.toString());
|
306
|
+
// try {
|
307
|
+
// CloseableReference<CloseableImage> result = DataSources.waitForFinalResult(dataSource);
|
308
|
+
// if (result != null) {
|
309
|
+
// // Do something with the image, but do not keep the reference to it!
|
310
|
+
// // The image may get recycled as soon as the reference gets closed below.
|
311
|
+
// // If you need to keep a reference to the image, read the following sections.
|
312
|
+
// }
|
313
|
+
// } finally {
|
314
|
+
// dataSource.close();
|
315
|
+
// }
|
316
|
+
// }
|
317
|
+
|
296
318
|
PipelineDraweeControllerBuilder builder = com.facebook.drawee.backends.pipeline.Fresco.newDraweeControllerBuilder();
|
297
319
|
builder.setImageRequest(request);
|
298
320
|
builder.setCallerContext(uri.toString());
|
Binary file
|