@nativescript-community/ui-image 4.3.12 → 4.3.14

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,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.14](https://github.com/nativescript-community/ui-image/compare/v4.3.13...v4.3.14) (2023-09-27)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-image
9
+
10
+ ## [4.3.13](https://github.com/nativescript-community/ui-image/compare/v4.3.12...v4.3.13) (2023-09-27)
11
+
12
+ ### Bug Fixes
13
+
14
+ * **android:** border radius correctly working now ([69c2732](https://github.com/nativescript-community/ui-image/commit/69c27327ebc627901a6aa4e7617b8975b3d14bc4))
15
+
6
16
  ## [4.3.12](https://github.com/nativescript-community/ui-image/compare/v4.3.11...v4.3.12) (2023-09-26)
7
17
 
8
18
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.3.12",
3
+ "version": "4.3.14",
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": "9ea31cb0967917f14880e3928043f74497f59b88"
47
+ "gitHead": "cc57cff80b69dd3bcce84f27ee5e66c46b858874"
48
48
  }
@@ -36,74 +36,56 @@ import java.util.Arrays;
36
36
  public class DraweeView extends SimpleDraweeView {
37
37
  public int imageWidth = 0;
38
38
  public int imageHeight = 0;
39
+ public boolean isUsingOutlineProvider = false;
39
40
  private static Paint clipPaint;
40
41
 
41
- private boolean clipEnabled = true;
42
-
43
42
  public DraweeView(Context context, GenericDraweeHierarchy hierarchy) {
44
- super(context);
45
- setClipToBounds(clipEnabled);
46
- }
43
+ super(context);
44
+ }
47
45
 
48
- public DraweeView(Context context) {
49
- super(context);
50
- setClipToBounds(clipEnabled);
51
- }
46
+ public DraweeView(Context context) {
47
+ super(context);
48
+ }
52
49
 
53
- public DraweeView(Context context, AttributeSet attrs) {
54
- super(context, attrs);
55
- setClipToBounds(clipEnabled);
56
- }
50
+ public DraweeView(Context context, AttributeSet attrs) {
51
+ super(context, attrs);
52
+ }
57
53
 
58
- public DraweeView(Context context, AttributeSet attrs, int defStyle) {
59
- super(context, attrs, defStyle);
60
- setClipToBounds(clipEnabled);
61
- }
54
+ public DraweeView(Context context, AttributeSet attrs, int defStyle) {
55
+ super(context, attrs, defStyle);
56
+ }
62
57
 
63
- public void setClipToBounds(boolean value) {
64
- clipEnabled = value;
65
- if (value) {
66
- if (android.os.Build.VERSION.SDK_INT >= 21) {
67
- setOutlineProvider(new ViewOutlineProvider() {
68
- @Override
69
- public void getOutline(View view, Outline outline) {
70
- Drawable drawable = getBackground();
71
- if (drawable instanceof BorderDrawable) {
72
- BorderDrawable borderDrawable = (BorderDrawable) drawable;
73
- float borderTopLeftRadius = borderDrawable.getBorderTopLeftRadius();
74
- float borderTopRightRadius = borderDrawable.getBorderTopRightRadius();
75
- float borderBottomRightRadius = borderDrawable.getBorderBottomRightRadius();
76
- float borderBottomLeftRadius = borderDrawable.getBorderBottomLeftRadius();
77
- float borderLeftWidth = borderDrawable.getBorderLeftWidth();
78
- float borderBottomWidth = borderDrawable.getBorderBottomWidth();
79
- float borderTopWidth = borderDrawable.getBorderTopWidth();
80
- float borderRightWidth = borderDrawable.getBorderRightWidth();
81
- if (android.os.Build.VERSION.SDK_INT >= 21 &&
82
- borderDrawable.getUniformBorderRadius() > 0 &&
83
- borderLeftWidth == 0 &&
84
- borderBottomWidth == 0 &&
85
- borderTopWidth == 0 &&
86
- borderRightWidth == 0) {
87
- drawable.getOutline(outline);
88
- return;
89
- }
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);
90
75
  }
91
- outline.setRect(0, 0, view.getWidth(), view.getHeight());
76
+ } else {
77
+ outline.setRect(100, 100, view.getWidth() - 200, view.getHeight() - 200);
92
78
  }
93
- });
94
- setClipToOutline(true);
95
- }
79
+ }
80
+ });
81
+ setClipToOutline(true);
82
+ isUsingOutlineProvider = true;
96
83
  } else if (android.os.Build.VERSION.SDK_INT >= 21) {
97
84
  setOutlineProvider(null);
98
85
  setClipToOutline(false);
99
86
  }
100
87
  }
101
88
 
102
- public boolean getClipToBounds() {
103
- return clipEnabled;
104
- }
105
-
106
-
107
89
  @Override
108
90
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
109
91
  int widthMode = MeasureSpec.getMode(widthMeasureSpec);
@@ -141,13 +123,6 @@ public class DraweeView extends SimpleDraweeView {
141
123
  float borderBottomWidth = borderDrawable.getBorderBottomWidth();
142
124
  float borderTopWidth = borderDrawable.getBorderTopWidth();
143
125
  float borderRightWidth = borderDrawable.getBorderRightWidth();
144
- if (android.os.Build.VERSION.SDK_INT >= 21 && ((borderDrawable.hasUniformBorderRadius()
145
- && (borderLeftWidth == 0 && borderBottomWidth == 0 && borderTopWidth == 0 && borderRightWidth == 0))
146
- || (borderTopLeftRadius == 0 && borderTopRightRadius == 0 && borderBottomRightRadius == 0
147
- && borderBottomLeftRadius == 0))) {
148
- // we can use outline
149
- return null;
150
- }
151
126
  if (innerBorderPath == null) {
152
127
  innerBorderPath = new Path();
153
128
  } else {
@@ -180,7 +155,7 @@ public class DraweeView extends SimpleDraweeView {
180
155
  @Override
181
156
  protected void onDraw(Canvas canvas) {
182
157
  Drawable drawable = getBackground();
183
- if (clipEnabled && drawable instanceof BorderDrawable) {
158
+ if (!isUsingOutlineProvider && drawable instanceof BorderDrawable) {
184
159
  BorderDrawable borderDrawable = (BorderDrawable) drawable;
185
160
  Path clipPath = generateInnerBorderPath(borderDrawable);
186
161
  if (clipPath != null) {
@@ -201,12 +176,11 @@ public class DraweeView extends SimpleDraweeView {
201
176
  canvas.restoreToCount(saveCount);
202
177
  return;
203
178
  }
204
- }
179
+ }
205
180
  super.onDraw(canvas);
206
181
  }
207
182
 
208
183
  public void setUri(android.net.Uri uri, String jsonOptions, com.facebook.drawee.controller.ControllerListener listener) {
209
- Log.d("JS", "setUri " + uri.toString());
210
184
  ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setRotationOptions( com.facebook.imagepipeline.common.RotationOptions.autoRotate());
211
185
  JSONObject object = null;
212
186
  if (jsonOptions.length() > 2) {
@@ -267,7 +241,18 @@ public class DraweeView extends SimpleDraweeView {
267
241
  builder.setTapToRetryEnabled(true);
268
242
  }
269
243
  }
270
- Log.d("JS", "setUri " + uri.toString() + " " + object);
271
244
  setController(builder.build());
272
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
+ }
273
258
  }
Binary file