@nativescript-community/ui-image 4.3.11 → 4.3.13

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 CHANGED
@@ -3,6 +3,18 @@
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.13](https://github.com/nativescript-community/ui-image/compare/v4.3.12...v4.3.13) (2023-09-27)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **android:** border radius correctly working now ([69c2732](https://github.com/nativescript-community/ui-image/commit/69c27327ebc627901a6aa4e7617b8975b3d14bc4))
11
+
12
+ ## [4.3.12](https://github.com/nativescript-community/ui-image/compare/v4.3.11...v4.3.12) (2023-09-26)
13
+
14
+ ### Bug Fixes
15
+
16
+ * **android:** zoomimage not showing anything ([a8c666b](https://github.com/nativescript-community/ui-image/commit/a8c666bec8ffd0b3bc0907e0e9ddab89ec8dfbaf))
17
+
6
18
  ## [4.3.11](https://github.com/nativescript-community/ui-image/compare/v4.3.10...v4.3.11) (2023-08-15)
7
19
 
8
20
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.3.11",
3
+ "version": "4.3.13",
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": "c4c455b78a420a512dd17bdc08b2aa5a0a0e4ed4"
47
+ "gitHead": "0191483b8075a1fc9d6f7c8ef2f6b7d8a0bd3a78"
48
48
  }
@@ -1,6 +1,6 @@
1
1
  import groovy.json.JsonSlurper
2
2
  dependencies {
3
- def frescoVersion = project.hasProperty("frescoVersion") ? project.frescoVersion : "3.0.0"
3
+ def frescoVersion = project.hasProperty("frescoVersion") ? project.frescoVersion : "2.6.0"
4
4
 
5
5
  implementation("com.facebook.fresco:fresco:$frescoVersion") {
6
6
  exclude group: 'com.facebook.soloader', module: 'soloader'
@@ -9,11 +9,7 @@ dependencies {
9
9
  implementation("com.facebook.fresco:imagepipeline-okhttp3:$frescoVersion") {
10
10
  exclude group: 'com.facebook.soloader', module: 'soloader'
11
11
  }
12
- implementation('com.facebook.fresco:nativeimagetranscoder') {
13
- version {
14
- strictly '2.6.0'
15
- }
16
- }
12
+ implementation("com.facebook.fresco:nativeimagetranscoder:$frescoVersion")
17
13
  implementation 'com.facebook.infer.annotation:infer-annotation:0.18.0'
18
14
  // implementation ("com.facebook.fresco:animated-gif:$frescoVersion") {
19
15
  // exclude group: 'com.facebook.soloader', module: 'soloader'
@@ -4,6 +4,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
4
4
  import com.facebook.imagepipeline.request.ImageRequestBuilder;
5
5
  import com.facebook.imagepipeline.request.ImageRequest;
6
6
  import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder;
7
+ import com.facebook.drawee.generic.GenericDraweeHierarchy;
7
8
 
8
9
  import android.graphics.Outline;
9
10
  import android.graphics.Rect;
@@ -13,6 +14,7 @@ import android.view.View;
13
14
  import android.content.Context;
14
15
  import android.os.Build;
15
16
  import android.util.Log;
17
+ import android.util.AttributeSet;
16
18
 
17
19
  import android.graphics.Canvas;
18
20
  import android.graphics.Path;
@@ -34,58 +36,56 @@ import java.util.Arrays;
34
36
  public class DraweeView extends SimpleDraweeView {
35
37
  public int imageWidth = 0;
36
38
  public int imageHeight = 0;
39
+ public boolean isUsingOutlineProvider = false;
37
40
  private static Paint clipPaint;
38
41
 
39
- private boolean clipEnabled = true;
40
-
41
- public void setClipToBounds(boolean value) {
42
- clipEnabled = value;
43
- if (value) {
44
- if (android.os.Build.VERSION.SDK_INT >= 21) {
45
- setOutlineProvider(new ViewOutlineProvider() {
46
- @Override
47
- public void getOutline(View view, Outline outline) {
48
- Drawable drawable = getBackground();
49
- if (drawable instanceof BorderDrawable) {
50
- BorderDrawable borderDrawable = (BorderDrawable) drawable;
51
- float borderTopLeftRadius = borderDrawable.getBorderTopLeftRadius();
52
- float borderTopRightRadius = borderDrawable.getBorderTopRightRadius();
53
- float borderBottomRightRadius = borderDrawable.getBorderBottomRightRadius();
54
- float borderBottomLeftRadius = borderDrawable.getBorderBottomLeftRadius();
55
- float borderLeftWidth = borderDrawable.getBorderLeftWidth();
56
- float borderBottomWidth = borderDrawable.getBorderBottomWidth();
57
- float borderTopWidth = borderDrawable.getBorderTopWidth();
58
- float borderRightWidth = borderDrawable.getBorderRightWidth();
59
- if (android.os.Build.VERSION.SDK_INT >= 21 &&
60
- borderDrawable.getUniformBorderRadius() > 0 &&
61
- borderLeftWidth == 0 &&
62
- borderBottomWidth == 0 &&
63
- borderTopWidth == 0 &&
64
- borderRightWidth == 0) {
65
- drawable.getOutline(outline);
66
- return;
67
- }
42
+ public DraweeView(Context context, GenericDraweeHierarchy hierarchy) {
43
+ super(context);
44
+ }
45
+
46
+ public DraweeView(Context context) {
47
+ super(context);
48
+ }
49
+
50
+ public DraweeView(Context context, AttributeSet attrs) {
51
+ super(context, attrs);
52
+ }
53
+
54
+ public DraweeView(Context context, AttributeSet attrs, int defStyle) {
55
+ super(context, attrs, defStyle);
56
+ }
57
+
58
+ // private final Rect outlineRect = new RectF();
59
+ public void updateOutlineProvider() {
60
+ Drawable drawable = getBackground();
61
+ isUsingOutlineProvider = false;
62
+ if (android.os.Build.VERSION.SDK_INT >= 21 && drawable instanceof BorderDrawable && (android.os.Build.VERSION.SDK_INT >= 33 || ((BorderDrawable)drawable).hasUniformBorderRadius())) {
63
+ setOutlineProvider(new ViewOutlineProvider() {
64
+ @Override
65
+ public void getOutline(View view, Outline outline) {
66
+ Drawable drawable = getBackground();
67
+ if (drawable instanceof BorderDrawable) {
68
+ BorderDrawable borderDrawable = (BorderDrawable) drawable;
69
+ // that if test is only needed until N BorderDrawable is updated to do it
70
+ if (borderDrawable.hasUniformBorderRadius()) {
71
+ // outlineRect.set(borderDrawable.getBounds());
72
+ outline.setRoundRect(borderDrawable.getBounds(), borderDrawable.getBorderBottomLeftRadius());
73
+ } else {
74
+ drawable.getOutline(outline);
68
75
  }
69
- outline.setRect(0, 0, view.getWidth(), view.getHeight());
76
+ } else {
77
+ outline.setRect(100, 100, view.getWidth() - 200, view.getHeight() - 200);
70
78
  }
71
- });
72
- setClipToOutline(true);
73
- }
79
+ }
80
+ });
81
+ setClipToOutline(true);
82
+ isUsingOutlineProvider = true;
74
83
  } else if (android.os.Build.VERSION.SDK_INT >= 21) {
75
84
  setOutlineProvider(null);
76
85
  setClipToOutline(false);
77
86
  }
78
87
  }
79
88
 
80
- public boolean getClipToBounds() {
81
- return clipEnabled;
82
- }
83
-
84
- public DraweeView(Context context) {
85
- super(context);
86
- setClipToBounds(clipEnabled);
87
- }
88
-
89
89
  @Override
90
90
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
91
91
  int widthMode = MeasureSpec.getMode(widthMeasureSpec);
@@ -123,13 +123,6 @@ public class DraweeView extends SimpleDraweeView {
123
123
  float borderBottomWidth = borderDrawable.getBorderBottomWidth();
124
124
  float borderTopWidth = borderDrawable.getBorderTopWidth();
125
125
  float borderRightWidth = borderDrawable.getBorderRightWidth();
126
- if (android.os.Build.VERSION.SDK_INT >= 21 && ((borderDrawable.hasUniformBorderRadius()
127
- && (borderLeftWidth == 0 && borderBottomWidth == 0 && borderTopWidth == 0 && borderRightWidth == 0))
128
- || (borderTopLeftRadius == 0 && borderTopRightRadius == 0 && borderBottomRightRadius == 0
129
- && borderBottomLeftRadius == 0))) {
130
- // we can use outline
131
- return null;
132
- }
133
126
  if (innerBorderPath == null) {
134
127
  innerBorderPath = new Path();
135
128
  } else {
@@ -162,7 +155,7 @@ public class DraweeView extends SimpleDraweeView {
162
155
  @Override
163
156
  protected void onDraw(Canvas canvas) {
164
157
  Drawable drawable = getBackground();
165
- if (clipEnabled && drawable instanceof BorderDrawable) {
158
+ if (!isUsingOutlineProvider && drawable instanceof BorderDrawable) {
166
159
  BorderDrawable borderDrawable = (BorderDrawable) drawable;
167
160
  Path clipPath = generateInnerBorderPath(borderDrawable);
168
161
  if (clipPath != null) {
@@ -183,12 +176,11 @@ public class DraweeView extends SimpleDraweeView {
183
176
  canvas.restoreToCount(saveCount);
184
177
  return;
185
178
  }
186
- }
179
+ }
187
180
  super.onDraw(canvas);
188
181
  }
189
182
 
190
183
  public void setUri(android.net.Uri uri, String jsonOptions, com.facebook.drawee.controller.ControllerListener listener) {
191
- long start = System.nanoTime();
192
184
  ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setRotationOptions( com.facebook.imagepipeline.common.RotationOptions.autoRotate());
193
185
  JSONObject object = null;
194
186
  if (jsonOptions.length() > 2) {
@@ -249,7 +241,18 @@ public class DraweeView extends SimpleDraweeView {
249
241
  builder.setTapToRetryEnabled(true);
250
242
  }
251
243
  }
252
-
253
244
  setController(builder.build());
254
245
  }
246
+
247
+ @Override
248
+ public void setBackground(Drawable background) {
249
+ super.setBackground(background);
250
+ updateOutlineProvider();
251
+ }
252
+
253
+ @Override
254
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
255
+ super.onSizeChanged(w, h, oldw, oldh);
256
+ updateOutlineProvider();
257
+ }
255
258
  }
Binary file