From 01db444f511a5e2dde45d8597dbc691aa25586d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Thu, 28 Nov 2024 17:05:43 +0100 Subject: [PATCH] feat: make `RenderableView.hitTest` public to create a cross-library interface (#2555) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Summary Adding an `RNGH <-> RNSVG` interface requires usage of `RenderableView.hitTest` to work. ([link](https://github.com/software-mansion/react-native-gesture-handler/pull/3242)) Currently, `RenderableView.hitTest` is `package-private`, meaning it cannot be accessed by other packages. This change does not change any functionality of the library, it only exposes existing functions to other libraries. I only made public those `hitTest` implementation which are strictly necessary for this interface, this is why multiple, if not most `hitTest` implementations remain `package-private` despite the changes made in the PR. ## Test Plan - open the example app, see how the app builds successfully ### What's required for testing (prerequisites)? - `RNSVG`'s `paper-example` app ### What are the steps to reproduce (after prerequisites)? ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ❌ | | MacOS | ❌ | | Android | ✅ | | Web | ❌ | ## Checklist - [X] I have tested this on a device and a simulator - [ ] I added documentation in `README.md` - [ ] ~~I updated the typed files (typescript)~~ - [ ] I added a test for the API in the `__tests__` folder --- android/src/main/java/com/horcrux/svg/ClipPathView.java | 2 +- android/src/main/java/com/horcrux/svg/GroupView.java | 2 +- android/src/main/java/com/horcrux/svg/RenderableView.java | 2 +- android/src/main/java/com/horcrux/svg/TSpanView.java | 2 +- android/src/main/java/com/horcrux/svg/UseView.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/horcrux/svg/ClipPathView.java b/android/src/main/java/com/horcrux/svg/ClipPathView.java index a81891674..b1618b76c 100644 --- a/android/src/main/java/com/horcrux/svg/ClipPathView.java +++ b/android/src/main/java/com/horcrux/svg/ClipPathView.java @@ -40,7 +40,7 @@ boolean isResponsible() { } @Override - int hitTest(float[] src) { + public int hitTest(float[] src) { return -1; } diff --git a/android/src/main/java/com/horcrux/svg/GroupView.java b/android/src/main/java/com/horcrux/svg/GroupView.java index d5df75bc9..6a6b22d4b 100644 --- a/android/src/main/java/com/horcrux/svg/GroupView.java +++ b/android/src/main/java/com/horcrux/svg/GroupView.java @@ -254,7 +254,7 @@ Path getPath(final Canvas canvas, final Paint paint, final Region.Op op) { } @Override - int hitTest(final float[] src) { + public int hitTest(final float[] src) { if (!mInvertible) { return -1; } diff --git a/android/src/main/java/com/horcrux/svg/RenderableView.java b/android/src/main/java/com/horcrux/svg/RenderableView.java index 0e7dad7b4..7a256c0c0 100644 --- a/android/src/main/java/com/horcrux/svg/RenderableView.java +++ b/android/src/main/java/com/horcrux/svg/RenderableView.java @@ -676,7 +676,7 @@ private void setupPaint(Paint paint, float opacity, ReadableArray colors) { abstract Path getPath(Canvas canvas, Paint paint); @Override - int hitTest(final float[] src) { + public int hitTest(final float[] src) { if (mPath == null || !mInvertible) { return -1; } diff --git a/android/src/main/java/com/horcrux/svg/TSpanView.java b/android/src/main/java/com/horcrux/svg/TSpanView.java index 708f17fcf..fbee3e12e 100644 --- a/android/src/main/java/com/horcrux/svg/TSpanView.java +++ b/android/src/main/java/com/horcrux/svg/TSpanView.java @@ -1208,7 +1208,7 @@ private void setupTextPath() { } @Override - int hitTest(final float[] src) { + public int hitTest(final float[] src) { if (mContent == null) { return super.hitTest(src); } diff --git a/android/src/main/java/com/horcrux/svg/UseView.java b/android/src/main/java/com/horcrux/svg/UseView.java index 7e49f8c46..5e8a2973d 100644 --- a/android/src/main/java/com/horcrux/svg/UseView.java +++ b/android/src/main/java/com/horcrux/svg/UseView.java @@ -100,7 +100,7 @@ void draw(Canvas canvas, Paint paint, float opacity) { } @Override - int hitTest(float[] src) { + public int hitTest(float[] src) { if (!mInvertible) { return -1; }