Skip to content

Commit

Permalink
Release 3.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Mar 22, 2024
1 parent 05b38da commit 12e4d5b
Show file tree
Hide file tree
Showing 66 changed files with 1,637 additions and 587 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
## Newest Release

### 3.9.0 - 22 Mar 2024

- Adds annotation toolbar customization for iOS and Android. (J#HYB-209)
- Adds support for `MeasurementValueConfiguration` to replace `setMeasurementScale` and `setMeasurementPrecision`. (J#HYB-206)
- Updates for PSPDFKit 13.3.3 for iOS. (#43792)
- Updates for PSPDFKit 2024.1.2 for Android. (#43792)
- Fixes events callback functions not being triggered on Web. (J#HYB-221)
- Fixes blank page when an annotation toolbar item is selected on Web. (#43792)

## Previous Releases

### 3.8.2 - 27 Feb 2024

- Updates for PSPDFKit 13.3.1 for iOS. (#43550)
- Fixes issue where PSPDFKit for Flutter does not work on web with Flutter SDK version 13.19.0 (J#HYB-216)
- Fixes issue where annotation toolbar items are not being displayed on Web. (J#HYB-217)

## Previous Releases

### 3.8.1 - 14 Feb 2024
- Fixes callbacks when Pspdfkit.present() is used. (J#HYB-204)

Expand Down
5 changes: 5 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ dependencies {
implementation "com.pspdfkit:$pspdfkitMavenModuleName:$pspdfkitVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.compose.material:material:1.6.3"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
implementation "androidx.compose.foundation:foundation:1.6.3"
implementation "androidx.compose.ui:ui:1.6.3"
}
4 changes: 2 additions & 2 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.1.0'
ext.pspdfkitVersion = '2024.1.2'
}

ext.pspdfkitMavenModuleName = 'pspdfkit'
Expand All @@ -55,5 +55,5 @@ ext.pspdfkitFlutterVersion = pubspecYaml.version
ext.androidCompileSdkVersion = 34
ext.androidMinSdkVersion = 21
ext.androidTargetSdkVersion = 34
ext.androidGradlePluginVersion = '8.1.2'
ext.androidGradlePluginVersion = '8.2.2'
ext.kotlinVersion = "1.8.10"
4 changes: 4 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
<activity
android:name="com.pspdfkit.flutter.pspdfkit.FlutterPdfActivity"
android:windowSoftInputMode="adjustNothing" />

<meta-data
android:name="pspdfkit_automatic_initialize"
android:value="false" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ import android.content.Context
import android.graphics.Color
import androidx.core.util.Pair
import com.pspdfkit.annotations.AnnotationType
import com.pspdfkit.annotations.AnnotationType.*
import com.pspdfkit.annotations.AnnotationType.CIRCLE
import com.pspdfkit.annotations.AnnotationType.FILE
import com.pspdfkit.annotations.AnnotationType.FREETEXT
import com.pspdfkit.annotations.AnnotationType.HIGHLIGHT
import com.pspdfkit.annotations.AnnotationType.INK
import com.pspdfkit.annotations.AnnotationType.LINE
import com.pspdfkit.annotations.AnnotationType.NOTE
import com.pspdfkit.annotations.AnnotationType.POLYGON
import com.pspdfkit.annotations.AnnotationType.POLYLINE
import com.pspdfkit.annotations.AnnotationType.REDACT
import com.pspdfkit.annotations.AnnotationType.SOUND
import com.pspdfkit.annotations.AnnotationType.SQUARE
import com.pspdfkit.annotations.AnnotationType.SQUIGGLY
import com.pspdfkit.annotations.AnnotationType.STAMP
import com.pspdfkit.annotations.AnnotationType.STRIKEOUT
import com.pspdfkit.annotations.AnnotationType.UNDERLINE
import com.pspdfkit.annotations.LineEndType
import com.pspdfkit.annotations.configuration.AnnotationConfiguration
import com.pspdfkit.annotations.configuration.AnnotationProperty
Expand All @@ -33,7 +48,6 @@ import com.pspdfkit.annotations.configuration.SoundAnnotationConfiguration
import com.pspdfkit.annotations.configuration.StampAnnotationConfiguration
import com.pspdfkit.annotations.stamps.StampPickerItem
import com.pspdfkit.configuration.annotations.AnnotationAggregationStrategy
import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper
import com.pspdfkit.ui.fonts.Font
import com.pspdfkit.ui.inspector.views.BorderStylePreset
import com.pspdfkit.ui.special_mode.controller.AnnotationTool
Expand Down Expand Up @@ -69,8 +83,6 @@ const val MIN_TEXT_SIZE = "minimumFontSize"
const val MAX_TEXT_SIZE = "maximumFontSize"
const val DEFAULT_FONT = "fontName"
const val AVAILABLE_FONTS = "availableFonts"
const val DEFAULT_SCALE = "defaultScale"
const val DEFAULT_PRECISION = "defaultPrecision"
const val OVERLAY_TEXT = "overlayText"
const val REPEAT_OVERLAY_TEXT = "repeatOverlayText"

Expand Down Expand Up @@ -307,21 +319,6 @@ class AnnotationConfigurationAdaptor {
)
}

DEFAULT_SCALE -> (configuration[key] as Map<String, Any>?)?.let { scaleObject ->
val scale = MeasurementHelper.convertScale(scaleObject)
if (scale != null) {
builder.setDefaultScale(scale)
}
}

DEFAULT_PRECISION -> configuration[key].let { precisionString ->
val precision =
MeasurementHelper.convertPrecision(precisionString as String)
if (precision != null) {
builder.setDefaultPrecision(precision)
}
}

MAX_ALPHA -> builder.setMaxAlpha((configuration[key] as Double).toFloat())
MIN_ALPHA -> builder.setMinAlpha((configuration[key] as Double).toFloat())
MAX_THICKNESS -> builder.setMaxThickness((configuration[key] as Double).toFloat())
Expand Down Expand Up @@ -375,19 +372,6 @@ class AnnotationConfigurationAdaptor {
)
}

DEFAULT_SCALE -> configuration[key].let { scaleObject ->
val scale = MeasurementHelper.convertScale(scaleObject as Map<String, Any>)
if (scale != null)
builder.setDefaultScale(scale)
}

DEFAULT_PRECISION -> (configuration[key])?.let { precisionString ->
val precision =
MeasurementHelper.convertPrecision(precisionString as String)
if (precision != null)
builder.setDefaultPrecision(precision)
}

MAX_ALPHA -> builder.setMaxAlpha((configuration[key] as Double).toFloat())
MIN_ALPHA -> builder.setMinAlpha((configuration[key] as Double).toFloat())
MAX_THICKNESS -> builder.setMaxThickness((configuration[key] as Double).toFloat())
Expand Down Expand Up @@ -441,19 +425,6 @@ class AnnotationConfigurationAdaptor {
)
}

DEFAULT_SCALE -> (configuration[key] as Map<String, Any>?)?.let { scaleObject ->
val scale = MeasurementHelper.convertScale(scaleObject)
if (scale != null)
builder.setDefaultScale(scale)
}

DEFAULT_PRECISION -> configuration[key].let { precisionString ->
val precision =
MeasurementHelper.convertPrecision(precisionString as String)
if (precision != null)
builder.setDefaultPrecision(precision)
}

DEFAULT_LINE_END -> configuration[key].let { lineEndPair ->

builder.setDefaultLineEnds(extractLineEndPair(lineEndPair as String))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;

import com.pspdfkit.annotations.measurements.MeasurementValueConfiguration;
import com.pspdfkit.configuration.PdfConfiguration;
import com.pspdfkit.configuration.activity.PdfActivityConfiguration;
import com.pspdfkit.configuration.activity.ThumbnailBarMode;
Expand All @@ -29,13 +30,15 @@
import com.pspdfkit.configuration.settings.SettingsMenuItemType;
import com.pspdfkit.configuration.sharing.ShareFeatures;
import com.pspdfkit.configuration.theming.ThemeMode;
import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper;
import com.pspdfkit.preferences.PSPDFKitPreferences;
import com.pspdfkit.ui.special_mode.controller.AnnotationTool;

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

class ConfigurationAdapter {
private static final String LOG_TAG = "ConfigurationAdapter";
Expand Down Expand Up @@ -186,8 +189,7 @@ class ConfigurationAdapter {
private static final String ENABLED_MEASUREMENT_TOOLS = "enableMeasurementTools";
private static final String ENABLE_MAGNIFIER = "enableMagnifier";
private static final String ENABLED_MEASUREMENT_TOOL_SNAPPING = "enableMeasurementToolSnapping";



@NonNull
private final PdfActivityConfiguration.Builder configuration;
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package com.pspdfkit.flutter.pspdfkit

import android.os.Bundle
import com.pspdfkit.document.PdfDocument
import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper
import com.pspdfkit.instant.document.InstantPdfDocument
import com.pspdfkit.instant.exceptions.InstantException
import com.pspdfkit.instant.ui.InstantPdfActivity
Expand All @@ -21,6 +22,8 @@ import java.util.concurrent.atomic.AtomicReference
* activity.
*/
class FlutterInstantPdfActivity : InstantPdfActivity() {


override fun onCreate(bundle: Bundle?) {
super.onCreate(bundle)
bindActivity()
Expand All @@ -41,6 +44,11 @@ class FlutterInstantPdfActivity : InstantPdfActivity() {
super.onDocumentLoaded(pdfDocument)
val result = loadedDocumentResult.getAndSet(null)
result?.success(true)
measurementValueConfigurations?.forEach {
pdfFragment.let { fragment ->
MeasurementHelper.addMeasurementConfiguration(fragment, it)
}
}
}

override fun onDocumentLoadFailed(throwable: Throwable) {
Expand Down Expand Up @@ -99,6 +107,7 @@ class FlutterInstantPdfActivity : InstantPdfActivity() {
}

companion object {
private var measurementValueConfigurations:List<Map<String,Any>>? = null

@JvmStatic
var currentActivity: FlutterInstantPdfActivity? = null
Expand All @@ -110,5 +119,12 @@ class FlutterInstantPdfActivity : InstantPdfActivity() {
fun setLoadedDocumentResult(result: MethodChannel.Result?) {
loadedDocumentResult.set(result)
}

@JvmStatic
fun setMeasurementValueConfigurations(configurations: List<Map<String, Any>>?) {
measurementValueConfigurations = configurations
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.pspdfkit.annotations.measurements.MeasurementPrecision;
import com.pspdfkit.annotations.measurements.Scale;
import com.pspdfkit.document.PdfDocument;
import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper;
import com.pspdfkit.ui.PdfActivity;

import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

import io.flutter.plugin.common.MethodChannel.Result;

/**
Expand All @@ -23,19 +23,14 @@ public class FlutterPdfActivity extends PdfActivity {
@Nullable private static FlutterPdfActivity currentActivity;
@NonNull private static final AtomicReference<Result> loadedDocumentResult = new AtomicReference<>();

@Nullable private static Scale scale;
@Nullable private static MeasurementPrecision floatPrecision;
@Nullable private static List<Map<String,Object>> measurementValueConfigurations;

public static void setLoadedDocumentResult(Result result) {
loadedDocumentResult.set(result);
}

public static void setMeasurementScale(@Nullable final Scale scale) {
FlutterPdfActivity.scale = scale;
}

public static void setFloatPrecision(@Nullable final MeasurementPrecision floatPrecision) {
FlutterPdfActivity.floatPrecision = floatPrecision;
public static void setMeasurementValueConfigurations(@Nullable final List<Map<String,Object>> configurations) {
measurementValueConfigurations = configurations;
}

@Override
Expand Down Expand Up @@ -64,13 +59,10 @@ public void onDocumentLoaded(@NonNull PdfDocument pdfDocument) {
if (result != null) {
result.success(true);
}

if (scale != null) {
pdfDocument.setMeasurementScale(scale);
}

if (floatPrecision != null) {
pdfDocument.setMeasurementPrecision(floatPrecision);
if (measurementValueConfigurations != null && getPdfFragment() !=null) {
for (Map<String, Object> configuration : measurementValueConfigurations) {
MeasurementHelper.addMeasurementConfiguration(getPdfFragment(), configuration);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
package com.pspdfkit.flutter.pspdfkit

import com.pspdfkit.annotations.measurements.MeasurementPrecision
import com.pspdfkit.annotations.measurements.Scale
import com.pspdfkit.document.PdfDocument
import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper
import com.pspdfkit.ui.PdfUiFragment

class FlutterPdfUiFragment : PdfUiFragment() {

private var scale: Scale? = null
private var precision: MeasurementPrecision? = null

override fun onDocumentLoaded(document: PdfDocument) {
super.onDocumentLoaded(document)
// Notify the Flutter PSPDFKit plugin that the document has been loaded.
EventDispatcher.getInstance().notifyDocumentLoaded(document)
// We can register interest in newly created annotations so we can easily pick up measurement information.
if (scale != null) {
document.measurementScale = scale
}
if (precision != null) {
document.measurementPrecision = precision
}
}

fun setMeasurementScale(scale: Scale?) {
this.scale = scale
}

fun setMeasurementPrecision(precision: MeasurementPrecision?) {
this.precision = precision
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ package com.pspdfkit.flutter.pspdfkit
import android.content.Context
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.pspdfkit.annotations.measurements.MeasurementValueConfiguration
import com.pspdfkit.document.PdfDocument
import com.pspdfkit.flutter.pspdfkit.util.MeasurementHelper
import com.pspdfkit.listeners.SimpleDocumentListener
import com.pspdfkit.ui.PdfFragment

class FlutterPdfUiFragmentCallbacks: FragmentManager.FragmentLifecycleCallbacks() {

class FlutterPdfUiFragmentCallbacks(val measurementConfigurations: List<Map<String, Any>>?): FragmentManager.FragmentLifecycleCallbacks() {
final
override fun onFragmentAttached(
fm: FragmentManager,
f: Fragment,
context: Context
) {
if (f.tag?.contains("PSPDFKit.Fragment") == true) {
EventDispatcher.getInstance().notifyPdfFragmentAdded()
val pdfFragment = f as PdfFragment

pdfFragment.addDocumentListener( object : SimpleDocumentListener() {
override fun onDocumentLoaded(document: PdfDocument) {
if (measurementConfigurations == null) return
measurementConfigurations.forEach {
MeasurementHelper.addMeasurementConfiguration(pdfFragment, it)
}
}
})
}
}
}
Loading

0 comments on commit 12e4d5b

Please sign in to comment.