Skip to content

Commit 6378b8d

Browse files
author
PSPDFKit
committed
Release 2.16.1
1 parent 4cbfc5c commit 6378b8d

35 files changed

+57
-51
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.16.1 - 27 Mar 2025
2+
3+
- Adds support for React Native 0.78. (J#HYB-737)
4+
- Fixes an issue where a crash could occur during `onAnnotationChanged` event callbacks on Android. (J#HYB-738)
5+
16
## 2.16.0 - 26 Feb 2025
27

38
- Adds the ability to merge entire PDF documents using the `generatePDFFromDocuments` Processor API. (J#HYB-579)

android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 0 additions & 13 deletions
This file was deleted.

android/src/main/java/com/pspdfkit/react/ReactPdfViewManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.facebook.react.common.MapBuilder;
2727
import com.facebook.react.uimanager.ThemedReactContext;
2828
import com.facebook.react.uimanager.UIManagerModule;
29+
import com.facebook.react.uimanager.UIManagerHelper;
2930
import com.facebook.react.uimanager.ViewGroupManager;
3031
import com.facebook.react.uimanager.annotations.ReactProp;
3132
import com.pspdfkit.annotations.AnnotationType;
@@ -100,7 +101,7 @@ protected PdfView createViewInstance(ThemedReactContext reactContext) {
100101
FragmentActivity fragmentActivity = (FragmentActivity) reactContext.getCurrentActivity();
101102
PdfView pdfView = new PdfView(reactContext);
102103
pdfView.inject(fragmentActivity.getSupportFragmentManager(),
103-
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher());
104+
UIManagerHelper.getEventDispatcher(reactContext, pdfView.getId()));
104105
return pdfView;
105106
} else {
106107
throw new IllegalStateException("ReactPSPDFKitView can only be used in FragmentActivity subclasses.");

android/src/main/java/com/pspdfkit/react/events/PdfViewAnnotationChangedEvent.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ public void dispatch(RCTEventEmitter rctEventEmitter) {
9191

9292
WritableMap eventData = Arguments.makeNativeMap(map);
9393
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData);
94-
} catch (JSONException e) {
94+
} catch (Exception e) {
95+
Map<String, Object> map = new HashMap<>();
96+
map.put("change", eventType);
97+
List<Map<String, Object>> annotations = new ArrayList<>();
98+
map.put("annotations", annotations);
99+
WritableMap eventData = Arguments.makeNativeMap(map);
100+
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData);
101+
95102
e.printStackTrace();
96103
}
97104
}

android/src/main/java/com/pspdfkit/react/events/PdfViewAnnotationTappedEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void dispatch(RCTEventEmitter rctEventEmitter) {
6767
WritableMap eventData = Arguments.makeNativeMap(map);
6868
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData);
6969
}
70-
} catch (JSONException e) {
70+
} catch (Exception e) {
7171
e.printStackTrace();
7272
}
7373
}

android/src/main/java/com/pspdfkit/views/MenuItemListener.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class MenuItemListener: MenuItem.OnMenuItemClickListener {
2222
override fun onMenuItemClick(menuItem: MenuItem): Boolean {
2323
val resourceName: String? = context?.resources?.getResourceEntryName(menuItem.itemId)
2424
if (resourceName != null) {
25-
eventDispatcher!!.dispatchEvent(parent?.let { CustomToolbarButtonTappedEvent(it.id, resourceName) })
25+
parent?.let { CustomToolbarButtonTappedEvent(it.id, resourceName) }
26+
?.let { eventDispatcher!!.dispatchEvent(it) }
2627
}
2728
return false
2829
}

android/src/main/java/com/pspdfkit/views/ToolbarMenuItemListener.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class ToolbarMenuItemListener: ContextualToolbar.OnMenuItemClickListener {
2828
if (this.resourceIds.contains(menuItem.id)) {
2929
val resourceName: String? = context?.resources?.getResourceEntryName(menuItem.id)
3030
if (resourceName != null) {
31-
eventDispatcher!!.dispatchEvent(parent?.let { CustomAnnotationContextualMenuItemTappedEvent(it.id, resourceName) })
31+
parent?.let { CustomAnnotationContextualMenuItemTappedEvent(it.id, resourceName) }
32+
?.let { eventDispatcher!!.dispatchEvent(it) }
3233
}
3334
return true
3435
}

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ import {
3434
* />
3535
*/
3636
class PSPDFKitView extends React.Component {
37+
/**
38+
* @ignore
39+
*/
40+
refs;
3741
/**
3842
* @ignore
3943
*/

ios/RCTPSPDFKit/RCTPSPDFKitManager.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ @implementation RCTPSPDFKitManager
3535
RCT_EXPORT_MODULE(PSPDFKit)
3636

3737
RCT_REMAP_METHOD(setLicenseKey, setLicenseKey:(nullable NSString *)licenseKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
38-
[PSPDFKitGlobal setLicenseKey:licenseKey options:@{PSPDFSettingKeyHybridEnvironment: @"ReactNative"}];
38+
if (![licenseKey isEqual:[NSNull null]]) {
39+
[PSPDFKitGlobal setLicenseKey:licenseKey options:@{PSPDFSettingKeyHybridEnvironment: @"ReactNative"}];
40+
}
3941
resolve(@(YES));
4042
}
4143

4244
RCT_REMAP_METHOD(setLicenseKeys, setLicenseKeys:(nullable NSString *)androidLicenseKey iOSLicenseKey:(nullable NSString *)iOSLicenseKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
4345
// Here, we ignore the `androidLicenseKey` parameter and only care about `iOSLicenseKey`.
4446
// `androidLicenseKey` will be used to activate the license on Android.
45-
[PSPDFKitGlobal setLicenseKey:iOSLicenseKey options:@{PSPDFSettingKeyHybridEnvironment: @"ReactNative"}];
47+
if (![iOSLicenseKey isEqual:[NSNull null]]) {
48+
[PSPDFKitGlobal setLicenseKey:iOSLicenseKey options:@{PSPDFSettingKeyHybridEnvironment: @"ReactNative"}];
49+
}
4650
resolve(@(YES));
4751
}
4852

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-pspdfkit",
3-
"version": "2.16.0",
3+
"version": "2.16.1",
44
"description": "Nutrient React Native SDK",
55
"keywords": [
66
"react native",
@@ -31,7 +31,7 @@
3131
"dev-build": "npm run build-and-generate-types && npm run docs && npm run copy-types-and-lib"
3232
},
3333
"peerDependencies": {
34-
"@types/react": "^18.2.28",
34+
"@types/react": ">=17.0.0",
3535
"prop-types": "^15.8.1",
3636
"react": ">=17.0.0",
3737
"react-native": ">=0.66.0"

0 commit comments

Comments
 (0)