Skip to content

Commit

Permalink
Add version 2.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leontobias committed Apr 18, 2023
1 parent b9592f4 commit 9fd7326
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 32 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion RNPhotoEditorSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 1 addition & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
android:exported="false"
android:enabled="false"
android:name="ly.img.android.IMGLYAutoInit" />
<activity android:name=".RNPhotoEditorSDKActivity" />
</application>
</manifest>

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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()
)
)
}
}
Expand All @@ -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
)
)
}()
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}()
}
Expand Down Expand Up @@ -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)
}
}
9 changes: 9 additions & 0 deletions configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}

0 comments on commit 9fd7326

Please sign in to comment.