Skip to content

Commit d73b9e9

Browse files
author
PSPDFKit
committed
Release 4.2.2
1 parent 0920a7c commit d73b9e9

25 files changed

+1821
-1602
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 4.2.2 - 24 Mar 2025
2+
3+
- Updates for Nutrient Android SDK 10.1.1 - https://www.nutrient.io/guides/android/changelog/.
4+
- Updates Android bridging by moving `MethodCallHandler` from `PspdfkitPlugin` to `PspdfkitPluginMethodCallHandler`, preparing for a complete migration to Pigeon and proper deprecation path. (J#HYB-690)
5+
- Fixes issue on Android when adding an annotationDeleted event listener. (J#HYB-640)
6+
17
## 4.2.1 - 10 Mar 2025
28

39
- Adds `enterAnnotationCreationMode` and `exitAnnotationCreationMode` APIs to `PspdfkitWidgetController`.
@@ -12,7 +18,7 @@
1218
- Adds support for annotation flags. (J#HYB-683)
1319
- Adds support for custom stamps. (J#HYB-685)
1420
- Fixes issue where setting an iOS license key shows "PSPDFKit Licensing Issue" error. (J#HYB-658)
15-
- Fixes Annotation preset customizations not being set correctly. (J#HYB-686)
21+
- Fixes annotation preset customizations not being set correctly. (J#HYB-686)
1622

1723
## 4.1.1 - 17 Jan 2025
1824

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ android {
6262

6363
dependencies {
6464
implementation 'androidx.appcompat:appcompat:1.7.0'
65-
implementation "com.pspdfkit:$pspdfkitMavenModuleName:$pspdfkitVersion"
65+
implementation "io.nutrient:$pspdfkitMavenModuleName:$pspdfkitVersion"
6666
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
6767
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
6868
implementation "androidx.compose.material:material:1.7.8"

android/config.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ if (pspdfkitMavenUrl == null || pspdfkitMavenUrl == '') {
3838

3939
ext.pspdfkitVersion = localProperties.getProperty('pspdfkit.version')
4040
if (pspdfkitVersion == null || pspdfkitVersion == '') {
41-
ext.pspdfkitVersion = '2024.9.1'
41+
ext.pspdfkitVersion = '10.1.1'
4242
}
4343

44-
ext.pspdfkitMavenModuleName = 'pspdfkit'
44+
ext.pspdfkitMavenModuleName = 'nutrient'
4545

4646
// Get our library version from the top level pubspec.yaml file.
4747
def pubspecFilePath = '../pubspec.yaml'

android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:windowSoftInputMode="adjustNothing" />
1818

1919
<meta-data
20-
android:name="pspdfkit_automatic_initialize"
20+
android:name="nutrient_automatic_initialize"
2121
android:value="false" />
2222
</application>
2323
</manifest>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,13 @@ class ConfigurationAdapter {
125125
* @deprecated This key word was deprecated with PSPDFKit for Fluttter 3.1.
126126
* Use {@code FIRST_PAGE_ALWAYS_SINGLE} instead, which replaces it.
127127
*/
128+
@Deprecated
128129
private static final String IS_FIRST_PAGE_ALWAYS_SINGLE = "isFirstPageAlwaysSingle";
129130
/**
130131
* @deprecated This key word was deprecated with PSPDFKit for Fluttter 3.1.
131132
* Use {@code SHOW_BOOKMARKS_ACTION} instead, which replaces it.
132133
*/
134+
@Deprecated
133135
private static final String ENABLE_BOOKMARK_LIST = "enableBookmarkList";
134136

135137
// Document Interaction Values

android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterInstantPdfActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class FlutterInstantPdfActivity : InstantPdfActivity() {
100100

101101
override fun onAttachFragment(fragment: Fragment) {
102102
super.onAttachFragment(fragment)
103-
if(fragment.tag?.contains("PSPDFKit.Fragment") == true){
103+
if(fragment.tag?.contains("Nutrient.Fragment") == true){
104104
EventDispatcher.getInstance().notifyPdfFragmentAdded()
105105
}
106106
}

android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterPdfActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void onDocumentLoaded(@NonNull PdfDocument pdfDocument) {
8080
@Override
8181
public void onAttachFragment(@NonNull Fragment fragment) {
8282
super.onAttachFragment(fragment);
83-
if(fragment.getTag() !=null && fragment.getTag().contains("PSPDFKit.Fragment")){
83+
if(fragment.getTag() !=null && fragment.getTag().contains("Nutrient.Fragment")){
8484
EventDispatcher.getInstance().notifyPdfFragmentAdded();
8585
}
8686
}

android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterPdfUiFragmentCallbacks.kt

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package com.pspdfkit.flutter.pspdfkit
1717
///
1818
import android.content.Context
1919
import android.graphics.PointF
20+
import android.util.Log
2021
import android.view.MotionEvent
2122
import androidx.fragment.app.Fragment
2223
import androidx.fragment.app.FragmentManager
@@ -31,6 +32,8 @@ import com.pspdfkit.ui.PdfFragment
3132
import io.flutter.plugin.common.BinaryMessenger
3233
import io.flutter.plugin.common.MethodChannel
3334

35+
private const val LOG_TAG = "FlutterPdfUiCallbacks"
36+
3437
/**
3538
* Callbacks for the FlutterPdfUiFragment.
3639
* This class is responsible for notifying the Flutter side about document loading events.
@@ -41,8 +44,8 @@ import io.flutter.plugin.common.MethodChannel
4144
* @param flutterWidgetCallback The callback to notify the Flutter side about document loading events.
4245
*/
4346
class FlutterPdfUiFragmentCallbacks(
44-
private val methodChannel: MethodChannel, private val measurementConfigurations:
45-
List<Map<String, Any>>?,
47+
private val methodChannel: MethodChannel,
48+
private val measurementConfigurations: List<Map<String, Any>>?,
4649
private val binaryMessenger: BinaryMessenger,
4750
private val flutterWidgetCallback: FlutterWidgetCallback
4851
) : FragmentManager.FragmentLifecycleCallbacks(), DocumentListener {
@@ -55,9 +58,10 @@ class FlutterPdfUiFragmentCallbacks(
5558
f: Fragment,
5659
context: Context
5760
) {
58-
if (f.tag?.contains("PSPDFKit.Fragment") == true) {
61+
if (f.tag?.contains("Nutrient.Fragment") == true) {
5962
EventDispatcher.getInstance().notifyPdfFragmentAdded()
6063
if (f !is PdfFragment) {
64+
Log.w(LOG_TAG, "Fragment is not a PdfFragment: ${f::class.java.simpleName}")
6165
return
6266
}
6367
if (pdfFragment != null) {
@@ -69,45 +73,82 @@ class FlutterPdfUiFragmentCallbacks(
6973
}
7074

7175
override fun onDocumentLoaded(document: PdfDocument) {
76+
// Apply measurement configurations if available
7277
measurementConfigurations?.forEach {
73-
MeasurementHelper.addMeasurementConfiguration(pdfFragment!!, it)
78+
try {
79+
MeasurementHelper.addMeasurementConfiguration(pdfFragment!!, it)
80+
} catch (e: Exception) {
81+
Log.e(LOG_TAG, "Failed to apply measurement configuration", e)
82+
}
83+
}
84+
85+
// Send event through method channel
86+
try {
87+
val eventData = mapOf("documentId" to document.uid)
88+
methodChannel.invokeMethod("onDocumentLoaded", eventData)
89+
} catch (e: Exception) {
90+
Log.e(LOG_TAG, "Error sending onDocumentLoaded via method channel", e)
91+
}
92+
93+
// Send event through widget callbacks
94+
try {
95+
flutterWidgetCallback.onDocumentLoaded(document)
96+
} catch (e: Exception) {
97+
Log.e(LOG_TAG, "Error sending onDocumentLoaded via widget callbacks", e)
98+
}
99+
100+
// Set up document API for Flutter access
101+
try {
102+
flutterPdfDocument = FlutterPdfDocument(document)
103+
PdfDocumentApi.setUp(binaryMessenger, flutterPdfDocument, document.uid)
104+
} catch (e: Exception) {
105+
Log.e(LOG_TAG, "Error setting up FlutterPdfDocument", e)
106+
}
107+
108+
// Additional direct channel sending
109+
try {
110+
EventDispatcher.getInstance().notifyDocumentLoaded(document)
111+
} catch (e: Exception) {
112+
Log.e(LOG_TAG, "Error sending direct event notification", e)
74113
}
75-
methodChannel.invokeMethod(
76-
"onDocumentLoaded", mapOf(
77-
"documentId" to document.uid
78-
)
79-
)
80-
flutterWidgetCallback.onDocumentLoaded(document)
81-
flutterPdfDocument =
82-
FlutterPdfDocument(document);
83-
PdfDocumentApi.setUp(binaryMessenger, flutterPdfDocument, document.uid)
84114
}
85115

86116
override fun onPageChanged(document: PdfDocument, pageIndex: Int) {
87117
super.onPageChanged(document, pageIndex)
88-
flutterWidgetCallback.onPageChanged(document, pageIndex)
89-
methodChannel.invokeMethod(
90-
"onPageChanged",
91-
mapOf(
92-
"documentId" to document.uid,
93-
"pageIndex" to pageIndex
118+
119+
try {
120+
flutterWidgetCallback.onPageChanged(document, pageIndex)
121+
methodChannel.invokeMethod(
122+
"onPageChanged",
123+
mapOf(
124+
"documentId" to document.uid,
125+
"pageIndex" to pageIndex
126+
)
94127
)
95-
)
128+
} catch (e: Exception) {
129+
Log.e(LOG_TAG, "Error sending onPageChanged event", e)
130+
}
96131
}
97132

98133
override fun onDocumentLoadFailed(exception: Throwable) {
99134
super.onDocumentLoadFailed(exception)
100-
flutterWidgetCallback.onDocumentLoadFailed(exception)
101-
methodChannel.invokeMethod(
102-
"onDocumentLoadFailed",
103-
mapOf(
104-
"error" to exception.message
135+
Log.e(LOG_TAG, "Document load failed", exception)
136+
137+
try {
138+
flutterWidgetCallback.onDocumentLoadFailed(exception)
139+
methodChannel.invokeMethod(
140+
"onDocumentLoadFailed",
141+
mapOf(
142+
"error" to exception.message
143+
)
105144
)
106-
)
145+
} catch (e: Exception) {
146+
Log.e(LOG_TAG, "Error sending onDocumentLoadFailed event", e)
147+
}
107148
}
108149

109150
override fun onFragmentDetached(fm: FragmentManager, f: Fragment) {
110-
if (f.tag?.contains("PSPDFKit.Fragment") == true) {
151+
if (f.tag?.contains("Nutrient.Fragment") == true) {
111152
if (f !is PdfFragment) {
112153
return
113154
}
@@ -126,12 +167,20 @@ class FlutterPdfUiFragmentCallbacks(
126167
pagePosition: PointF?,
127168
clickedAnnotation: Annotation?
128169
): Boolean {
129-
flutterWidgetCallback.onPageClick(document, pageIndex, event, pagePosition, clickedAnnotation)
170+
try {
171+
flutterWidgetCallback.onPageClick(document, pageIndex, event, pagePosition, clickedAnnotation)
172+
} catch (e: Exception) {
173+
Log.e(LOG_TAG, "Error sending onPageClick event", e)
174+
}
130175
return true
131176
}
132177

133178
override fun onDocumentSave(document: PdfDocument, saveOptions: DocumentSaveOptions): Boolean {
134-
flutterWidgetCallback.onDocumentSave(document,saveOptions)
179+
try {
180+
flutterWidgetCallback.onDocumentSave(document, saveOptions)
181+
} catch (e: Exception) {
182+
Log.e(LOG_TAG, "Error sending onDocumentSave event", e)
183+
}
135184
return true
136185
}
137186
}

android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterWidgetCallback.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class FlutterWidgetCallback(
5151
var flutterPointF: com.pspdfkit.flutter.pspdfkit.api.PointF? = null
5252
pagePosition?.let {
5353
flutterPointF = com.pspdfkit.flutter.pspdfkit.api.PointF(
54-
pagePosition.x.toDouble(),
55-
pagePosition.x.toDouble()
54+
it.x.toDouble(),
55+
it.y.toDouble()
5656
)
5757
}
5858
pspdfkitWidgetCallbacks?.onPageClick(

0 commit comments

Comments
 (0)