From 9fd73265340dd05f5a03b5949d7b9163b571b4b8 Mon Sep 17 00:00:00 2001 From: Leon Dudlik Date: Tue, 18 Apr 2023 15:04:39 +0200 Subject: [PATCH] Add version 2.17.0 --- CHANGELOG.md | 13 ++++ LICENSE.md | 2 +- README.md | 6 +- RNPhotoEditorSDK.podspec | 2 +- android/build.gradle | 2 +- android/src/main/AndroidManifest.xml | 1 + .../pesdk/RNPhotoEditorSDKModule.kt | 67 ++++++++++++------- configuration.ts | 9 +++ package.json | 4 +- 9 files changed, 74 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a5b085..b92de53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## [2.17.0] + +### Added + +* Added `configuration.singleToolMode` that skips main menu if only one tool is used. +* [react-native-videoeditorsdk] Added `RNVideoEditorSDKModule.editorWillOpenClosure` and `RNVideoEditorSDKModule.editorWillExportClosure` which allow further native configuration on Android. +* [react-native-photoeditorsdk] Added `RNPhotoEditorSDKModule.editorWillOpenClosure` and `RNPhotoEditorSDKModule.editorWillExportClosure` which allow further native configuration on Android. + +### Fixed + +* [react-native-videoeditorsdk] Fixed `VideoEditorResult.videoSize` would always be zero. +* [react-native-videoeditorsdk] Fixed error when not setting `Configuration.export.video.segments`. + ## [2.16.1] ### Fixed diff --git a/LICENSE.md b/LICENSE.md index d86fc14..e6acf57 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -4,7 +4,7 @@ In order to run any samples or use any wrapper without a watermark, you'll have to purchase a commercial PhotoEditor SDK or VideoEditor SDK license. Visit https://img.ly for more details. -Copyright (c) 2014-2022, img.ly GmbH +Copyright (c) 2014-2023, img.ly GmbH All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 863d3fa..debcdc6 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ In order to use this module with the Expo CLI you can make use of our integrated "react-native-imglysdk", { "android": { - "version": "10.4.0", + "version": "10.4.1", "modules": [ "ui:core", "ui:transform", @@ -161,12 +161,12 @@ For older React Native versions autolinking is not available and PhotoEditor SDK } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.32" - classpath 'ly.img.android.sdk:plugin:10.4.0' + classpath 'ly.img.android.sdk:plugin:10.4.1' } } ``` - In order to update PhotoEditor SDK for Android replace the version string `10.4.0` with a [newer release](https://github.com/imgly/pesdk-android-demo/releases). + In order to update PhotoEditor SDK for Android replace the version string `10.4.1` with a [newer release](https://github.com/imgly/pesdk-android-demo/releases). 2. Still in the `android/build.gradle` file (**not** `android/app/build.gradle`), add these lines at the bottom: diff --git a/RNPhotoEditorSDK.podspec b/RNPhotoEditorSDK.podspec index c06e4fd..4ae7652 100644 --- a/RNPhotoEditorSDK.podspec +++ b/RNPhotoEditorSDK.podspec @@ -18,5 +18,5 @@ Pod::Spec.new do |s| s.dependency 'React' s.dependency 'React-RCTImage' - s.dependency 'PhotoEditorSDK', '~> 11.3' + s.dependency 'PhotoEditorSDK', '~> 11.4' end diff --git a/android/build.gradle b/android/build.gradle index 455ba6e..6ff4da8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -20,7 +20,7 @@ imglyConfig { } } -def MIN_LY_IMG_ANDROID_SDK_PLUGIN_VERSION = "10.4.0" +def MIN_LY_IMG_ANDROID_SDK_PLUGIN_VERSION = "10.4.1" task checkVersion { if (imglyConfig.convertToVersionNumber(imglyConfig.getVersion()) < imglyConfig.convertToVersionNumber(MIN_LY_IMG_ANDROID_SDK_PLUGIN_VERSION)) { diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index a49375a..031556d 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ android:exported="false" android:enabled="false" android:name="ly.img.android.IMGLYAutoInit" /> + \ No newline at end of file diff --git a/android/src/main/java/ly/img/react_native/pesdk/RNPhotoEditorSDKModule.kt b/android/src/main/java/ly/img/react_native/pesdk/RNPhotoEditorSDKModule.kt index e542d2e..02ec3e9 100644 --- a/android/src/main/java/ly/img/react_native/pesdk/RNPhotoEditorSDKModule.kt +++ b/android/src/main/java/ly/img/react_native/pesdk/RNPhotoEditorSDKModule.kt @@ -4,6 +4,7 @@ import android.app.Activity import android.content.Intent import android.net.Uri import android.util.Log +import androidx.annotation.WorkerThread import com.facebook.react.bridge.* import ly.img.android.IMGLY import ly.img.android.PESDK @@ -23,6 +24,8 @@ import org.json.JSONObject import java.io.File import ly.img.android.pesdk.backend.encoder.Encoder import ly.img.android.pesdk.backend.model.EditorSDKResult +import ly.img.android.pesdk.backend.model.state.manager.StateHandler +import ly.img.android.pesdk.ui.activity.PhotoEditorActivity import ly.img.android.serializer._3.IMGLYFileReader import ly.img.android.serializer._3.IMGLYFileWriter import java.util.UUID @@ -31,12 +34,17 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC companion object { // This number must be unique. It is public to allow client code to change it if the same value is used elsewhere. - var EDITOR_RESULT_ID = 29064 + @JvmField var EDITOR_RESULT_ID = 29064 + + /** A closure to modify a *PhotoEditorSettingsList* before the editor is opened. */ + @JvmField var editorWillOpenClosure: ((settingsList: PhotoEditorSettingsList) -> Unit)? = null + + /** A closure allowing access to the *StateHandler* before the editor is exporting. */ + @JvmField var editorWillExportClosure: ((stateHandler: StateHandler) -> Unit)? = null } init { reactContext.addActivityEventListener(this) - } private var currentPromise: Promise? = null @@ -50,9 +58,9 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, intent: Intent?) { val data = try { - intent?.let { EditorSDKResult(it) } + intent?.let { EditorSDKResult(it) } } catch (e: EditorSDKResult.NotAnImglyResultException) { - null + null } ?: return // If data is null the result is not from us. when (requestCode) { @@ -81,16 +89,16 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC val uri = serializationConfig.filename?.let { Uri.parse("$it.json") } ?: Uri.fromFile(File.createTempFile("serialization-" + UUID.randomUUID().toString(), ".json")) - Encoder.createOutputStream(uri).use { outputStream -> + Encoder.createOutputStream(uri).use { outputStream -> IMGLYFileWriter(settingsList).writeJson(outputStream) } uri.toString() } SerializationExportType.OBJECT -> { ReactJSON.convertJsonToMap( - JSONObject( - IMGLYFileWriter(settingsList).writeJsonAsString() - ) + JSONObject( + IMGLYFileWriter(settingsList).writeJsonAsString() + ) ) } } @@ -102,18 +110,18 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC } currentPromise?.resolve( - reactMap( - "image" to when (currentConfig?.export?.image?.exportType) { - ImageExportType.DATA_URL -> resultPath?.let { - val imageSource = ImageSource.create(it) - "data:${imageSource.imageFormat.mimeType};base64,${imageSource.asBase64}" - } - ImageExportType.FILE_URL -> resultPath?.toString() - else -> resultPath?.toString() - }, - "hasChanges" to (sourcePath?.path != resultPath?.path), - "serialization" to serialization - ) + reactMap( + "image" to when (currentConfig?.export?.image?.exportType) { + ImageExportType.DATA_URL -> resultPath?.let { + val imageSource = ImageSource.create(it) + "data:${imageSource.imageFormat.mimeType};base64,${imageSource.asBase64}" + } + ImageExportType.FILE_URL -> resultPath?.toString() + else -> resultPath?.toString() + }, + "hasChanges" to (sourcePath?.path != resultPath?.path), + "serialization" to serialization + ) ) }() } @@ -156,7 +164,9 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC startEditor(settingsList) } - private fun readSerialisation(settingsList: SettingsList, serialization: String?, readImage: Boolean) { + private fun readSerialisation(settingsList: PhotoEditorSettingsList, serialization: String?, readImage: Boolean) { + editorWillOpenClosure?.invoke(settingsList) + if (serialization != null) { skipIfNotExists { IMGLYFileReader(settingsList).also { @@ -170,9 +180,9 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC val currentActivity = this.currentActivity ?: throw RuntimeException("Can't start the Editor because there is no current activity") if (settingsList != null) { MainThreadRunnable { - PhotoEditorBuilder(currentActivity) - .setSettingsList(settingsList) - .startActivityForResult(currentActivity, EDITOR_RESULT_ID) + PhotoEditorBuilder(currentActivity, RNPhotoEditorSDKActivity::class.java) + .setSettingsList(settingsList) + .startActivityForResult(currentActivity, EDITOR_RESULT_ID) settingsList.release() }() } @@ -277,5 +287,14 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC } override fun getName() = "RNPhotoEditorSDK" +} +/** A *PhotoEditorActivity* used for the native interfaces. */ +class RNPhotoEditorSDKActivity: PhotoEditorActivity() { + @WorkerThread + override fun onExportStart(stateHandler: StateHandler) { + RNPhotoEditorSDKModule.editorWillExportClosure?.invoke(stateHandler) + + super.onExportStart(stateHandler) + } } \ No newline at end of file diff --git a/configuration.ts b/configuration.ts index e10b785..dda7297 100644 --- a/configuration.ts +++ b/configuration.ts @@ -24,6 +24,15 @@ export interface Configuration { */ forceCrop?: boolean; + /** + * Controls if the editor is used in single tool mode. + * Prerequisite is that only one tool is in `tools`. + * + * @example // Defaults to: + * true + */ + singleToolMode?: boolean; + /** * Defines all allowed actions for the main screen that are displayed as overlay buttons on the canvas. * Only buttons for allowed actions are visible. diff --git a/package.json b/package.json index fe49e0e..93e7d05 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-native-photoeditorsdk", "title": "React Native module for PhotoEditor SDK", - "version": "2.16.1", + "version": "2.17.0", "description": "A React Native module for PhotoEditor SDK. Integrate the photo editor into your own HTML5, iOS or Android app - in minutes!", "main": "index.js", "typings": "index.d.ts", @@ -38,6 +38,6 @@ "react-native": ">=0.60.0 <1.0.x" }, "dependencies": { - "react-native-imglysdk": "2.16.1" + "react-native-imglysdk": "2.17.0" } }