Skip to content

Commit 9fd7326

Browse files
committed
Add version 2.17.0
1 parent b9592f4 commit 9fd7326

9 files changed

+74
-32
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## [2.17.0]
2+
3+
### Added
4+
5+
* Added `configuration.singleToolMode` that skips main menu if only one tool is used.
6+
* [react-native-videoeditorsdk] Added `RNVideoEditorSDKModule.editorWillOpenClosure` and `RNVideoEditorSDKModule.editorWillExportClosure` which allow further native configuration on Android.
7+
* [react-native-photoeditorsdk] Added `RNPhotoEditorSDKModule.editorWillOpenClosure` and `RNPhotoEditorSDKModule.editorWillExportClosure` which allow further native configuration on Android.
8+
9+
### Fixed
10+
11+
* [react-native-videoeditorsdk] Fixed `VideoEditorResult.videoSize` would always be zero.
12+
* [react-native-videoeditorsdk] Fixed error when not setting `Configuration.export.video.segments`.
13+
114
## [2.16.1]
215

316
### Fixed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In order to run any samples or use any wrapper without a watermark,
44
you'll have to purchase a commercial PhotoEditor SDK or VideoEditor SDK
55
license. Visit https://img.ly for more details.
66

7-
Copyright (c) 2014-2022, img.ly GmbH
7+
Copyright (c) 2014-2023, img.ly GmbH
88
All rights reserved.
99

1010
Redistribution and use in source and binary forms, with or without

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ In order to use this module with the Expo CLI you can make use of our integrated
8686
"react-native-imglysdk",
8787
{
8888
"android": {
89-
"version": "10.4.0",
89+
"version": "10.4.1",
9090
"modules": [
9191
"ui:core",
9292
"ui:transform",
@@ -161,12 +161,12 @@ For older React Native versions autolinking is not available and PhotoEditor SDK
161161
}
162162
dependencies {
163163
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.32"
164-
classpath 'ly.img.android.sdk:plugin:10.4.0'
164+
classpath 'ly.img.android.sdk:plugin:10.4.1'
165165
}
166166
}
167167
```
168168

169-
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).
169+
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).
170170

171171
2. Still in the `android/build.gradle` file (**not** `android/app/build.gradle`), add these lines at the bottom:
172172

RNPhotoEditorSDK.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ Pod::Spec.new do |s|
1818

1919
s.dependency 'React'
2020
s.dependency 'React-RCTImage'
21-
s.dependency 'PhotoEditorSDK', '~> 11.3'
21+
s.dependency 'PhotoEditorSDK', '~> 11.4'
2222
end

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ imglyConfig {
2020
}
2121
}
2222

23-
def MIN_LY_IMG_ANDROID_SDK_PLUGIN_VERSION = "10.4.0"
23+
def MIN_LY_IMG_ANDROID_SDK_PLUGIN_VERSION = "10.4.1"
2424

2525
task checkVersion {
2626
if (imglyConfig.convertToVersionNumber(imglyConfig.getVersion()) < imglyConfig.convertToVersionNumber(MIN_LY_IMG_ANDROID_SDK_PLUGIN_VERSION)) {

android/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
android:exported="false"
99
android:enabled="false"
1010
android:name="ly.img.android.IMGLYAutoInit" />
11+
<activity android:name=".RNPhotoEditorSDKActivity" />
1112
</application>
1213
</manifest>
1314

android/src/main/java/ly/img/react_native/pesdk/RNPhotoEditorSDKModule.kt

+43-24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.app.Activity
44
import android.content.Intent
55
import android.net.Uri
66
import android.util.Log
7+
import androidx.annotation.WorkerThread
78
import com.facebook.react.bridge.*
89
import ly.img.android.IMGLY
910
import ly.img.android.PESDK
@@ -23,6 +24,8 @@ import org.json.JSONObject
2324
import java.io.File
2425
import ly.img.android.pesdk.backend.encoder.Encoder
2526
import ly.img.android.pesdk.backend.model.EditorSDKResult
27+
import ly.img.android.pesdk.backend.model.state.manager.StateHandler
28+
import ly.img.android.pesdk.ui.activity.PhotoEditorActivity
2629
import ly.img.android.serializer._3.IMGLYFileReader
2730
import ly.img.android.serializer._3.IMGLYFileWriter
2831
import java.util.UUID
@@ -31,12 +34,17 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC
3134

3235
companion object {
3336
// This number must be unique. It is public to allow client code to change it if the same value is used elsewhere.
34-
var EDITOR_RESULT_ID = 29064
37+
@JvmField var EDITOR_RESULT_ID = 29064
38+
39+
/** A closure to modify a *PhotoEditorSettingsList* before the editor is opened. */
40+
@JvmField var editorWillOpenClosure: ((settingsList: PhotoEditorSettingsList) -> Unit)? = null
41+
42+
/** A closure allowing access to the *StateHandler* before the editor is exporting. */
43+
@JvmField var editorWillExportClosure: ((stateHandler: StateHandler) -> Unit)? = null
3544
}
3645

3746
init {
3847
reactContext.addActivityEventListener(this)
39-
4048
}
4149

4250
private var currentPromise: Promise? = null
@@ -50,9 +58,9 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC
5058

5159
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, intent: Intent?) {
5260
val data = try {
53-
intent?.let { EditorSDKResult(it) }
61+
intent?.let { EditorSDKResult(it) }
5462
} catch (e: EditorSDKResult.NotAnImglyResultException) {
55-
null
63+
null
5664
} ?: return // If data is null the result is not from us.
5765

5866
when (requestCode) {
@@ -81,16 +89,16 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC
8189
val uri = serializationConfig.filename?.let {
8290
Uri.parse("$it.json")
8391
} ?: Uri.fromFile(File.createTempFile("serialization-" + UUID.randomUUID().toString(), ".json"))
84-
Encoder.createOutputStream(uri).use { outputStream ->
92+
Encoder.createOutputStream(uri).use { outputStream ->
8593
IMGLYFileWriter(settingsList).writeJson(outputStream)
8694
}
8795
uri.toString()
8896
}
8997
SerializationExportType.OBJECT -> {
9098
ReactJSON.convertJsonToMap(
91-
JSONObject(
92-
IMGLYFileWriter(settingsList).writeJsonAsString()
93-
)
99+
JSONObject(
100+
IMGLYFileWriter(settingsList).writeJsonAsString()
101+
)
94102
)
95103
}
96104
}
@@ -102,18 +110,18 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC
102110
}
103111

104112
currentPromise?.resolve(
105-
reactMap(
106-
"image" to when (currentConfig?.export?.image?.exportType) {
107-
ImageExportType.DATA_URL -> resultPath?.let {
108-
val imageSource = ImageSource.create(it)
109-
"data:${imageSource.imageFormat.mimeType};base64,${imageSource.asBase64}"
110-
}
111-
ImageExportType.FILE_URL -> resultPath?.toString()
112-
else -> resultPath?.toString()
113-
},
114-
"hasChanges" to (sourcePath?.path != resultPath?.path),
115-
"serialization" to serialization
116-
)
113+
reactMap(
114+
"image" to when (currentConfig?.export?.image?.exportType) {
115+
ImageExportType.DATA_URL -> resultPath?.let {
116+
val imageSource = ImageSource.create(it)
117+
"data:${imageSource.imageFormat.mimeType};base64,${imageSource.asBase64}"
118+
}
119+
ImageExportType.FILE_URL -> resultPath?.toString()
120+
else -> resultPath?.toString()
121+
},
122+
"hasChanges" to (sourcePath?.path != resultPath?.path),
123+
"serialization" to serialization
124+
)
117125
)
118126
}()
119127
}
@@ -156,7 +164,9 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC
156164
startEditor(settingsList)
157165
}
158166

159-
private fun readSerialisation(settingsList: SettingsList, serialization: String?, readImage: Boolean) {
167+
private fun readSerialisation(settingsList: PhotoEditorSettingsList, serialization: String?, readImage: Boolean) {
168+
editorWillOpenClosure?.invoke(settingsList)
169+
160170
if (serialization != null) {
161171
skipIfNotExists {
162172
IMGLYFileReader(settingsList).also {
@@ -170,9 +180,9 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC
170180
val currentActivity = this.currentActivity ?: throw RuntimeException("Can't start the Editor because there is no current activity")
171181
if (settingsList != null) {
172182
MainThreadRunnable {
173-
PhotoEditorBuilder(currentActivity)
174-
.setSettingsList(settingsList)
175-
.startActivityForResult(currentActivity, EDITOR_RESULT_ID)
183+
PhotoEditorBuilder(currentActivity, RNPhotoEditorSDKActivity::class.java)
184+
.setSettingsList(settingsList)
185+
.startActivityForResult(currentActivity, EDITOR_RESULT_ID)
176186
settingsList.release()
177187
}()
178188
}
@@ -277,5 +287,14 @@ class RNPhotoEditorSDKModule(val reactContext: ReactApplicationContext) : ReactC
277287
}
278288

279289
override fun getName() = "RNPhotoEditorSDK"
290+
}
280291

292+
/** A *PhotoEditorActivity* used for the native interfaces. */
293+
class RNPhotoEditorSDKActivity: PhotoEditorActivity() {
294+
@WorkerThread
295+
override fun onExportStart(stateHandler: StateHandler) {
296+
RNPhotoEditorSDKModule.editorWillExportClosure?.invoke(stateHandler)
297+
298+
super.onExportStart(stateHandler)
299+
}
281300
}

configuration.ts

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ export interface Configuration {
2424
*/
2525
forceCrop?: boolean;
2626

27+
/**
28+
* Controls if the editor is used in single tool mode.
29+
* Prerequisite is that only one tool is in `tools`.
30+
*
31+
* @example // Defaults to:
32+
* true
33+
*/
34+
singleToolMode?: boolean;
35+
2736
/**
2837
* Defines all allowed actions for the main screen that are displayed as overlay buttons on the canvas.
2938
* Only buttons for allowed actions are visible.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-photoeditorsdk",
33
"title": "React Native module for PhotoEditor SDK",
4-
"version": "2.16.1",
4+
"version": "2.17.0",
55
"description": "A React Native module for PhotoEditor SDK. Integrate the photo editor into your own HTML5, iOS or Android app - in minutes!",
66
"main": "index.js",
77
"typings": "index.d.ts",
@@ -38,6 +38,6 @@
3838
"react-native": ">=0.60.0 <1.0.x"
3939
},
4040
"dependencies": {
41-
"react-native-imglysdk": "2.16.1"
41+
"react-native-imglysdk": "2.17.0"
4242
}
4343
}

0 commit comments

Comments
 (0)