From 587a3afb912a9375328cca7644d7cfffe2c437b2 Mon Sep 17 00:00:00 2001
From: Prempal Singh
Date: Mon, 4 Apr 2022 18:06:51 +0530
Subject: [PATCH] release/10.0.0 (#83)
* Update from https://github.com/imgly-labs/pesdk/commit/79b238013382fb4dfdf2aaa6006374e130fad96b
* bump version to 10.0.0
* Update README.md
* Update README.md
* downgrade buildToolsVersion
Co-authored-by: imgly-bot <47853486+imgly-bot@users.noreply.github.com>
---
CHANGELOG.md | 37 +-
README.md | 361 ++++++++----------
app/build.gradle | 4 +-
.../android/app/KEditorDemoActivity.kt | 50 +--
build.gradle | 4 +-
example_brush_presets_panel/build.gradle | 6 +-
.../android/app/KEditorDemoActivity.kt | 38 +-
7 files changed, 243 insertions(+), 257 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1294fdc3..01a38275 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,41 @@
# PhotoEditor SDK - Changelog
+## v10.0.0
+
+### Changed
+
+* Bumped `minSdkVersion` to 21.
+* Bumped `compileSdkVersion` to 31 and `buildToolsVersion` to 31.0.0.
+* Our activities now extend from `AppCompatActivity` instead of `Activity`.
+* `PESDKMobileUIDefaultTheme` is now `Theme.Imgly`.
+* `Imgly.Theme` is now `Theme.Imgly`.
+* `RoxOperation::onReleaseOperator()` renamed to `RoxOperation::onOperatorReleased()`.
+* `startActivityForBroadcast()` is deprecated. Use `DocumentRenderWorker` instead.
+* `ly.img.android.pesdk.backend.model.state.VideoCompositionSettings.VideoPart` deprecated in favor of `ly.img.android.pesdk.backend.model.VideoPart`.
+* `VideoCompositionSettings.Event.VIDEO_SELECTED` deprecated in favor of `VideoState.Event.VIDEO_SELECTED`.
+* `EditorBuilder::startActivityForResult()` is now in sync with `PhotoEditorBuilder::startActivityForResult()` and `VideoEditorBuilder::startActivityForResult()` and doesn't ask for any permissions.
+* Certain parameters in the following functions were incorrectly declared as nullable which could lead to a `RuntimeException`. They are now non-null.
+ * `ImglyIntent::startActivityForBroadcast()`.
+ * `PhotoEditorBuilder::startActivityForBroadcast()`.
+ * `VideoEditorBuilder::startActivityForBroadcast()` and `VideoEditorBuilder::startActivityForResult()`.
+ * `EditorBuilder` and its subclasses' constructors.
+
+### Added
+
+* Light(`Theme.Imgly.Light`) theme variant.
+* Batch background renderer.
+* New constructor in `PhotoEditorBuilder` and `VideoEditorBuilder` to open a custom `Activity`.
+
+### Fixed
+* Audio surge.
+* A couple of Video crashes.
+* Unable to replace sticker sometimes.
+* Serialisation compatibility issues with iOS/Web.
+* Time units used in "Video too short" dialog are now translatable (`imgly_hour_unit`, `imgly_minute_unit`, etc.).
+* Blinking effect when image/video is loaded in the editor.
+ * 🚨 `android:windowBackground` now refers to `?attr/imgly_background_color`.
+* Close Editor alert message adjusted based on PE/VE SDK (`pesdk_editor_text_closeImageEditorAlert`, `pesdk_editor_text_closeVideoEditorAlert`).
+
## v9.2.0
### Added
@@ -23,7 +59,6 @@
* Missing filter categories thumbnail for existing categories.
* Export hangs if the audio track is unsupported or broken.
* Those tracks that can't be decoded, such as ALAC (Apple Lossless Audio Codec) encoded tracks, are ignored.
-
## v9.1.1
diff --git a/README.md b/README.md
index 6f040ad1..97d0ee06 100644
--- a/README.md
+++ b/README.md
@@ -9,14 +9,14 @@
-
-
+
+
-
+
@@ -64,7 +64,7 @@ Please [get in touch](https://img.ly/pricing/?utm_campaign=Projects&utm_source=G
* A clean and intuitive **UI** that ensures an unhindered flow of creativity and a seamless experience while composing creatives. The UI is designed to be customized to completely match your CI and blend with your app.
* You can strip out every feature you deem unnecessary to provide your users with the exact feature set your use case requires.
-* __Android API Level 16+__ Covers nearly 99% of all Android devices with touchscreen.
+* __Android API Level 21+__ Covers nearly 98% of all Android devices with touchscreen.
* __Fast image export up to 4294 MegaPixel__
* __Generic camera support__ for most Android phones.
* __Tablet support__: The PhotoEditor SDK uses auto layout for its views and adapts to each screen size.
@@ -95,7 +95,7 @@ img.ly GmbH, [@imgly](https://twitter.com/imgly), [img.ly](https://img.ly/?utm_c
## Installation
-> This SDK requires a minimum deployment target of Android API 15 (4.0.4) with OpenGl ES 2.0 supported Device but our official support is starting with API 16 (4.1.0)
+> The PhotoEditor SDK supports Android 5.0+ API 21 as the `minSdkVersion`, but it must be compiled with `compileSdkVersion` 31+.
## Add your license file
@@ -119,13 +119,13 @@ buildscript {
maven { url "https://artifactory.img.ly/artifactory/imgly" }
}
dependencies {
- classpath 'ly.img.android.pesdk:plugin:9.2.0'
+ classpath 'ly.img.android.pesdk:plugin:10.0.0'
}
}
```
-You will have to add the pesdk plugin and PESDKConfig into your module's `build.gradle` file:
+Apply the img.ly plugin and add the imglyConfig block into your module's `build.gradle` file:
```groovy
// Apply the Android Plugin
@@ -179,11 +179,11 @@ imglyConfig {
// Do your Android Configurations... ex.
android {
- /* Set the compile SDK and the Build SDK min. at SDK 29 or grater.
- * We can't provide support for Bugs, that are the result of older SDK versions.
+ /* Set the compileSdkVersion at 31 or greater and set the buildToolsVersion at '31.0.0' or greater.
+ * We can't provide support for bugs, that are the result of older SDK versions.
*/
- compileSdkVersion 29
- buildToolsVersion '29.0.2'
+ compileSdkVersion 31
+ buildToolsVersion '31.0.0'
defaultConfig {
/*
@@ -192,8 +192,8 @@ android {
*/
applicationId "my.domain.application"
- /* Set the minimum supported SDK Version to 16 (Android 4.1.0) or higher */
- minSdkVersion 16
+ /* Set the minimum supported SDK Version to 21 (Android 5.0) or higher */
+ minSdkVersion 21
/* Set the target SDK Version at minimum to 29 or higher */
targetSdkVersion 29
@@ -224,248 +224,225 @@ __Please take a look at the hint in the next step in order to integrate the Andr
## Integration
-In order to open the camera preview and pass the resulting image to the editor, create a
-`CameraPreviewBuilder` and start the `CameraPreviewActivity` with `startActivityForResult(activity, custom_id)`:
+### Start Editor standalone
-> __Please make sure you delegate the `onRequestPermissionsResult` to `PermissionRequest.onRequestPermissionsResult`
-as demonstrated in the following example. This ensures correct behavior on Android 6.0 and above.__
+If you want to open the editor directly with an existing image look at this example:
-```java
-public class CameraDemoActivity extends Activity implements PermissionRequest.Response {
+```kotlin
+class KEditorDemoActivity : Activity() {
- // Important permission request for Android 6.0 and above, don't forget to add this!
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- PermissionRequest.onRequestPermissionsResult(requestCode, permissions, grantResults);
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ companion object {
+ const val PESDK_RESULT = 1
+ const val GALLERY_RESULT = 2
}
- @Override
- public void permissionGranted() {}
-
- @Override
- public void permissionDenied() {
- /* TODO: The Permission was rejected by the user. The Editor was not opened,
- * Show a hint to the user and try again. */
+ // Create a empty new SettingsList and apply the changes on this reference.
+ // If you include our asset Packs and use our UI you also need to add them to the UI Config,
+ // otherwise they are only available for the backend (like Serialisation)
+ // See the specific feature sections of our guides if you want to know how to add your own Assets.
+ private fun createPESDKSettingsList() =
+ PhotoEditorSettingsList(true)
+ .configure {
+ it.setFilterList(FilterPackBasic.getFilterPack())
+ }
+ .configure {
+ it.setFontList(FontPackBasic.getFontPack())
+ }
+ .configure {
+ it.setFrameList(FramePackBasic.getFramePack())
+ }
+ .configure {
+ it.setOverlayList(OverlayPackBasic.getOverlayPack())
+ }
+ .configure {
+ it.setStickerLists(
+ StickerPackEmoticons.getStickerCategory(),
+ StickerPackShapes.getStickerCategory()
+ )
+ }
+ .configure {
+ it.setOutputToGallery(Environment.DIRECTORY_DCIM)
+ }
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ openSystemGalleryToSelectAnImage()
}
- public static int PESDK_RESULT = 1;
-
- private PhotoEditorSettingsList createPesdkSettingsList() {
-
- // Create a empty new SettingsList and apply the changes on this referance.
- PhotoEditorSettingsList settingsList = new PhotoEditorSettingsList();
-
- // If you include our asset Packs and you use our UI you also need to add them to the UI,
- // otherwise they are only available for the backend
- // See the specific feature sections of our guides if you want to know how to add our own Assets.
-
- settingsList.getSettingsModel(UiConfigFilter.class).setFilterList(
- FilterPackBasic.getFilterPack()
- );
-
- settingsList.getSettingsModel(UiConfigText.class).setFontList(
- FontPackBasic.getFontPack()
- );
-
- settingsList.getSettingsModel(UiConfigFrame.class).setFrameList(
- FramePackBasic.getFramePack()
- );
-
- settingsList.getSettingsModel(UiConfigOverlay.class).setOverlayList(
- OverlayPackBasic.getOverlayPack()
- );
-
- settingsList.getSettingsModel(UiConfigSticker.class).setStickerLists(
- StickerPackEmoticons.getStickerCategory(),
- StickerPackShapes.getStickerCategory()
- );
-
- return settingsList;
+ fun openSystemGalleryToSelectAnImage() {
+ val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
+ try {
+ startActivityForResult(intent, GALLERY_RESULT)
+ } catch (ex: ActivityNotFoundException) {
+ Toast.makeText(
+ this,
+ "No Gallery APP installed",
+ Toast.LENGTH_LONG
+ ).show()
+ }
}
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
+ fun openEditor(inputImage: Uri?) {
+ val settingsList = createPESDKSettingsList()
+
+ settingsList.configure {
+ it.source = inputImage
+ }
- openCamera();
+ PhotoEditorBuilder(this)
+ .setSettingsList(settingsList)
+ .startActivityForResult(this, PESDK_RESULT)
+
+ settingsList.release()
}
- private void openCamera() {
- PhotoEditorSettingsList settingsList = createPesdkSettingsList();
- new CameraPreviewBuilder(this)
- .setSettingsList(settingsList)
- .startActivityForResult(this, PESDK_RESULT, PermissionRequest.NEEDED_PREVIEW_PERMISSIONS_AND_FINE_LOCATION);
- }
+ override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {
+ super.onActivityResult(requestCode, resultCode, intent)
- @Override
- protected void onActivityResult(int requestCode, int resultCode, android.content.Intent intent) {
- super.onActivityResult(requestCode, resultCode, intent);
+ if (resultCode == RESULT_OK && requestCode == GALLERY_RESULT) {
+ // Open Editor with some uri in this case with an image selected from the system gallery.
+ openEditor(intent.data)
- if (resultCode == RESULT_OK && requestCode == PESDK_RESULT) {
+ } else if (resultCode == RESULT_OK && requestCode == PESDK_RESULT) {
// Editor has saved an Image.
- EditorSDKResult data = new EditorSDKResult(intent);
+ val data = EditorSDKResult(intent)
- data.notifyGallery(EditorSDKResult.UPDATE_RESULT & EditorSDKResult.UPDATE_SOURCE);
-
- Log.i("PESDK", "Source image is located here " + data.getSourceUri());
- Log.i("PESDK", "Result image is located here " + data.getResultUri());
+ Log.i("PESDK", "Source image is located here ${data.sourceUri}")
+ Log.i("PESDK", "Result image is located here ${data.resultUri}")
// TODO: Do something with the result image
// OPTIONAL: read the latest state to save it as a serialisation
- SettingsList lastState = data.getSettingsList();
+ val lastState = data.settingsList
try {
- new IMGLYFileWriter(lastState).writeJson(new File(
- Environment.getExternalStorageDirectory(),
- "serialisationReadyToReadWithPESDKFileReader.json"
- ));
- } catch (IOException e) { e.printStackTrace(); }
+ IMGLYFileWriter(lastState).writeJson(File(
+ getExternalFilesDir(null),
+ "serialisationReadyToReadWithPESDKFileReader.json"
+ ))
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ lastState.release()
} else if (resultCode == RESULT_CANCELED && requestCode == PESDK_RESULT) {
// Editor was canceled
- EditorSDKResult data = new EditorSDKResult(intent);
+ val data = EditorSDKResult(intent)
- Uri sourceURI = data.getSourceUri();
- // TODO: Do something...
+ val sourceURI = data.sourceUri
+ // TODO: Do something with the source...
}
}
}
```
-### Start Editor standalone (without camera).
+### Start Editor (with camera)
-If you want to open the editor directly with an existing image look at this example:
+In order to open the camera preview and pass the resulting image to the editor, create a
+[`CameraPreviewBuilder`](https://img.ly/docs/pesdk/apidocs/android/v10/pesdk-mobile_ui-camera/ly.img.android.pesdk.ui.activity/-camera-preview-builder/index.html) and start the [`CameraPreviewActivity`](https://img.ly/docs/pesdk/apidocs/android/v10/pesdk-mobile_ui-camera/ly.img.android.pesdk.ui.activity/-camera-preview-activity/index.html) with [`startActivityForResult(android.app.Activity, int)`](https://img.ly/docs/pesdk/apidocs/android/v10/pesdk-mobile_ui-camera/ly.img.android.pesdk.ui.activity/-camera-preview-builder/index.html#1501569930%2FFunctions%2F-594191830):
-```java
-public class EditorDemoActivity extends Activity implements PermissionRequest.Response {
+The camera module requires two permissions: The "_Write access to external storage_" and the "_Camera_" permission.
+You can grant these permissions yourself otherwise the SDK will automatically grant these permissions.
- // Important permission request for Android 6.0 and above, don't forget to add this!
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- PermissionRequest.onRequestPermissionsResult(requestCode, permissions, grantResults);
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
+> **Please make sure you delegate the [`onRequestPermissionsResult()`](https://developer.android.com/reference/android/app/Activity#onRequestPermissionsResult(int,%20java.lang.String[],%20int[])) to [`PermissionRequest.onRequestPermissionsResult()`](https://img.ly/docs/pesdk/apidocs/android/v10/pesdk-backend-core/ly.img.android.pesdk.ui.utils/-permission-request/index.html#-390511216%2FFunctions%2F-68773581)
+> as demonstrated in the following example. This ensures correct behavior on Android 6.0 and above.**
- @Override
- public void permissionGranted() {}
+```kotlin
+class KCameraDemoActivity : Activity(), PermissionRequest.Response {
- @Override
- public void permissionDenied() {
- /* TODO: The Permission was rejected by the user. The Editor was not opened,
- * Show a hint to the user and try again. */
+ companion object {
+ const val PESDK_RESULT = 1
}
- public static int PESDK_RESULT = 1;
- public static int GALLERY_RESULT = 2;
-
- private SettingsList createPesdkSettingsList() {
-
- // Create a empty new SettingsList and apply the changes on this referance.
- PhotoEditorSettingsList settingsList = new PhotoEditorSettingsList();
-
- // If you include our asset Packs and you use our UI you also need to add them to the UI,
- // otherwise they are only available for the backend
- // See the specific feature sections of our guides if you want to know how to add our own Assets.
-
- settingsList.getSettingsModel(UiConfigFilter.class).setFilterList(
- FilterPackBasic.getFilterPack()
- );
-
- settingsList.getSettingsModel(UiConfigText.class).setFontList(
- FontPackBasic.getFontPack()
- );
-
- settingsList.getSettingsModel(UiConfigFrame.class).setFrameList(
- FramePackBasic.getFramePack()
- );
-
- settingsList.getSettingsModel(UiConfigOverlay.class).setOverlayList(
- OverlayPackBasic.getOverlayPack()
- );
-
- settingsList.getSettingsModel(UiConfigSticker.class).setStickerLists(
- StickerPackEmoticons.getStickerCategory(),
- StickerPackShapes.getStickerCategory()
- );
-
- return settingsList;
+ // Important permission request for Android 6.0 and above, don't forget to add this!
+ override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
+ PermissionRequest.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
+ override fun permissionGranted() {}
- openSystemGalleryToSelectAnImage();
+ override fun permissionDenied() {
+ /* TODO: The Permission was rejected by the user. The Editor was not opened,
+ * Show a hint to the user and try again. */
}
- private void openSystemGalleryToSelectAnImage() {
- Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
- if (intent.resolveActivity(getPackageManager()) != null) {
- startActivityForResult(intent, GALLERY_RESULT);
- } else {
- Toast.makeText(
- this,
- "No Gallery APP installed",
- Toast.LENGTH_LONG
- ).show();
+ // Create a empty new SettingsList and apply the changes on this reference.
+ // If you have included our asset Packs and you want to use our default UI you also need to add them to the UI config,
+ // otherwise they are only available for the backend link serialisation.
+ // See the specific feature sections of our guides if you want to know how to add your own assets.
+ private fun createPESDKSettingsList() = PhotoEditorSettingsList(true)
+ .configure {
+ it.setFilterList(FilterPackBasic.getFilterPack())
+ }
+ .configure {
+ it.setFontList(FontPackBasic.getFontPack())
+ }
+ .configure {
+ it.setFrameList(FramePackBasic.getFramePack())
+ }
+ .configure {
+ it.setOverlayList(OverlayPackBasic.getOverlayPack())
+ }
+ .configure {
+ it.setStickerLists(
+ StickerPackEmoticons.getStickerCategory(),
+ StickerPackShapes.getStickerCategory()
+ )
}
- }
- private void openEditor(Uri inputImage) {
- SettingsList settingsList = createPesdkSettingsList();
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+ openCamera()
+ }
- // Set input image
- settingsList.getSettingsModel(LoadSettings.class).setSource(inputImage);
+ private fun openCamera() {
+ val settingsList = createPESDKSettingsList()
- settingsList.getSettingsModel(PhotoEditorSaveSettings.class).setOutputToGallery(Environment.DIRECTORY_DCIM);
+ CameraPreviewBuilder(this)
+ .setSettingsList(settingsList)
+ .startActivityForResult(this, PESDK_RESULT)
- new EditorBuilder(this)
- .setSettingsList(settingsList)
- .startActivityForResult(this, PESDK_RESULT);
+ settingsList.release()
}
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
- super.onActivityResult(requestCode, resultCode, intent);
-
- if (resultCode == RESULT_OK && requestCode == GALLERY_RESULT) {
- // Open Editor with some uri in this case with an image selected from the system gallery.
- Uri selectedImage = intent.getData();
- openEditor(selectedImage);
+ override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {
+ super.onActivityResult(requestCode, resultCode, intent)
- } else if (resultCode == RESULT_OK && requestCode == PESDK_RESULT) {
+ if (resultCode == RESULT_OK && requestCode == PESDK_RESULT) {
// Editor has saved an Image.
- EditorSDKResult data = new EditorSDKResult(intent);
+ val data = EditorSDKResult(intent)
- // This adds the result and source image to Android's gallery
- data.notifyGallery(EditorSDKResult.UPDATE_RESULT & EditorSDKResult.UPDATE_SOURCE);
-
- Log.i("PESDK", "Source image is located here " + data.getSourceUri());
- Log.i("PESDK", "Result image is located here " + data.getResultUri());
+ Log.i("PESDK", "Source image is located here ${data.sourceUri}")
+ Log.i("PESDK", "Result image is located here ${data.resultUri}")
// TODO: Do something with the result image
// OPTIONAL: read the latest state to save it as a serialisation
- SettingsList lastState = data.getSettingsList();
+ val lastState = data.settingsList
try {
- new IMGLYFileWriter(lastState).writeJson(new File(
- Environment.getExternalStorageDirectory(),
- "serialisationReadyToReadWithPESDKFileReader.json"
- ));
- } catch (IOException e) { e.printStackTrace(); }
+ IMGLYFileWriter(lastState).writeJson(File(
+ getExternalFilesDir(null),
+ "serialisationReadyToReadWithPESDKFileReader.json"
+ ))
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ lastState.release()
} else if (resultCode == RESULT_CANCELED && requestCode == PESDK_RESULT) {
// Editor was canceled
- EditorSDKResult data = new EditorSDKResult(intent);
+ val data = EditorSDKResult(intent)
- Uri sourceURI = data.getSourceUri();
- // TODO: Do something with the source...
+ val sourceURI = data.sourceUri
+ // TODO: Do something...
}
}
}
```
-
diff --git a/app/build.gradle b/app/build.gradle
index 80d064dc..e6e26516 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -44,12 +44,12 @@ imglyConfig {
}
android {
- compileSdkVersion 30
+ compileSdkVersion 31
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "com.photoeditorsdk.android.app"
- minSdkVersion 16
+ minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
diff --git a/app/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt b/app/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt
index cf36d338..058df321 100644
--- a/app/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt
+++ b/app/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt
@@ -1,17 +1,15 @@
package com.photoeditorsdk.android.app
import android.app.Activity
+import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
-import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.provider.MediaStore
import android.util.Log
import android.widget.Button
import android.widget.Toast
-import java.io.File
-import java.io.IOException
import ly.img.android.pesdk.PhotoEditorSettingsList
import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic
import ly.img.android.pesdk.assets.font.basic.FontPackBasic
@@ -24,37 +22,29 @@ import ly.img.android.pesdk.backend.model.constant.OutputMode
import ly.img.android.pesdk.backend.model.state.LoadSettings
import ly.img.android.pesdk.backend.model.state.PhotoEditorSaveSettings
import ly.img.android.pesdk.ui.activity.PhotoEditorBuilder
-import ly.img.android.pesdk.ui.model.state.*
+import ly.img.android.pesdk.ui.model.state.UiConfigFilter
+import ly.img.android.pesdk.ui.model.state.UiConfigFrame
+import ly.img.android.pesdk.ui.model.state.UiConfigOverlay
+import ly.img.android.pesdk.ui.model.state.UiConfigSticker
+import ly.img.android.pesdk.ui.model.state.UiConfigText
import ly.img.android.pesdk.ui.panels.item.PersonalStickerAddItem
-import ly.img.android.pesdk.ui.utils.PermissionRequest
import ly.img.android.serializer._3.IMGLYFileWriter
+import java.io.File
+import java.io.IOException
-class KEditorDemoActivity : Activity(), PermissionRequest.Response {
+class KEditorDemoActivity : Activity() {
companion object {
const val PESDK_RESULT = 1
const val GALLERY_RESULT = 2
}
- // Important permission request for Android 6.0 and above, don't forget to add this!
- override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
- PermissionRequest.onRequestPermissionsResult(requestCode, permissions, grantResults)
- super.onRequestPermissionsResult(requestCode, permissions, grantResults)
- }
-
- override fun permissionGranted() {}
-
- override fun permissionDenied() {
- /* TODO: The Permission was rejected by the user. The Editor was not opened,
- * Show a hint to the user and try again. */
- }
-
// Create a empty new SettingsList and apply the changes on this reference.
- // If you include our asset Packs and use our UI you also need to add them to the UI,
+ // If you include our asset Packs and use our UI you also need to add them to the UI Config,
// otherwise they are only available for the backend (like Serialisation)
- // See the specific feature sections of our guides if you want to know how to add our own Assets.
+ // See the specific feature sections of our guides if you want to know how to add your own Assets.
private fun createPesdkSettingsList() =
- PhotoEditorSettingsList()
+ PhotoEditorSettingsList(true)
.configure {
it.setFilterList(FilterPackBasic.getFilterPack())
}
@@ -92,16 +82,10 @@ class KEditorDemoActivity : Activity(), PermissionRequest.Response {
}
fun openSystemGalleryToSelectAnImage() {
- val intent = Intent(Intent.ACTION_PICK)
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
- intent.type = "image/*"
- } else {
- intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*")
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || intent.resolveActivity(packageManager) != null) {
+ val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
+ try {
startActivityForResult(intent, GALLERY_RESULT)
- } else {
+ } catch (ex: ActivityNotFoundException) {
Toast.makeText(
this,
"No Gallery APP installed",
@@ -120,6 +104,8 @@ class KEditorDemoActivity : Activity(), PermissionRequest.Response {
PhotoEditorBuilder(this)
.setSettingsList(settingsList)
.startActivityForResult(this, PESDK_RESULT)
+
+ settingsList.release()
}
@@ -154,6 +140,8 @@ class KEditorDemoActivity : Activity(), PermissionRequest.Response {
e.printStackTrace()
}
+ lastState.release()
+
} else if (resultCode == RESULT_CANCELED && requestCode == PESDK_RESULT) {
// Editor was canceled
val data = EditorSDKResult(intent)
diff --git a/build.gradle b/build.gradle
index ad4b21bf..d5eff01e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,8 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.4.10'
- ext.pesdk_version = '9.2.0' // Insert the latest SDK version here. You will find it here https://github.com/imgly/pesdk-android-demo/releases
+ ext.kotlin_version = '1.5.32'
+ ext.pesdk_version = '10.0.0' // Insert the latest SDK version here. You will find it here https://github.com/imgly/pesdk-android-demo/releases
repositories {
google()
gradlePluginPortal()
diff --git a/example_brush_presets_panel/build.gradle b/example_brush_presets_panel/build.gradle
index 12175373..b5f89e01 100644
--- a/example_brush_presets_panel/build.gradle
+++ b/example_brush_presets_panel/build.gradle
@@ -44,12 +44,12 @@ imglyConfig {
}
android {
- compileSdkVersion 30
- buildToolsVersion '30.0.2'
+ compileSdkVersion 31
+ buildToolsVersion '30.0.3'
defaultConfig {
applicationId "com.photoeditorsdk.android.app"
- minSdkVersion 16
+ minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
diff --git a/example_brush_presets_panel/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt b/example_brush_presets_panel/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt
index ce1b63d2..2f5daceb 100644
--- a/example_brush_presets_panel/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt
+++ b/example_brush_presets_panel/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt
@@ -1,6 +1,7 @@
package com.photoeditorsdk.android.app
import android.app.Activity
+import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Build
@@ -34,32 +35,19 @@ import ly.img.android.pesdk.ui.panels.item.PersonalStickerAddItem
import ly.img.android.pesdk.ui.utils.PermissionRequest
import ly.img.android.serializer._3.IMGLYFileWriter
-class KEditorDemoActivity : Activity(), PermissionRequest.Response {
+class KEditorDemoActivity : Activity() {
companion object {
const val PESDK_RESULT = 1
const val GALLERY_RESULT = 2
}
- // Important permission request for Android 6.0 and above, don't forget to add this!
- override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
- PermissionRequest.onRequestPermissionsResult(requestCode, permissions, grantResults)
- super.onRequestPermissionsResult(requestCode, permissions, grantResults)
- }
-
- override fun permissionGranted() {}
-
- override fun permissionDenied() {
- /* TODO: The Permission was rejected by the user. The Editor was not opened,
- * Show a hint to the user and try again. */
- }
-
// Create a empty new SettingsList and apply the changes on this reference.
- // If you include our asset Packs and use our UI you also need to add them to the UI,
+ // If you include our asset Packs and use our UI you also need to add them to the UI Config,
// otherwise they are only available for the backend (like Serialisation)
- // See the specific feature sections of our guides if you want to know how to add our own Assets.
+ // See the specific feature sections of our guides if you want to know how to add your own Assets.
private fun createPesdkSettingsList() =
- PhotoEditorSettingsList()
+ PhotoEditorSettingsList(true)
.configure {
it.setFilterList(FilterPackBasic.getFilterPack())
}
@@ -111,16 +99,10 @@ class KEditorDemoActivity : Activity(), PermissionRequest.Response {
}
fun openSystemGalleryToSelectAnImage() {
- val intent = Intent(Intent.ACTION_PICK)
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
- intent.type = "image/*"
- } else {
- intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*")
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || intent.resolveActivity(packageManager) != null) {
+ val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
+ try {
startActivityForResult(intent, GALLERY_RESULT)
- } else {
+ } catch (ex: ActivityNotFoundException) {
Toast.makeText(
this,
"No Gallery APP installed",
@@ -139,6 +121,8 @@ class KEditorDemoActivity : Activity(), PermissionRequest.Response {
PhotoEditorBuilder(this)
.setSettingsList(settingsList)
.startActivityForResult(this, PESDK_RESULT)
+
+ settingsList.release()
}
@@ -173,6 +157,8 @@ class KEditorDemoActivity : Activity(), PermissionRequest.Response {
e.printStackTrace()
}
+ lastState.release()
+
} else if (resultCode == RESULT_CANCELED && requestCode == PESDK_RESULT) {
// Editor was canceled
val data = EditorSDKResult(intent)