Skip to content

Commit

Permalink
Release 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Feb 22, 2022
1 parent 06ffdd7 commit 7265e24
Show file tree
Hide file tree
Showing 52 changed files with 1,769 additions and 1,563 deletions.
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
## Next Release

## Newest Release

### 2.2.0 - 14 Feb 2022

- 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.
- 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)
- Improves the file structure of the Catalog sample project for better readability. (#32685)
- Improves the file structure of the NativeCatalog sample project for better readability. (#32887)
- Updates for PSPDFKit 8.1.1 for Android. (#33017)
- Updates for PSPDFKit 11.2.2 for iOS. (#33017)
- Fixes an issue where the `spreadFitting` configuration value is inverted on Android. (#32789)
- Removes `signingConfig` from React Native Android's sample projects app-level `build.gradle` files. (#32767)

## Previous Releases

### 2.1.0 - 06 Jan 2022

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

## Previous Releases

### 2.0.4 - 07 Dec 2021

- Updates the Xcode build settings of the Catalog and Native Catalog example projects to work on iOS simulators on Apple Silicon Macs. (#32129)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Windows is not currently supported, please use the previous version [1.24.9](htt
- [How to Extend React Native APIs for Windows](https://pspdfkit.com/blog/2019/how-to-extend-react-native-apis-for-windows/)
- [How to Bridge Native iOS Code to React Native](https://pspdfkit.com/blog/2020/how-to-bridge-native-ios-code-to-react-native/)
- [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/)
- [How to Build a React Native PDF Viewer](https://pspdfkit.com/blog/2021/how-to-build-a-react-native-pdf-viewer/)

### PSPDFKit

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Contains gradle configuration constants
*/
ext {
PSPDFKIT_VERSION = '8.0.2'
PSPDFKIT_VERSION = '8.1.1'
}

buildscript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ private void configureSpreadFitting(@Nullable final String mode) {
return;
}
if (mode.equals(SPREAD_FITTING_FIT)) {
configuration.fitMode(PageFitMode.FIT_TO_WIDTH);
configuration.fitMode(PageFitMode.FIT_TO_SCREEN);
}
else if (mode.equals(SPREAD_FITTING_FILL)) {
configuration.fitMode(PageFitMode.FIT_TO_SCREEN);
configuration.fitMode(PageFitMode.FIT_TO_WIDTH);
}
}

Expand Down
7 changes: 5 additions & 2 deletions android/src/main/java/com/pspdfkit/react/PSPDFKitModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@
import com.pspdfkit.ui.PdfFragment;

import java.io.File;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

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

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

Expand Down Expand Up @@ -183,14 +186,14 @@ public void run() {

@ReactMethod
public void setLicenseKey(@Nullable String licenseKey) {
PSPDFKit.initialize(getReactApplicationContext().getApplicationContext(), licenseKey);
PSPDFKit.initialize(getReactApplicationContext().getApplicationContext(), licenseKey, new ArrayList<>(), HYBRID_TECHNOLOGY);
}

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

@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class ReactPdfViewManager extends ViewGroupManager<PdfView> {
public static final int COMMAND_SET_FORM_FIELD_VALUE = 9;
public static final int COMMAND_REMOVE_ANNOTATION = 10;
public static final int COMMAND_GET_ALL_ANNOTATIONS = 11;
public static final int COMMAND_REMOVE_FRAGMENT = 12;

private CompositeDisposable annotationDisposables = new CompositeDisposable();

Expand Down Expand Up @@ -110,6 +111,7 @@ public Map<String, Integer> getCommandsMap() {
commandMap.put("setFormFieldValue", COMMAND_SET_FORM_FIELD_VALUE);
commandMap.put("removeAnnotation", COMMAND_REMOVE_ANNOTATION);
commandMap.put("getAllAnnotations", COMMAND_GET_ALL_ANNOTATIONS);
commandMap.put("removeFragment", COMMAND_REMOVE_FRAGMENT);
return commandMap;
}

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

Expand Down
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class PSPDFKitView extends React.Component {
this._requestMap.delete(requestId);
};


/**
* Enters the annotation creation mode, showing the annotation creation toolbar.
*/
Expand Down Expand Up @@ -505,6 +506,26 @@ class PSPDFKitView extends React.Component {
}
};

/**
* Removes the currently displayed Android Native PdfUiFragment.
*
* This function should only be used as a workaround for a bug in `react-native-screen` that causes a crash when
* `navigation.goBack()` is called or a hardware back button is used to navigate back on Android. Calling this
* function will prevent the crash by removing the fragment from the `PdfView` before the navigation takes place.
*
* <b>Note:</> this function is available for Android only, it will have no effect on iOS.
*/
destroyView = function () {
if (Platform.OS === "android") {
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.removeFragment,
[]
);
}
};

_getViewManagerConfig = (viewManagerName) => {
const version = NativeModules.PlatformConstants.reactNativeVersion.minor;
if (version >= 58) {
Expand Down
6 changes: 4 additions & 2 deletions ios/RCTPSPDFKit/RCTPSPDFKitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@

@implementation RCTPSPDFKitManager

PSPDFSettingKey const PSPDFSettingKeyHybridEnvironment = @"com.pspdfkit.hybrid-environment";

RCT_EXPORT_MODULE(PSPDFKit)

RCT_REMAP_METHOD(setLicenseKey, setLicenseKey:(nullable NSString *)licenseKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[PSPDFKitGlobal setLicenseKey:licenseKey];
[PSPDFKitGlobal setLicenseKey:licenseKey options:@{PSPDFSettingKeyHybridEnvironment: @"ReactNative"}];
resolve(@(YES));
}

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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pspdfkit",
"version": "2.1.0",
"version": "2.2.0",
"description": "React Native PDF Library by PSPDFKit",
"keywords": [
"react native",
Expand Down
2 changes: 0 additions & 2 deletions samples/Catalog/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ yarn-error.log
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
Expand Down
Loading

0 comments on commit 7265e24

Please sign in to comment.