Skip to content

Commit 4609349

Browse files
committed
fix: compatibility with older react native versions
1 parent c7e42e6 commit 4609349

2 files changed

Lines changed: 4 additions & 46 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## Fixed
11+
12+
- Compatibility with older react native versions
13+
1014
## [0.20.0] - 2026-01-13
1115

1216
## Added

android/src/main/java/com/reactnativeandroidwidget/oss/CSSBackgroundDrawable.java

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,16 @@
2929
import android.graphics.Canvas;
3030
import android.graphics.Color;
3131
import android.graphics.ColorFilter;
32-
import android.graphics.ComposeShader;
3332
import android.graphics.DashPathEffect;
3433
import android.graphics.Outline;
3534
import android.graphics.Paint;
3635
import android.graphics.Path;
3736
import android.graphics.PathEffect;
3837
import android.graphics.PixelFormat;
3938
import android.graphics.PointF;
40-
import android.graphics.PorterDuff;
4139
import android.graphics.Rect;
4240
import android.graphics.RectF;
4341
import android.graphics.Region;
44-
import android.graphics.Shader;
4542
import android.graphics.drawable.Drawable;
4643
import android.view.View;
4744
import androidx.annotation.Nullable;
@@ -55,13 +52,11 @@
5552
import com.facebook.react.uimanager.LengthPercentageType;
5653
import com.facebook.react.uimanager.PixelUtil;
5754
import com.facebook.react.uimanager.Spacing;
58-
import com.facebook.react.uimanager.style.BackgroundImageLayer;
5955
import com.facebook.react.uimanager.style.BorderRadiusProp;
6056
import com.facebook.react.uimanager.style.BorderRadiusStyle;
6157
import com.facebook.react.uimanager.style.BorderStyle;
6258
import com.facebook.react.uimanager.style.ComputedBorderRadius;
6359
import com.facebook.react.uimanager.style.CornerRadii;
64-
import java.util.List;
6560
import java.util.Locale;
6661
import java.util.Objects;
6762

@@ -134,7 +129,6 @@ public class CSSBackgroundDrawable extends Drawable {
134129
/* Used by all types of background and for drawing borders */
135130
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
136131
private int mColor = Color.TRANSPARENT;
137-
private @Nullable List<BackgroundImageLayer> mBackgroundImageLayers = null;
138132
private int mAlpha = 255;
139133

140134
// There is a small gap between the edges of adjacent paths
@@ -358,11 +352,6 @@ public void setColor(int color) {
358352
invalidateSelf();
359353
}
360354

361-
public void setBackgroundImage(@Nullable List<BackgroundImageLayer> backgroundImageLayers) {
362-
mBackgroundImageLayers = backgroundImageLayers;
363-
invalidateSelf();
364-
}
365-
366355
public int getColor() {
367356
return mColor;
368357
}
@@ -414,13 +403,6 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
414403
canvas.drawPath(Preconditions.checkNotNull(mBackgroundColorRenderPath), mPaint);
415404
}
416405

417-
if (mBackgroundImageLayers != null && !mBackgroundImageLayers.isEmpty()) {
418-
mPaint.setShader(getBackgroundImageShader());
419-
mPaint.setStyle(Paint.Style.FILL);
420-
canvas.drawPath(Preconditions.checkNotNull(mBackgroundColorRenderPath), mPaint);
421-
mPaint.setShader(null);
422-
}
423-
424406
final RectF borderWidth = getDirectionAwareBorderInsets();
425407
int colorLeft = getBorderColor(Spacing.LEFT);
426408
int colorTop = getBorderColor(Spacing.TOP);
@@ -1152,12 +1134,6 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) {
11521134
canvas.drawRect(getBounds(), mPaint);
11531135
}
11541136

1155-
if (mBackgroundImageLayers != null && !mBackgroundImageLayers.isEmpty()) {
1156-
mPaint.setShader(getBackgroundImageShader());
1157-
canvas.drawRect(getBounds(), mPaint);
1158-
mPaint.setShader(null);
1159-
}
1160-
11611137
final RectF borderWidth = getDirectionAwareBorderInsets();
11621138

11631139
final int borderLeft = Math.round(borderWidth.left);
@@ -1449,28 +1425,6 @@ public RectF getDirectionAwareBorderInsets() {
14491425
return new RectF(borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth);
14501426
}
14511427

1452-
private @Nullable Shader getBackgroundImageShader() {
1453-
if (mBackgroundImageLayers == null) {
1454-
return null;
1455-
}
1456-
1457-
Shader compositeShader = null;
1458-
for (BackgroundImageLayer backgroundImageLayer : mBackgroundImageLayers) {
1459-
Rect bounds = getBounds();
1460-
Shader currentShader = backgroundImageLayer.getShader(bounds.width(), bounds.height());
1461-
if (currentShader == null) {
1462-
continue;
1463-
}
1464-
if (compositeShader == null) {
1465-
compositeShader = currentShader;
1466-
} else {
1467-
compositeShader =
1468-
new ComposeShader(currentShader, compositeShader, PorterDuff.Mode.SRC_OVER);
1469-
}
1470-
}
1471-
return compositeShader;
1472-
}
1473-
14741428
/**
14751429
* Multiplies the color with the given alpha.
14761430
*

0 commit comments

Comments
 (0)