Skip to content

Commit 7265e24

Browse files
author
PSPDFKit
committed
Release 2.2.0
1 parent 06ffdd7 commit 7265e24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1769
-1563
lines changed

CHANGELOG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
## Next Release
2-
31
## Newest Release
42

3+
### 2.2.0 - 14 Feb 2022
4+
5+
- This release requires you to update your Android project's `compileSdkVersion` to version 31. Please refer to [our migration guide](https://pspdfkit.com/guides/react-native/migration-guides/react-native-2-2-migration-guide) for this release.
6+
- Adds a `destroyView()` function to `PSPDFKitView` to be used as a workaround for crash caused by a [`react-native-screens` issue](https://github.com/software-mansion/react-native-screens/issues/1300) when navigating back. (#32960)
7+
- Improves the file structure of the Catalog sample project for better readability. (#32685)
8+
- Improves the file structure of the NativeCatalog sample project for better readability. (#32887)
9+
- Updates for PSPDFKit 8.1.1 for Android. (#33017)
10+
- Updates for PSPDFKit 11.2.2 for iOS. (#33017)
11+
- Fixes an issue where the `spreadFitting` configuration value is inverted on Android. (#32789)
12+
- Removes `signingConfig` from React Native Android's sample projects app-level `build.gradle` files. (#32767)
13+
14+
## Previous Releases
15+
516
### 2.1.0 - 06 Jan 2022
617

718
- Adds documentation for all the configuration options. (#31898)
@@ -11,8 +22,6 @@
1122
- Updates for PSPDFKit 11.2 for iOS. (#32495)
1223
- Fixes an issue where some examples using `Form_example.pdf` would not work. (#32495)
1324

14-
## Previous Releases
15-
1625
### 2.0.4 - 07 Dec 2021
1726

1827
- Updates the Xcode build settings of the Catalog and Native Catalog example projects to work on iOS simulators on Apple Silicon Macs. (#32129)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Windows is not currently supported, please use the previous version [1.24.9](htt
2121
- [How to Extend React Native APIs for Windows](https://pspdfkit.com/blog/2019/how-to-extend-react-native-apis-for-windows/)
2222
- [How to Bridge Native iOS Code to React Native](https://pspdfkit.com/blog/2020/how-to-bridge-native-ios-code-to-react-native/)
2323
- [How to Open a PDF in React Native Using the Document Picker](https://pspdfkit.com/blog/2021/how-to-open-a-pdf-in-react-native-using-the-document-browser/)
24+
- [How to Build a React Native PDF Viewer](https://pspdfkit.com/blog/2021/how-to-build-a-react-native-pdf-viewer/)
2425

2526
### PSPDFKit
2627

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Contains gradle configuration constants
1616
*/
1717
ext {
18-
PSPDFKIT_VERSION = '8.0.2'
18+
PSPDFKIT_VERSION = '8.1.1'
1919
}
2020

2121
buildscript {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ private void configureSpreadFitting(@Nullable final String mode) {
350350
return;
351351
}
352352
if (mode.equals(SPREAD_FITTING_FIT)) {
353-
configuration.fitMode(PageFitMode.FIT_TO_WIDTH);
353+
configuration.fitMode(PageFitMode.FIT_TO_SCREEN);
354354
}
355355
else if (mode.equals(SPREAD_FITTING_FILL)) {
356-
configuration.fitMode(PageFitMode.FIT_TO_SCREEN);
356+
configuration.fitMode(PageFitMode.FIT_TO_WIDTH);
357357
}
358358
}
359359

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@
4848
import com.pspdfkit.ui.PdfFragment;
4949

5050
import java.io.File;
51+
import java.util.ArrayList;
5152
import java.util.EnumSet;
5253
import java.util.HashMap;
5354
import java.util.Map;
5455

5556
public class PSPDFKitModule extends ReactContextBaseJavaModule implements Application.ActivityLifecycleCallbacks, ActivityEventListener {
5657

58+
/** Hybrid technology where the application is supposed to be working on. */
59+
private static final String HYBRID_TECHNOLOGY = "ReactNative";
5760
private static final String VERSION_KEY = "versionString";
5861
private static final String FILE_SCHEME = "file:///";
5962

@@ -183,14 +186,14 @@ public void run() {
183186

184187
@ReactMethod
185188
public void setLicenseKey(@Nullable String licenseKey) {
186-
PSPDFKit.initialize(getReactApplicationContext().getApplicationContext(), licenseKey);
189+
PSPDFKit.initialize(getReactApplicationContext().getApplicationContext(), licenseKey, new ArrayList<>(), HYBRID_TECHNOLOGY);
187190
}
188191

189192
@ReactMethod
190193
public void setLicenseKeys(@Nullable String androidLicenseKey, @Nullable String iOSLicenseKey) {
191194
// Here, we ignore the `iOSLicenseKey` parameter and only care about `androidLicenseKey`.
192195
// `iOSLicenseKey` will be used to activate the license on iOS.
193-
PSPDFKit.initialize(getReactApplicationContext().getApplicationContext(), androidLicenseKey);
196+
PSPDFKit.initialize(getReactApplicationContext().getApplicationContext(), androidLicenseKey, new ArrayList<>(), HYBRID_TECHNOLOGY);
194197
}
195198

196199
@ReactMethod

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class ReactPdfViewManager extends ViewGroupManager<PdfView> {
6060
public static final int COMMAND_SET_FORM_FIELD_VALUE = 9;
6161
public static final int COMMAND_REMOVE_ANNOTATION = 10;
6262
public static final int COMMAND_GET_ALL_ANNOTATIONS = 11;
63+
public static final int COMMAND_REMOVE_FRAGMENT = 12;
6364

6465
private CompositeDisposable annotationDisposables = new CompositeDisposable();
6566

@@ -110,6 +111,7 @@ public Map<String, Integer> getCommandsMap() {
110111
commandMap.put("setFormFieldValue", COMMAND_SET_FORM_FIELD_VALUE);
111112
commandMap.put("removeAnnotation", COMMAND_REMOVE_ANNOTATION);
112113
commandMap.put("getAllAnnotations", COMMAND_GET_ALL_ANNOTATIONS);
114+
commandMap.put("removeFragment", COMMAND_REMOVE_FRAGMENT);
113115
return commandMap;
114116
}
115117

@@ -285,6 +287,11 @@ public void accept(JSONObject jsonObject) {
285287
annotationDisposables.add(annotationDisposable);
286288
}
287289
break;
290+
case COMMAND_REMOVE_FRAGMENT:
291+
// Removing a fragment like this is not recommended, but it can be used as a workaround
292+
// to stop `react-native-screens` from crashing the App when the back button is pressed.
293+
root.removeFragment(true);
294+
break;
288295
}
289296
}
290297

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class PSPDFKitView extends React.Component {
101101
this._requestMap.delete(requestId);
102102
};
103103

104+
104105
/**
105106
* Enters the annotation creation mode, showing the annotation creation toolbar.
106107
*/
@@ -505,6 +506,26 @@ class PSPDFKitView extends React.Component {
505506
}
506507
};
507508

509+
/**
510+
* Removes the currently displayed Android Native PdfUiFragment.
511+
*
512+
* This function should only be used as a workaround for a bug in `react-native-screen` that causes a crash when
513+
* `navigation.goBack()` is called or a hardware back button is used to navigate back on Android. Calling this
514+
* function will prevent the crash by removing the fragment from the `PdfView` before the navigation takes place.
515+
*
516+
* <b>Note:</> this function is available for Android only, it will have no effect on iOS.
517+
*/
518+
destroyView = function () {
519+
if (Platform.OS === "android") {
520+
UIManager.dispatchViewManagerCommand(
521+
findNodeHandle(this.refs.pdfView),
522+
this._getViewManagerConfig("RCTPSPDFKitView").Commands
523+
.removeFragment,
524+
[]
525+
);
526+
}
527+
};
528+
508529
_getViewManagerConfig = (viewManagerName) => {
509530
const version = NativeModules.PlatformConstants.reactNativeVersion.minor;
510531
if (version >= 58) {

ios/RCTPSPDFKit/RCTPSPDFKitManager.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@
2222

2323
@implementation RCTPSPDFKitManager
2424

25+
PSPDFSettingKey const PSPDFSettingKeyHybridEnvironment = @"com.pspdfkit.hybrid-environment";
26+
2527
RCT_EXPORT_MODULE(PSPDFKit)
2628

2729
RCT_REMAP_METHOD(setLicenseKey, setLicenseKey:(nullable NSString *)licenseKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
28-
[PSPDFKitGlobal setLicenseKey:licenseKey];
30+
[PSPDFKitGlobal setLicenseKey:licenseKey options:@{PSPDFSettingKeyHybridEnvironment: @"ReactNative"}];
2931
resolve(@(YES));
3032
}
3133

3234
RCT_REMAP_METHOD(setLicenseKeys, setLicenseKeys:(nullable NSString *)androidLicenseKey iOSLicenseKey:(nullable NSString *)iOSLicenseKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
3335
// Here, we ignore the `androidLicenseKey` parameter and only care about `iOSLicenseKey`.
3436
// `androidLicenseKey` will be used to activate the license on Android.
35-
[PSPDFKitGlobal setLicenseKey:iOSLicenseKey];
37+
[PSPDFKitGlobal setLicenseKey:iOSLicenseKey options:@{PSPDFSettingKeyHybridEnvironment: @"ReactNative"}];
3638
resolve(@(YES));
3739
}
3840

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-pspdfkit",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "React Native PDF Library by PSPDFKit",
55
"keywords": [
66
"react native",

samples/Catalog/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ yarn-error.log
3939
buck-out/
4040
\.buckd/
4141
*.keystore
42-
!debug.keystore
43-
4442
# fastlane
4543
#
4644
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the

0 commit comments

Comments
 (0)