From 67365c1cc13af2475ffa29dba78efe48a7a1caac Mon Sep 17 00:00:00 2001 From: Leon Dudlik Date: Thu, 27 Apr 2023 23:41:41 +0200 Subject: [PATCH] Add version 3.0.0 --- CHANGELOG.md | 13 ++++++++++ README.md | 2 +- .../flutter/photo_editor_sdk/FlutterPESDK.kt | 8 +++--- example/ios/Podfile.lock | 10 +++---- ios/Classes/FlutterPESDK.swift | 26 ++++++++++--------- lib/photo_editor_sdk.dart | 4 +-- pubspec.yaml | 6 ++--- test/photo_editor_sdk_test.dart | 6 +++-- 8 files changed, 46 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9501109..4a8e3b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## [3.0.0] + +### Changed + +* Changed and aligned the error codes for the plugins. +* [imgly_sdk] Removed custom `Color` class and replaced its usage with the `dart:ui` `Color` class. +* [video_editor_sdk] Unlocking the license via `VESDK.unlockWithLicense` is now executing asynchronously. +* [photo_editor_sdk] Unlocking the license via `PESDK.unlockWithLicense` is now executing asynchronously. + +### Fixed + +* [video_editor_sdk] Fixed tint color of the toolbar would not be applied correctly in the trim tool on iOS. + ## [2.9.0] ### Added diff --git a/README.md b/README.md index f196873..a9cd211 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Add the plugin package to the `pubspec.yaml` file in your project: ```yaml dependencies: - photo_editor_sdk: ^2.9.0 + photo_editor_sdk: ^3.0.0 ``` Install the new dependency: diff --git a/android/src/main/kotlin/ly/img/flutter/photo_editor_sdk/FlutterPESDK.kt b/android/src/main/kotlin/ly/img/flutter/photo_editor_sdk/FlutterPESDK.kt index 0c3dd04..20f6671 100644 --- a/android/src/main/kotlin/ly/img/flutter/photo_editor_sdk/FlutterPESDK.kt +++ b/android/src/main/kotlin/ly/img/flutter/photo_editor_sdk/FlutterPESDK.kt @@ -61,7 +61,7 @@ class FlutterPESDK: FlutterIMGLY() { override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { if (this.result != null) { - result.error("Multiple requests.", "Cancelled due to multiple requests.", null) + result.error(IMGLYConstants.K_ERROR_MULTIPLE_REQUESTS, "Cancelled due to multiple requests.", null) return } @@ -93,11 +93,11 @@ class FlutterPESDK: FlutterIMGLY() { this.result = result this.present(imageData, config, serialization) } else { - result.error("PE.SDK", "The specified serialization did not include a photo.", null) + result.error(IMGLYConstants.K_ERROR_UNABLE_TO_LOAD, "The specified serialization did not include a photo.", null) return } } else { - result.error("PE.SDK", "No image has been specified or included in the serialization.", null) + result.error(IMGLYConstants.K_ERROR_UNABLE_TO_LOAD, "No image has been specified or included in the serialization.", null) return } } @@ -156,7 +156,7 @@ class FlutterPESDK: FlutterIMGLY() { this.result?.success(null) this.result = null } catch (e: AuthorizationException) { - this.result?.error("PE.SDK", "The license is invalid.", e.message) + this.result?.error(IMGLYConstants.K_ERROR_UNABLE_TO_UNLOCK, "The license is invalid.", e.message) this.result = null } } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index a6c5625..313b180 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,12 +1,12 @@ PODS: - Flutter (1.0.0) - - imgly_sdk (2.9.0): + - imgly_sdk (3.0.0): - Flutter - imglyKit (~> 11.4) - imglyKit (11.5.1) - - photo_editor_sdk (2.9.0): + - photo_editor_sdk (3.0.0): - Flutter - - imgly_sdk (= 2.9.0) + - imgly_sdk (= 3.0.0) DEPENDENCIES: - Flutter (from `Flutter`) @@ -27,9 +27,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - imgly_sdk: a1937f3cd410756297d87d15086a37f24466d288 + imgly_sdk: a114555e1d98e4a4fa5cc8f2b258353198c64e8b imglyKit: b1b3b827799a50b090433ca7c61f90b078944898 - photo_editor_sdk: 5e72294f9947007ff0918717f74a1186c1210f6d + photo_editor_sdk: d5eea1abfd23930ec45163f95d92e2570434e4cc PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 diff --git a/ios/Classes/FlutterPESDK.swift b/ios/Classes/FlutterPESDK.swift index 71163aa..ca608b6 100644 --- a/ios/Classes/FlutterPESDK.swift +++ b/ios/Classes/FlutterPESDK.swift @@ -37,7 +37,7 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD guard let arguments = call.arguments as? IMGLYDictionary else { return } if self.result != nil { - result(FlutterError(code: "Multiple requests.", message: "Cancelled due to multiple requests.", details: nil)) + result(FlutterError(code: IMGLYConstants.kErrorMultipleRequests, message: "Cancelled due to multiple requests.", details: nil)) return } @@ -83,7 +83,7 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD if let serializationPhoto = deserializationResult?.photo { finalPhotoAsset = Photo.from(photoRepresentation: serializationPhoto) } else { - self.result?(FlutterError(code: "Photo must not be nil.", message: "The specified serialization did not include a photo.", details: nil)) + self.result?(FlutterError(code: IMGLYConstants.kErrorUnableToLoad, message: "The specified serialization did not include a photo.", details: nil)) self.result = nil return nil } @@ -92,7 +92,7 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD } guard let finalPhoto = finalPhotoAsset else { - self.result?(FlutterError(code: "Photo must not be nil.", message: "No image has been specified or included in the serialization.", details: nil)) + self.result?(FlutterError(code: IMGLYConstants.kErrorUnableToLoad, message: "No image has been specified or included in the serialization.", details: nil)) self.result = nil return nil } @@ -121,9 +121,11 @@ public class FlutterPESDK: FlutterIMGLY, FlutterPlugin, PhotoEditViewControllerD DispatchQueue.main.async { do { try PESDK.unlockWithLicense(from: url) + self.result?(nil) self.result = nil } catch let error { - self.handleLicenseError(with: error as NSError) + self.result?(FlutterError(code: IMGLYConstants.kErrorUnableToUnlock, message: "Unlocking the SDK failed due to:", details: error.localizedDescription)) + self.result = nil } } } @@ -153,7 +155,7 @@ extension FlutterPESDK { /// - Parameter result: The `PhotoEditorResult` from the editor. public func photoEditViewControllerDidFinish(_ photoEditViewController: PhotoEditViewController, result: PhotoEditorResult) { guard let uti = result.output.uti else { - self.handleError(photoEditViewController, code: "Image could not be saved.", message: nil, details: nil) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "Failed to retrieve the output UTI.", details: nil) return } @@ -164,21 +166,21 @@ extension FlutterPESDK { if imageData.isEmpty == false { if self.exportType == IMGLYConstants.kExportTypeFileURL { guard let fileURL = self.exportFile else { - self.handleError(photoEditViewController, code: "Export type must not be nil.", message: "No valid export type has been specified.", details: self.exportFile?.absoluteString) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "No valid export type has been specified.", details: self.exportFile?.absoluteString) return } do { try imageData.IMGLYwriteToUrl(fileURL, andCreateDirectoryIfNeeded: true) imageString = fileURL.absoluteString } catch let error { - self.handleError(photoEditViewController, code: "Image could not be saved.", message: "Error message: \(error.localizedDescription)", details: error.localizedDescription) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: error.localizedDescription, details: error.localizedDescription) return } } else if self.exportType == IMGLYConstants.kExportTypeDataURL { if let mediaType = UTTypeCopyPreferredTagWithClass(uti as CFString, kUTTagClassMIMEType)?.takeRetainedValue() as? NSString { imageString = String(format: "data:%@;base64,%@", mediaType, imageData.base64EncodedString()) } else { - self.handleError(photoEditViewController, code: "Image could not be saved.", message: "The output UTI could not be read.", details: nil) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "The output UTI could not be read.", details: nil) return } } @@ -190,21 +192,21 @@ extension FlutterPESDK { } if self.serializationType == IMGLYConstants.kExportTypeFileURL { guard let exportURL = self.serializationFile else { - self.handleError(photoEditViewController, code: "Serialization failed.", message: "The URL must not be nil.", details: nil) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "The URL must not be nil.", details: nil) return } do { try serializationData.IMGLYwriteToUrl(exportURL, andCreateDirectoryIfNeeded: true) serialization = self.serializationFile?.absoluteString } catch let error { - self.handleError(photoEditViewController, code: "Serialization failed.", message: error.localizedDescription, details: error.localizedDescription) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: error.localizedDescription, details: error.localizedDescription) return } } else if self.serializationType == IMGLYConstants.kExportTypeObject { do { serialization = try JSONSerialization.jsonObject(with: serializationData, options: .init(rawValue: 0)) } catch let error { - self.handleError(photoEditViewController, code: "Serialization failed.", message: error.localizedDescription, details: error.localizedDescription) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: error.localizedDescription, details: error.localizedDescription) return } } @@ -223,7 +225,7 @@ extension FlutterPESDK { /// - Parameter photoEditViewController: The editor that failed to export. /// - Parameter error: The `PhotoEditorError` that caused the failure. public func photoEditViewControllerDidFail(_ photoEditViewController: PhotoEditViewController, error: PhotoEditorError) { - self.handleError(photoEditViewController, code: "Editor failed", message: "The editor did fail to generate the image.", details: error.localizedDescription) + self.handleError(photoEditViewController, code: IMGLYConstants.kErrorUnableToExport, message: "The editor did fail to generate the image.", details: error.localizedDescription) } /// Delegate function that is called if the `PhotoEditViewController` has diff --git a/lib/photo_editor_sdk.dart b/lib/photo_editor_sdk.dart index cda181f..d482974 100644 --- a/lib/photo_editor_sdk.dart +++ b/lib/photo_editor_sdk.dart @@ -17,8 +17,8 @@ class PESDK { /// to include one license for each platform with the same name, but where /// the iOS license has `.ios` as its file extension and the /// Android license has `.android` as its file extension. - static void unlockWithLicense(String path) async { - await _channel.invokeMethod('unlock', {'license': path}); + static Future unlockWithLicense(String path) async { + return _channel.invokeMethod('unlock', {'license': path}); } /// Opens a new photo editor. diff --git a/pubspec.yaml b/pubspec.yaml index e567821..2de5b3c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: photo_editor_sdk description: The official Flutter plugin for PhotoEditor SDK. Integrate the photo editor into your own iOS or Android app - in minutes! -version: 2.9.0 -homepage: https://www.photoeditorsdk.com +version: 3.0.0 +homepage: https://img.ly/products/photo-sdk repository: https://github.com/imgly/pesdk-flutter environment: @@ -11,7 +11,7 @@ environment: dependencies: flutter: sdk: flutter - imgly_sdk: 2.9.0 + imgly_sdk: 3.0.0 dev_dependencies: flutter_test: diff --git a/test/photo_editor_sdk_test.dart b/test/photo_editor_sdk_test.dart index 67a199d..412ef1a 100644 --- a/test/photo_editor_sdk_test.dart +++ b/test/photo_editor_sdk_test.dart @@ -2,11 +2,13 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - const MethodChannel channel = MethodChannel('photo_editor_sdk'); + const channel = MethodChannel('photo_editor_sdk'); TestWidgetsFlutterBinding.ensureInitialized(); setUp(() {}); - tearDown(() {}); + tearDown(() { + channel.setMockMethodCallHandler(null); + }); }