Skip to content

Commit

Permalink
Release 2.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed May 6, 2024
1 parent dc6971a commit 34697d8
Show file tree
Hide file tree
Showing 55 changed files with 5,092 additions and 4,720 deletions.
27 changes: 18 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
## Newest Release

### 2.10.0 - 06 May 2024

- Adds the ability to define annotation behavior using flags. (J#HYB-283)
- Adds the ability to add custom menu items to the annotation selection menu. (J#HYB-280)
- Adds the `imageSaveMode` property to the `PSPDFKitView` component to specify how annotations should be treated when saving image documents. (J#HYB-334)
- Updates for PSPDFKit 13.5.0 for iOS.
- Fixes an issue where selecting a measurement annotation without the Measurement Tools license causes a crash. (J#HYB-318)
- Fixes an issue where the `removeAnnotation` API sometimes failed to remove an annotation on iOS. (J#HYB-43)

## Previous Releases

### 2.9.1 - 12 Apr 2024

- Adds the ability to import and export annotations from XFDF files. (J#HYB-293)
- Updates for PSPDFKit 2024.2.1 for Android.
- Fixes issue where password input UI for password-protected documents wasn't shown on Android. (J#HYB-285)

## Previous Releases

### 2.9.0 - 22 Mar 2024

- Adds new getConfiguration method to retrieve current PSPDFKitView configuration options. (J#HYB-192)
- Adds the option to open a password protected document through configuration. (J#HYB-213)
- Adds new `getConfiguration` method to retrieve current PSPDFKitView configuration options. (J#HYB-192)
- Adds the option to open a password-protected document through configuration. (J#HYB-213)
- Adds the ability to add custom toolbar buttons to the PSPDFKit toolbar. (J#HYB-198)
- Adds support for new `MeasurementValueConfiguration` configuration option, replacing deprecated `setMeasurementScale` and `setMeasurementPrecision` methods. (J#HYB-205)
- Updates `showPageLabels` property to also control page number overlay on Android. (J#HYB-223)
- Adds support for the new `MeasurementValueConfiguration` configuration option, replacing the deprecated `setMeasurementScale` and `setMeasurementPrecision` methods. (J#HYB-205)
- Updates the `showPageLabels` property to also control page number overlay on Android. (J#HYB-223)
- Updates for PSPDFKit 2024.1.2 for Android.
- Updates for PSPDFKit 13.3.3 for iOS.
- Fixes issue of document URIs with file:/// scheme on iOS. (#43160)
- Fixes issue where `onDocumentLoaded` callback was not called on Android. (#43187)
- Fixes signatureSavingStrategy configuration option to save signature if enabled. (J#HYB-210)
- Fixes `spreadFitting` configuration option behaviour on iOS. (J#HYB-222)
- Fixes issue where the `onDocumentLoaded` callback was not called on Android. (#43187)
- Fixes the `signatureSavingStrategy` configuration option to save signatures if enabled. (J#HYB-210)
- Fixes `spreadFitting` configuration option behavior on iOS. (J#HYB-222)

### 2.8.1 - 27 Feb 2024

Expand Down
13 changes: 12 additions & 1 deletion android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
connection.project.dir=../../../android
arguments=--init-script /var/folders/3v/qy3ssjxs2m7d97yc60nrl2l00000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/3v/qy3ssjxs2m7d97yc60nrl2l00000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.1.1))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
28 changes: 28 additions & 0 deletions android/src/main/java/com/pspdfkit/react/ReactPdfViewManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class ReactPdfViewManager extends ViewGroupManager<PdfView> {
public static final int COMMAND_GET_MEASUREMENT_VALUE_CONFIGURATIONS = 22;
public static final int COMMAND_IMPORT_XFDF = 23;
public static final int COMMAND_EXPORT_XFDF = 24;
public static final int COMMAND_SET_ANNOTATION_FLAGS = 25;
public static final int COMMAND_GET_ANNOTATION_FLAGS = 26;

private final CompositeDisposable annotationDisposables = new CompositeDisposable();

Expand Down Expand Up @@ -127,6 +129,8 @@ public Map<String, Integer> getCommandsMap() {
commandMap.put("setToolbar", COMMAND_SET_TOOLBAR);
commandMap.put("importXFDF", COMMAND_IMPORT_XFDF);
commandMap.put("exportXFDF", COMMAND_EXPORT_XFDF);
commandMap.put("setAnnotationFlags", COMMAND_SET_ANNOTATION_FLAGS);
commandMap.put("getAnnotationFlags", COMMAND_GET_ANNOTATION_FLAGS);
return commandMap;
}

Expand Down Expand Up @@ -217,6 +221,11 @@ public void setAnnotationAuthorName(PdfView view, String annotationAuthorName) {
PSPDFKitPreferences.get(view.getContext()).setAnnotationCreator(annotationAuthorName);
}

@ReactProp(name = "imageSaveMode")
public void setImageSaveMode(PdfView view, String imageSaveMode) {
view.setImageSaveMode(imageSaveMode);
}

@ReactProp(name = "menuItemGrouping")
public void setMenuItemGrouping(PdfView view, @NonNull ReadableArray menuItemGrouping) {
ReactGroupingRule groupingRule = new ReactGroupingRule(view.getContext(), menuItemGrouping);
Expand Down Expand Up @@ -257,6 +266,13 @@ public void setToolbarMenuItems(@NonNull final PdfView view, @Nullable final Rea
}
}

@ReactProp(name = "annotationContextualMenu")
public void setAnnotationContextualMenu(@NonNull final PdfView view, @NonNull ReadableMap annotationContextualMenuItems) {
if (annotationContextualMenuItems != null) {
view.setAnnotationToolbarMenuButtonItems(annotationContextualMenuItems);
}
}

@ReactProp(name = "measurementValueConfigurations")
public void setMeasurementValueConfigurations(@NonNull final PdfView view, @Nullable final ReadableArray measurementValueConfigs) {
if (measurementValueConfigs != null) {
Expand Down Expand Up @@ -358,6 +374,18 @@ public void accept(List<Annotation> annotations) {
annotationDisposables.add(root.addAnnotations(requestId, args.getMap(1)));
}
break;
case COMMAND_SET_ANNOTATION_FLAGS:
if (args != null && args.size() == 3) {
final int requestId = args.getInt(0);
annotationDisposables.add(root.setAnnotationFlags(requestId, args.getString(1), args.getArray(2)));
}
break;
case COMMAND_GET_ANNOTATION_FLAGS:
if (args != null && args.size() == 2) {
final int requestId = args.getInt(0);
annotationDisposables.add(root.getAnnotationFlags(requestId, args.getString(1)));
}
break;
case COMMAND_GET_FORM_FIELD_VALUE:
if (args != null && args.size() == 2) {
final int requestId = args.getInt(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.pspdfkit.react.events

import androidx.annotation.IdRes
import com.facebook.react.bridge.Arguments
import com.facebook.react.uimanager.events.Event
import com.facebook.react.uimanager.events.RCTEventEmitter

class CustomAnnotationContextualMenuItemTappedEvent: Event<CustomAnnotationContextualMenuItemTappedEvent> {
private var buttonId: String? = null

constructor(@IdRes viewId: Int, buttonId: String) : super(viewId) {

this.buttonId = buttonId
}

override fun getEventName(): String? {
return EVENT_NAME
}

override fun dispatch(rctEventEmitter: RCTEventEmitter) {
val eventData = Arguments.createMap()
eventData.putString("id", buttonId)
rctEventEmitter.receiveEvent(viewTag, eventName, eventData)
}

companion object {
@kotlin.jvm.JvmField
var EVENT_NAME = "customAnnotationContextualMenuItemTapped"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void dispatch(RCTEventEmitter rctEventEmitter) {
} else {
JSONObject instantJson = new JSONObject(annotation.toInstantJson());
annotationMap = JsonUtilities.jsonObjectToMap(instantJson);
annotationMap.put("uuid", annotation.getUuid());
}

List<Map<String, Object>> annotations = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ public String getEventName() {
@Override
public void dispatch(RCTEventEmitter rctEventEmitter) {
try {
JSONObject instantJson = new JSONObject(annotation.toInstantJson());
Map<String, Object> map = JsonUtilities.jsonObjectToMap(instantJson);
WritableMap eventData = Arguments.makeNativeMap(map);
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData);
String rawInstantJson = annotation.toInstantJson();
if (rawInstantJson != null && !rawInstantJson.equals("null")) {
JSONObject instantJson = new JSONObject(rawInstantJson);
Map<String, Object> map = JsonUtilities.jsonObjectToMap(instantJson);
WritableMap eventData = Arguments.makeNativeMap(map);
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData);
}
} catch (JSONException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ public PdfViewDataReturnedEvent(@IdRes int viewId, int requestId, boolean result
payload = Arguments.makeNativeMap(map);
}

public PdfViewDataReturnedEvent(@IdRes int viewId, int requestId, ArrayList result) {
super(viewId);
this.requestId = requestId;
Map<String, Object> map = new HashMap<>();
map.put("requestId", requestId);
map.put("result", result);

payload = Arguments.makeNativeMap(map);
}

public PdfViewDataReturnedEvent(@IdRes int viewId, int requestId, @NonNull JSONObject jsonObject) {
super(viewId);
this.requestId = requestId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

import androidx.annotation.Nullable;

import com.facebook.react.bridge.ReadableArray;
import com.pspdfkit.annotations.AnnotationFlags;
import com.pspdfkit.annotations.AnnotationType;
import com.pspdfkit.ui.toolbar.ContextualToolbarMenuItem;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;

public class ConversionHelpers {

Expand Down Expand Up @@ -82,4 +87,86 @@ public static EnumSet<AnnotationType> getAnnotationTypeFromString(@Nullable fina
return EnumSet.allOf(AnnotationType.class);
}
}

public static EnumSet<AnnotationFlags> getAnnotationFlags(final ReadableArray flags) {

EnumSet<AnnotationFlags> convertedFlags = EnumSet.noneOf(AnnotationFlags.class);

for (int i = 0; i < flags.size(); i++) {
String flag = flags.getString(i);
switch (flag) {
case "hidden":
convertedFlags.add(AnnotationFlags.HIDDEN);
break;
case "invisible":
convertedFlags.add(AnnotationFlags.INVISIBLE);
break;
case "locked":
convertedFlags.add(AnnotationFlags.LOCKED);
break;
case "lockedContents":
convertedFlags.add(AnnotationFlags.LOCKEDCONTENTS);
break;
case "print":
convertedFlags.add(AnnotationFlags.PRINT);
break;
case "readOnly":
convertedFlags.add(AnnotationFlags.READONLY);
break;
case "noView":
convertedFlags.add(AnnotationFlags.NOVIEW);
break;
case "noZoom":
convertedFlags.add(AnnotationFlags.NOZOOM);
break;
default:
break;
}

}
return convertedFlags;
}

public static ArrayList<String> convertAnnotationFlags(final EnumSet<AnnotationFlags> flags) {

ArrayList<String> stringFlags = new ArrayList<String>();

if (flags.contains(AnnotationFlags.HIDDEN)) {
stringFlags.add("hidden");
}
if (flags.contains(AnnotationFlags.INVISIBLE)) {
stringFlags.add("invisible");
}
if (flags.contains(AnnotationFlags.LOCKED)) {
stringFlags.add("locked");
}
if (flags.contains(AnnotationFlags.LOCKEDCONTENTS)) {
stringFlags.add("lockedContents");
}
if (flags.contains(AnnotationFlags.PRINT)) {
stringFlags.add("print");
}
if (flags.contains(AnnotationFlags.READONLY)) {
stringFlags.add("readOnly");
}
if (flags.contains(AnnotationFlags.NOVIEW)) {
stringFlags.add("noView");
}
if (flags.contains(AnnotationFlags.NOZOOM)) {
stringFlags.add("noZoom");
}

return stringFlags;
}

public static ContextualToolbarMenuItem.Position getContextualToolbarMenuItemPosition(final String position) {
switch (position.toLowerCase()) {
case "start":
return ContextualToolbarMenuItem.Position.START;
case "end":
return ContextualToolbarMenuItem.Position.END;
default:
return ContextualToolbarMenuItem.Position.END;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pspdfkit.react.helper

import android.content.Context
import java.io.File
import java.util.Locale

Expand Down Expand Up @@ -28,6 +29,11 @@ class PSPDFKitUtils {
@JvmStatic
public fun isValidPdf(file: File): Boolean {
return file.name.lowercase(Locale.getDefault()).endsWith(".pdf")
}

@JvmStatic
public fun getCustomResourceId(resName: String, type: String, context: Context): Int {
return context.resources.getIdentifier(resName, type, context.packageName)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.pspdfkit.react.menu;

import android.content.Context;
import androidx.annotation.NonNull;

import com.pspdfkit.ui.toolbar.ContextualToolbarMenuItem;
import com.pspdfkit.ui.toolbar.grouping.presets.AnnotationEditingToolbarGroupingRule;
import com.pspdfkit.ui.toolbar.grouping.presets.MenuItem;
import java.util.ArrayList;
import java.util.List;
public class AnnotationContextualToolbarGroupingRule extends AnnotationEditingToolbarGroupingRule {

List<ContextualToolbarMenuItem> menuItems;

public AnnotationContextualToolbarGroupingRule(@NonNull Context context, @NonNull List menuItems) {
super(context);
this.menuItems = menuItems;
}

@NonNull
@Override
public List<MenuItem> getGroupPreset(int capacity, int itemsCount) {
List<com.pspdfkit.ui.toolbar.grouping.presets.MenuItem> groupPreset =
new ArrayList<>(super.getGroupPreset(capacity - 1, itemsCount - 1));
for (ContextualToolbarMenuItem menuItem : menuItems) {
groupPreset.add(new MenuItem(menuItem.getId()));
}
return groupPreset;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.pspdfkit.react.menu

import com.pspdfkit.ui.toolbar.ContextualToolbarMenuItem
import com.pspdfkit.views.ToolbarMenuItemListener

class ContextualToolbarMenuItemConfig(menuItems: List<ContextualToolbarMenuItem>, retain: Boolean = true, listener: ToolbarMenuItemListener) {
val annotationSelectionMenuItems: List<ContextualToolbarMenuItem>
val retainSuggestedMenuItems: Boolean
val toolbarMenuItemListener: ToolbarMenuItemListener

init {
annotationSelectionMenuItems = menuItems
retainSuggestedMenuItems = retain
toolbarMenuItemListener = listener
}
}
Loading

0 comments on commit 34697d8

Please sign in to comment.