Skip to content

Commit

Permalink
Release 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Jul 19, 2022
1 parent cb2c9ea commit dbd3363
Show file tree
Hide file tree
Showing 59 changed files with 7,640 additions and 6,345 deletions.
402 changes: 339 additions & 63 deletions ACKNOWLEDGEMENTS.md

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
## Newest Release

### 2.3.0 - 19 Jul 2022

- Adds Android Toolbar menu customization from `PSPDFKitView` properties. (#33417)
- Adds handling multiple initializations exception. (#35079)
- Updates the deployment target to iOS 14.0. (#33871)
- Updates for PSPDFKit 11.4.0 for iOS. (#33485)
- PSPDFKit now requires React Native 0.68 or later. (#33875)
- PSPDFKit now requires Xcode 13.4.1 or later. (#32495)

## Previous Releases

### 2.2.2 - 15 Mar 2022

- Adds image support to `PSKDFKit.present()` on Android. (#33312)
- Adds a new **Save As** example to the Catalog example project. (#33376)
- Updates for PSPDFKit 11.3.0 for iOS. (#33485)
- Fixes React Native Annotation Processor API for Android. (#33189, #33302)

## Previous Releases

### 2.2.1 - 04 Mar 2022

- Updates for PSPDFKit 8.1.2 for Android. (#33315)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Let's create a simple app that integrates PSPDFKit and uses the `react-native-ps
yarn install
```

1. Open your project’s Podfile in a text editor to update the platform to iOS 13, and add the PSPDFKit Podspec:
1. Open your project’s Podfile in a text editor to update the platform to iOS 14, and add the PSPDFKit Podspec:

```bash
open ios/Podfile
Expand All @@ -106,7 +106,7 @@ Let's create a simple app that integrates PSPDFKit and uses the `react-native-ps
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

- platform :ios, '10.0'
+ platform :ios, '13.0'
+ platform :ios, '14.0'

target 'PSPDFKitDemo' do
config = use_native_modules!
Expand Down Expand Up @@ -153,7 +153,7 @@ Let's create a simple app that integrates PSPDFKit and uses the `react-native-ps
open PSPDFKitDemo.xcworkspace
```

1. Make sure the deployment target is set to 13.0 or higher:
1. Make sure the deployment target is set to 14.0 or higher:

![deployment-target](./screenshots/deployment-target.png)

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.1.2'
PSPDFKIT_VERSION = 'SNAPSHOT'
}

buildscript {
Expand Down
19 changes: 15 additions & 4 deletions android/src/main/java/com/pspdfkit/react/PSPDFKitModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import com.pspdfkit.exceptions.InvalidPSPDFKitLicenseException;

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

Expand Down Expand Up @@ -210,15 +211,25 @@ public void run() {
}

@ReactMethod
public void setLicenseKey(@Nullable String licenseKey) {
PSPDFKit.initialize(getReactApplicationContext().getApplicationContext(), licenseKey, new ArrayList<>(), HYBRID_TECHNOLOGY);
public void setLicenseKey(@Nullable String licenseKey, @Nullable Promise promise) {
try {
PSPDFKit.initialize(resumedActivity, licenseKey, new ArrayList<>(), HYBRID_TECHNOLOGY);
promise.resolve("Initialised PSPDFKit");
} catch (InvalidPSPDFKitLicenseException e) {
promise.reject(e);
}
}

@ReactMethod
public void setLicenseKeys(@Nullable String androidLicenseKey, @Nullable String iOSLicenseKey) {
public void setLicenseKeys(@Nullable String androidLicenseKey, @Nullable String iOSLicenseKey, @Nullable Promise promise) {
// 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, new ArrayList<>(), HYBRID_TECHNOLOGY);
try {
PSPDFKit.initialize(resumedActivity, androidLicenseKey, new ArrayList<>(), HYBRID_TECHNOLOGY);
promise.resolve("Initialised PSPDFKit");
} catch (InvalidPSPDFKitLicenseException e) {
promise.reject(e);
}
}

@ReactMethod
Expand Down
18 changes: 18 additions & 0 deletions android/src/main/java/com/pspdfkit/react/ReactPdfViewManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.pspdfkit.react.events.PdfViewDataReturnedEvent;
import com.pspdfkit.react.menu.ReactGroupingRule;
import com.pspdfkit.views.PdfView;
import com.pspdfkit.configuration.activity.PdfActivityConfiguration;


import org.json.JSONObject;

Expand Down Expand Up @@ -61,6 +63,7 @@ public class ReactPdfViewManager extends ViewGroupManager<PdfView> {
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;
public static final int COMMAND_SET_TOOLBAR_MENU_ITEMS = 13;

private CompositeDisposable annotationDisposables = new CompositeDisposable();

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

Expand Down Expand Up @@ -170,6 +174,15 @@ public void setSelectedFontName(@NonNull final PdfView view, @Nullable final Str
view.setSelectedFontName(selectedFontName);
}

@ReactProp(name = "toolbarMenuItems")
public void setToolbarMenuItems(@NonNull final PdfView view, @Nullable final ReadableArray toolbarItems) {
if (toolbarItems != null) {
PdfActivityConfiguration.Builder currentConfiguration = new PdfActivityConfiguration.Builder(view.getConfiguration());
ToolbarMenuItemsAdapter newConfigurations = new ToolbarMenuItemsAdapter(currentConfiguration, toolbarItems);
view.setConfiguration(newConfigurations.build());
}
}

@Nullable
@Override
public Map getExportedCustomDirectEventTypeConstants() {
Expand Down Expand Up @@ -285,6 +298,11 @@ public void accept(JSONObject jsonObject) {
// to stop `react-native-screens` from crashing the App when the back button is pressed.
root.removeFragment(true);
break;
case COMMAND_SET_TOOLBAR_MENU_ITEMS:
if (args != null && args.size() == 1) {
setToolbarMenuItems(root,args.getArray(0));
}
break;
}
}

Expand Down
109 changes: 109 additions & 0 deletions android/src/main/java/com/pspdfkit/react/ToolbarMenuItemsAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* ToolbarMenuItemsAdapter.java
*
* PSPDFKit
*
* Copyright © 2022 PSPDFKit GmbH. All rights reserved.
*
* THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
* AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
* UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
* This notice may not be removed from this file.
*/

package com.pspdfkit.react;

import com.facebook.react.bridge.ReadableArray;
import com.pspdfkit.configuration.activity.PdfActivityConfiguration;
import com.pspdfkit.configuration.sharing.ShareFeatures;

import io.reactivex.annotations.NonNull;

/**
* This class is used for mapping the toolbar menu items for customization.
*/
public class ToolbarMenuItemsAdapter {

// Toolbar customization items.
private static final String TOOLBAR_ITEM_SEARCH = "searchButtonItem";
private static final String TOOLBAR_ITEM_READER_VIEW = "readerViewButtonItem";
private static final String TOOLBAR_ITEM_ANNOTATIONS = "annotationButtonItem";
private static final String TOOLBAR_ITEM_THUMBNAILS = "thumbnailsButtonItem";
private static final String TOOLBAR_ITEM_SHARE = "shareButtonItem";
private static final String TOOLBAR_ITEM_SETTINGS = "settingsButtonItem";
private static final String TOOLBAR_ITEM_OUTLINE = "outlineButtonItem";
private static final String TOOLBAR_ITEM_BOOKMARKS = "bookmarkButtonItem";
private static final String TOOLBAR_ITEM_PRINT = "printButtonItem";
private static final String TOOLBAR_ITEM_ANNOTATION_LIST = "annotationListButtonItem";
private static final String TOOLBAR_ITEM_DOCUMENT_INFO_VIEW = "documentInfoViewButtonItem";

private final PdfActivityConfiguration.Builder newConfigurations;

/**
* @param currentConfiguration The current configurations.
* @param toolbarItems The toolbar items to be customized.
*/
public ToolbarMenuItemsAdapter(@NonNull final PdfActivityConfiguration.Builder currentConfiguration, @NonNull final ReadableArray toolbarItems) {
PdfActivityConfiguration.Builder configuration = disableDefaultToolbarItems(currentConfiguration);

for (int i = 0; i < toolbarItems.size(); i++) {
String toolbarItem = toolbarItems.getString(i);
switch (toolbarItem) {
case TOOLBAR_ITEM_SEARCH:
configuration.enableSearch();
break;
case TOOLBAR_ITEM_READER_VIEW:
configuration.enableReaderView(true);
break;
case TOOLBAR_ITEM_ANNOTATIONS:
configuration.enableAnnotationEditing();
break;
case TOOLBAR_ITEM_THUMBNAILS:
configuration.showThumbnailGrid();
break;
case TOOLBAR_ITEM_SHARE:
configuration.setEnabledShareFeatures(ShareFeatures.all());
break;
case TOOLBAR_ITEM_SETTINGS:
configuration.showSettingsMenu();
break;
case TOOLBAR_ITEM_OUTLINE:
configuration.enableOutline();
break;
case TOOLBAR_ITEM_BOOKMARKS:
configuration.enableBookmarkList();
break;
case TOOLBAR_ITEM_PRINT:
configuration.enablePrinting();
break;
case TOOLBAR_ITEM_ANNOTATION_LIST:
configuration.enableAnnotationList();
break;
case TOOLBAR_ITEM_DOCUMENT_INFO_VIEW:
configuration.enableDocumentInfoView();
break;
}
}
newConfigurations = configuration;
}

private PdfActivityConfiguration.Builder disableDefaultToolbarItems(final PdfActivityConfiguration.Builder configuration) {
configuration.disableSearch()
.enableReaderView(false)
.disableAnnotationEditing()
.hideThumbnailGrid()
.setEnabledShareFeatures(ShareFeatures.none())
.hideSettingsMenu()
.hideThumbnailGrid()
.disableOutline()
.disableAnnotationList()
.disablePrinting()
.disableBookmarkList()
.disableDocumentInfoView();
return configuration;
}

public PdfActivityConfiguration build() {
return newConfigurations.build();
}
}
4 changes: 4 additions & 0 deletions android/src/main/java/com/pspdfkit/views/PdfView.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ public void setConfiguration(PdfActivityConfiguration configuration) {
setupFragment();
}

public PdfActivityConfiguration getConfiguration() {
return configuration;
}

public void setDocument(@Nullable String documentPath) {
if (documentPath == null) {
this.document = null;
Expand Down
23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,23 @@ class PSPDFKitView extends React.Component {
}
};

/**
* Customise visible toolbar menu items for Android.
*
* @param toolbarMenuItems The list of bar button items. See the full list of button items here: https://pspdfkit.com/guides/react-native/user-interface/toolbars/main-toolbar/.
*
* @platform android
*/
setToolbarMenuItems = function(toolbarMenuItems){
if(Platform.OS =="android"){
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands.setToolbarMenuItems,
[toolbarMenuItems]
);
}
}

/**
* Removes the currently displayed Android Native PdfUiFragment.
*
Expand Down Expand Up @@ -667,6 +684,12 @@ PSPDFKitView.propTypes = {
* @platform ios
*/
toolbarTitle: PropTypes.string,
/**
* androidToolbarMenuItems: Customize the the toolbar menu items for Android.
* The full list of toolbar menu items: https://github.com/PSPDFKit/react-native/blob/master/android/src/main/java/com/pspdfkit/react/ToolbarMenuItemsAdapter.java
* @platform android
*/
androidToolbarMenuItems: PropTypes.array,
/**
* showNavigationButtonInToolbar: When set to true the toolbar integrated into the PSPDFKitView will display a back button in the top left corner.
*
Expand Down
4 changes: 2 additions & 2 deletions ios/RCTPSPDFKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
"$(SRCROOT)/../../react-native/React/**",
"$(SRCROOT)/../samples/Catalog/node_modules/react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -340,7 +340,7 @@
"$(SRCROOT)/../../react-native/React/**",
"$(SRCROOT)/../samples/Catalog/node_modules/react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pspdfkit",
"version": "2.2.2",
"version": "2.3.0",
"description": "React Native PDF Library by PSPDFKit",
"keywords": [
"react native",
Expand All @@ -21,12 +21,12 @@
"format": "prettier \"{samples/**/*.{md,js},*.{md,js}}\" --write"
},
"peerDependencies": {
"prop-types": "^15.7.2",
"prop-types": "^15.8.1",
"react": "^17.0.2",
"react-native": "^0.66.3"
"react-native": "^0.68.2"
},
"dependencies": {},
"devDependencies": {
"prettier": "^2.5.1"
"prettier": "^2.7.1"
}
}
2 changes: 1 addition & 1 deletion react-native-pspdfkit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
DESC
s.authors = { 'PSPDFKit GmbH' => '[email protected]' }
s.homepage = 'https://pspdfkit.com/guides/react-native/'
s.platform = :ios, '13.0'
s.platform = :ios, '14.0'
s.module_name = 'PSPDFKitReactNativeiOS'
s.source = { :git => 'https://github.com/PSPDFKit/react-native' }
s.source_files = 'ios/*.{xcodeproj}', 'ios/RCTPSPDFKit/*.{h,m,swift}', 'ios/RCTPSPDFKit/Converters/*.{h,m,swift}'
Expand Down
4 changes: 4 additions & 0 deletions samples/Catalog/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
./android
./ios
./assets
./node_modules/**/*.js
4 changes: 4 additions & 0 deletions samples/Catalog/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
root: true,
extends: '@react-native-community',
rules: {
'react/no-string-refs': 'off',
'no-alert': 'off',
},
};
7 changes: 5 additions & 2 deletions samples/Catalog/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
bracketSpacing: true,
bracketSameLine: false,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
"endOfLine": "auto",
"printWidth": 80,
"tabWidth": 2,
};
2 changes: 1 addition & 1 deletion samples/Catalog/Catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const examples = [
component.props.navigation.navigate('SplitPDF');
},
},
Platform.OS === 'ios' && {
{
key: 'item11',
name: 'Customize the Toolbar',
description: 'Show how to customize buttons in the toolbar.',
Expand Down
Loading

0 comments on commit dbd3363

Please sign in to comment.