Skip to content

Commit

Permalink
Release 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Jan 3, 2025
1 parent e4129c5 commit cd7600d
Show file tree
Hide file tree
Showing 62 changed files with 2,284 additions and 260 deletions.
325 changes: 264 additions & 61 deletions ACKNOWLEDGEMENTS.md

Large diffs are not rendered by default.

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

### 4.1.0 - 03 January 2024

- Adds support for `PspdfkitWidgetController.addEventListener` to iOS and Android. (J#HYB-550)`
- Adds support for the latest Android Studio version. (J#HYB-539)
- Nutrient Flutter SDK now requires Android Gradle Plugin 8.0.0 or later. (J#HYB-539)
- Nutrient Flutter SDK now requires Flutter 3.27.0 or later. (J#HYB-596)
- Updates for Nutrient Android SDK 2024.9.0.
- Updates for Nutrient iOS SDK 14.3.0.
- Fixes onPageChanged callback being triggered early on iOS. (J#HYB-596)

## Previous Releases

### 4.0.0 - 01 Nov 2024

- Adds Pigeon for communication between Flutter and native iOS and Android platforms. (J#HYB-455)
Expand All @@ -9,8 +21,6 @@
- Updates for Nutrient iOS SDK 14.1.1. (#45458)
- Updates for Nutrient Web SDK 2024.7.0. (#45458)

## Previous Releases

### 3.12.0 - 30 Jul 2024

### 3.12.1 - 11 Sep 2024
Expand Down
5 changes: 5 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ buildscript {
}
}


group 'com.pspdfkit.flutter.pspdfkit'
version pspdfkitFlutterVersion

Expand All @@ -45,6 +46,10 @@ android {
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
minSdkVersion androidMinSdkVersion
Expand Down
8 changes: 4 additions & 4 deletions android/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (pspdfkitMavenUrl == null || pspdfkitMavenUrl == '') {

ext.pspdfkitVersion = localProperties.getProperty('pspdfkit.version')
if (pspdfkitVersion == null || pspdfkitVersion == '') {
ext.pspdfkitVersion = '2024.6.1'
ext.pspdfkitVersion = '2024.9.0'
}

ext.pspdfkitMavenModuleName = 'pspdfkit'
Expand All @@ -52,8 +52,8 @@ if (!pubspecFile.exists()) {
def pubspecYaml = new Yaml().load(pubspecFile.newInputStream())
ext.pspdfkitFlutterVersion = pubspecYaml.version

ext.androidCompileSdkVersion = 34
ext.androidCompileSdkVersion = 35
ext.androidMinSdkVersion = 21
ext.androidTargetSdkVersion = 34
ext.androidGradlePluginVersion = '7.4.2'
ext.androidTargetSdkVersion = 35
ext.androidGradlePluginVersion = '8.7.2'
ext.kotlinVersion = "1.9.20"
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.pspdfkit.configuration.page.PageLayoutMode;
import com.pspdfkit.configuration.page.PageScrollDirection;
import com.pspdfkit.configuration.page.PageScrollMode;
import com.pspdfkit.configuration.search.SearchType;
import com.pspdfkit.configuration.settings.SettingsMenuItemType;
import com.pspdfkit.configuration.sharing.ShareFeatures;
import com.pspdfkit.configuration.theming.ThemeMode;
Expand Down Expand Up @@ -476,7 +477,7 @@ private void configureFitPageToWidth(boolean fitPageToWidth) {
}

private void configureInlineSearch(boolean inlineSearch) {
final int searchType = inlineSearch ? PdfActivityConfiguration.SEARCH_INLINE : PdfActivityConfiguration.SEARCH_MODULAR;
final SearchType searchType = inlineSearch ? SearchType.INLINE : SearchType.MODULAR;
configuration.setSearchType(searchType);
}

Expand Down Expand Up @@ -860,7 +861,6 @@ PdfActivityConfiguration build() {
this.configuration
.enabledAnnotationTools(annotationTools);
}

return configuration.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ package com.pspdfkit.flutter.pspdfkit
/// This notice may not be removed from this file.
///
import android.content.Context
import android.graphics.PointF
import android.view.MotionEvent
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.pspdfkit.annotations.Annotation
import com.pspdfkit.document.DocumentSaveOptions
import com.pspdfkit.document.PdfDocument
import com.pspdfkit.flutter.pspdfkit.api.PdfDocumentApi
import com.pspdfkit.flutter.pspdfkit.document.FlutterPdfDocument
Expand Down Expand Up @@ -114,4 +118,20 @@ class FlutterPdfUiFragmentCallbacks(
}
}
}

override fun onPageClick(
document: PdfDocument,
pageIndex: Int,
event: MotionEvent?,
pagePosition: PointF?,
clickedAnnotation: Annotation?
): Boolean {
flutterWidgetCallback.onPageClick(document, pageIndex, event, pagePosition, clickedAnnotation)
return true
}

override fun onDocumentSave(document: PdfDocument, saveOptions: DocumentSaveOptions): Boolean {
flutterWidgetCallback.onDocumentSave(document,saveOptions)
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

package com.pspdfkit.flutter.pspdfkit

import android.graphics.PointF
import android.view.MotionEvent
import com.pspdfkit.annotations.Annotation
import com.pspdfkit.document.DocumentSaveOptions
import com.pspdfkit.document.PdfDocument
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitWidgetCallbacks
import com.pspdfkit.listeners.DocumentListener
Expand Down Expand Up @@ -36,4 +40,35 @@ class FlutterWidgetCallback(
) {}
super.onDocumentLoadFailed(exception)
}

override fun onPageClick(
document: PdfDocument,
pageIndex: Int,
event: MotionEvent?,
pagePosition: PointF?,
clickedAnnotation: Annotation?
): Boolean {
var flutterPointF: com.pspdfkit.flutter.pspdfkit.api.PointF? = null
pagePosition?.let {
flutterPointF = com.pspdfkit.flutter.pspdfkit.api.PointF(
pagePosition.x.toDouble(),
pagePosition.x.toDouble()
)
}
pspdfkitWidgetCallbacks?.onPageClick(
document.uid,
pageIndex.toLong(),
flutterPointF,
clickedAnnotation?.toInstantJson()
) {}
return true
}

override fun onDocumentSave(document: PdfDocument, saveOptions: DocumentSaveOptions): Boolean {
pspdfkitWidgetCallbacks?.onDocumentSaved(
document.uid,
document.documentSource.fileUri?.path
) {}
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import com.pspdfkit.document.processor.PdfProcessor
import com.pspdfkit.document.processor.PdfProcessor.ProcessorProgress
import com.pspdfkit.document.processor.PdfProcessorTask
import com.pspdfkit.flutter.pspdfkit.AnnotationConfigurationAdaptor.Companion.convertAnnotationConfigurations
import com.pspdfkit.flutter.pspdfkit.api.NutrientEventsCallbacks
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitWidgetCallbacks
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitWidgetControllerApi
import com.pspdfkit.flutter.pspdfkit.events.FlutterEventsHelper
import com.pspdfkit.flutter.pspdfkit.toolbar.FlutterMenuGroupingRule
import com.pspdfkit.flutter.pspdfkit.toolbar.FlutterViewModeController
import com.pspdfkit.flutter.pspdfkit.util.DocumentJsonDataProvider
Expand Down Expand Up @@ -70,6 +72,7 @@ internal class PSPDFKitView(
private val pdfUiFragment: PdfUiFragment
private var fragmentCallbacks: FlutterPdfUiFragmentCallbacks? = null
private val pspdfkitViewImpl: PspdfkitViewImpl = PspdfkitViewImpl()
private val nutrientEventsCallbacks: NutrientEventsCallbacks = NutrientEventsCallbacks(messenger, "events.callbacks.$id")
private val widgetCallbacks: PspdfkitWidgetCallbacks =
PspdfkitWidgetCallbacks(messenger, "widget.callbacks.$id")

Expand Down Expand Up @@ -171,6 +174,8 @@ internal class PSPDFKitView(
override fun onFlutterViewAttached(flutterView: View) {
super.onFlutterViewAttached(flutterView)
// Set up the method channel for communication with Flutter.
val flutterEventsHelper = FlutterEventsHelper(nutrientEventsCallbacks)
pspdfkitViewImpl.setEventDispatcher(flutterEventsHelper)
PspdfkitWidgetControllerApi.setUp(messenger, pspdfkitViewImpl, id.toString())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import android.provider.Settings
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentActivity
import com.pspdfkit.PSPDFKit
import com.pspdfkit.PSPDFKit.VERSION
import com.pspdfkit.PSPDFKit.initialize
import com.pspdfkit.document.formatters.DocumentJsonFormatter
Expand All @@ -31,6 +32,7 @@ import com.pspdfkit.flutter.pspdfkit.api.AndroidPermissionStatus
import com.pspdfkit.flutter.pspdfkit.api.AnnotationProcessingMode
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitApi
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitApiError
import com.pspdfkit.flutter.pspdfkit.events.FlutterAnalyticsClient
import com.pspdfkit.flutter.pspdfkit.pdfgeneration.PdfPageAdaptor
import com.pspdfkit.flutter.pspdfkit.util.DocumentJsonDataProvider
import com.pspdfkit.flutter.pspdfkit.util.Preconditions
Expand Down Expand Up @@ -66,15 +68,21 @@ import java.nio.charset.StandardCharsets
class PspdfkitApiImpl(private var activityPluginBinding: ActivityPluginBinding?) : PspdfkitApi {

private var disposable: Disposable? = null
private var analyticsEventClient: FlutterAnalyticsClient? = null

fun dispose() {
disposable?.dispose()
analyticsEventClient = null
}

fun setActivityPluginBinding(activityPluginBinding: ActivityPluginBinding?) {
this.activityPluginBinding = activityPluginBinding
}

fun setAnalyticsEventClient(analyticsEventClient: FlutterAnalyticsClient?) {
this.analyticsEventClient = analyticsEventClient
}

override fun getFrameworkVersion(callback: (Result<String?>) -> Unit) {
callback(Result.success(VERSION))
}
Expand Down Expand Up @@ -139,9 +147,6 @@ class PspdfkitApiImpl(private var activityPluginBinding: ActivityPluginBinding?)
val configurationAdapterInstant = ConfigurationAdapter(
activityPluginBinding?.activity as FragmentActivity, configurationMapInstant
)
val annotationTools =
configurationAdapterInstant.build().configuration.enabledAnnotationTools
annotationTools.add(AnnotationTool.INSTANT_COMMENT_MARKER)
val intentInstant = InstantPdfActivityIntentBuilder.fromInstantDocument(
activityPluginBinding?.activity as FragmentActivity, serverUrl, jwt
).activityClass(FlutterInstantPdfActivity::class.java)
Expand Down Expand Up @@ -474,13 +479,13 @@ class PspdfkitApiImpl(private var activityPluginBinding: ActivityPluginBinding?)
})
}

override fun importXfdf(xfdfPath: String, callback: (Result<Boolean?>) -> Unit) {
override fun importXfdf(xfdfString: String, callback: (Result<Boolean?>) -> Unit) {
checkNotNull(activityPluginBinding) { "ActivityPluginBinding is null" }
val document = Preconditions.requireDocumentNotNull(
activityPluginBinding?.activity as PdfActivity, "Pspdfkit.processAnnotations()"
)

val dataProvider = DocumentJsonDataProvider(xfdfPath)
val dataProvider = DocumentJsonDataProvider(xfdfString)
// The async parse method is recommended (so you can easily offload parsing from the UI thread).
disposable = XfdfFormatter.parseXfdfAsync(document, dataProvider)
.subscribeOn(Schedulers.io()) // Specify the thread on which to parse XFDF.
Expand Down Expand Up @@ -748,6 +753,14 @@ class PspdfkitApiImpl(private var activityPluginBinding: ActivityPluginBinding?)
}
}

override fun enableAnalyticsEvents(enable: Boolean) {
if (enable) {
analyticsEventClient?.let { PSPDFKit.addAnalyticsClient(it) }
} else {
analyticsEventClient?.let { PSPDFKit.removeAnalyticsClient(it) }
}
}

private fun setLicenseKey(activity: FragmentActivity, licenseKey: String?) {
try {
initialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@
import com.pspdfkit.document.processor.PdfProcessorTask;
import com.pspdfkit.exceptions.PSPDFKitException;
import com.pspdfkit.flutter.pspdfkit.annotations.FlutterAnnotationPresetConfiguration;
import com.pspdfkit.flutter.pspdfkit.api.AnalyticsEventsCallback;
import com.pspdfkit.flutter.pspdfkit.api.NutrientEventsCallbacks;
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitApi;
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitFlutterApiCallbacks;
import com.pspdfkit.flutter.pspdfkit.events.FlutterAnalyticsClient;
import com.pspdfkit.flutter.pspdfkit.events.FlutterEventsHelper;
import com.pspdfkit.flutter.pspdfkit.pdfgeneration.PdfPageAdaptor;
import com.pspdfkit.flutter.pspdfkit.util.DocumentJsonDataProvider;
import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper;
Expand Down Expand Up @@ -151,6 +155,8 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
// Setup the PSPDFKit API.
PspdfkitApi.Companion.setUp(binding.getBinaryMessenger(),pspdfkitApi,MESSAGE_CHANNEL_SUFFIX);
PspdfkitFlutterApiCallbacks pspdfkitFlutterApiCallbacks = new PspdfkitFlutterApiCallbacks(binding.getBinaryMessenger(),MESSAGE_CHANNEL_SUFFIX);
AnalyticsEventsCallback callback = new AnalyticsEventsCallback(binding.getBinaryMessenger(),MESSAGE_CHANNEL_SUFFIX);
pspdfkitApi.setAnalyticsEventClient(new FlutterAnalyticsClient(callback));
eventDispatcher.setPspdfkitApiCallbacks(new PspdfkitApiCallbacks(pspdfkitFlutterApiCallbacks));
}

Expand Down Expand Up @@ -268,6 +274,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {

Intent intentInstant =
InstantPdfActivityIntentBuilder
.Companion
.fromInstantDocument(activity, documentUrl, jwt)
.activityClass(FlutterInstantPdfActivity.class)
.configuration(configurationAdapterInstant.build())
Expand Down Expand Up @@ -929,6 +936,7 @@ private void detachActivityPluginBinding() {
activityPluginBinding.removeRequestPermissionsResultListener(this);
activityPluginBinding = null;
pspdfkitApi.setActivityPluginBinding(null);

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import com.pspdfkit.flutter.pspdfkit.AnnotationConfigurationAdaptor.Companion.co
import com.pspdfkit.flutter.pspdfkit.annotations.FlutterAnnotationPresetConfiguration
import com.pspdfkit.flutter.pspdfkit.api.AnnotationProcessingMode
import com.pspdfkit.flutter.pspdfkit.api.AnnotationType
import com.pspdfkit.flutter.pspdfkit.api.NutrientEvent
import com.pspdfkit.flutter.pspdfkit.api.PdfRect
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitApiError
import com.pspdfkit.flutter.pspdfkit.api.PspdfkitWidgetControllerApi
import com.pspdfkit.flutter.pspdfkit.events.FlutterEventsHelper
import com.pspdfkit.flutter.pspdfkit.util.DocumentJsonDataProvider
import com.pspdfkit.flutter.pspdfkit.util.Preconditions.requireNotNullNotEmpty
import com.pspdfkit.flutter.pspdfkit.util.ProcessorHelper.annotationTypeFromString
Expand All @@ -44,6 +46,7 @@ import java.util.Locale
class PspdfkitViewImpl : PspdfkitWidgetControllerApi {
private var pdfUiFragment: PdfUiFragment? = null
private var disposable: Disposable? = null
private var eventDispatcher: FlutterEventsHelper? = null

/**
* Sets the PdfFragment to be used by the controller.
Expand All @@ -54,6 +57,10 @@ class PspdfkitViewImpl : PspdfkitWidgetControllerApi {
this.pdfUiFragment = pdfFragment
}

fun setEventDispatcher(eventDispatcher: FlutterEventsHelper) {
this.eventDispatcher = eventDispatcher
}

/**
* Disposes the controller and releases all resources.
*/
Expand Down Expand Up @@ -617,4 +624,12 @@ class PspdfkitViewImpl : PspdfkitWidgetControllerApi {
}
}
}

override fun addEventListener(event: NutrientEvent) {
eventDispatcher?.setEventListener(pdfUiFragment!!, event)
}

override fun removeEventListener(event: NutrientEvent) {
eventDispatcher?.removeEventListener(pdfUiFragment!!, event)
}
}
Loading

0 comments on commit cd7600d

Please sign in to comment.