@@ -183,13 +183,30 @@ class IonCameraFlow(
183183 return IonGallerySettings (
184184 mediaType = IONCAMRMediaType .fromValue((call.getInt(" mediaType" ) ? : 0 )),
185185 allowMultipleSelection = call.getBoolean(" allowMultipleSelection" ) ? : false ,
186+ limit = call.getInt(" limit" ) ? : 0 ,
186187 includeMetadata = call.getBoolean(" includeMetadata" ) ? : false ,
187188 allowEdit = call.getBoolean(" allowEdit" ) ? : false ,
188- limit = call.getInt(" limit" ) ? : 0 ,
189- editInApp = call.getBoolean(" editInApp" ) ? : true
189+ editInApp = call.getBoolean(" editInApp" ) ? : true ,
190+ quality = call.getInt(" quality" ) ? : DEFAULT_QUALITY ,
191+ width = call.getInt(" width" ) ? : 0 ,
192+ height = call.getInt(" height" ) ? : 0 ,
193+ correctOrientation = call.getBoolean(" correctOrientation" ) ? : DEFAULT_CORRECT_ORIENTATION
190194 )
191195 }
192196
197+ data class IonGallerySettings (
198+ var mediaType : IONCAMRMediaType = IONCAMRMediaType .ALL ,
199+ var allowMultipleSelection : Boolean = false ,
200+ var limit : Int = 0 ,
201+ var includeMetadata : Boolean = false ,
202+ var allowEdit : Boolean = false ,
203+ var editInApp : Boolean = true ,
204+ var quality : Int = 90 ,
205+ var width : Int = 0 ,
206+ var height : Int = 0 ,
207+ var correctOrientation : Boolean = true
208+ )
209+
193210 fun getCameraSettings (call : PluginCall ): IonCameraSettings {
194211 val settings = IonCameraSettings ()
195212 settings.quality = call.getInt(" quality" , IonCameraSettings .DEFAULT_QUALITY )!!
@@ -314,7 +331,7 @@ class IonCameraFlow(
314331 saveToGallery = false ,
315332 includeMetadata = false
316333 )
317- val imageBase64 = call.data. getString(" base64 " )
334+ val imageBase64 = call.getString(" inputImage " )
318335 if (imageBase64 == null ) return
319336 manager.editImage(plugin.activity, imageBase64, editLauncher)
320337 }
@@ -670,8 +687,7 @@ class IonCameraFlow(
670687
671688 private fun handleEditBase64Result (image : String ) {
672689 val ret = JSObject ()
673- ret.put(" format" , " jpeg" )
674- ret.put(" base64String" , image)
690+ ret.put(" outputImage" , image)
675691 currentCall?.resolve(ret)
676692 currentCall = null
677693 }
@@ -685,8 +701,6 @@ class IonCameraFlow(
685701 return
686702 }
687703
688-
689-
690704 val exif = ImageUtils .getExifData(plugin.context, bitmap, uri)
691705 val ret = JSObject ()
692706 ret.put(" type" , mediaResult.type)
@@ -695,8 +709,6 @@ class IonCameraFlow(
695709 ret.put(" webPath" , FileUtils .getPortablePath(plugin.context, plugin.bridge.localUrl, uri))
696710 ret.put(" saved" , mediaResult.saved)
697711
698-
699-
700712 val metadata = JSObject ()
701713 mediaResult.metadata?.let {
702714 metadata.put(" duration" , it.duration)
@@ -746,21 +758,38 @@ class IonCameraFlow(
746758 val file = File (mediaResult.uri)
747759 val uri = Uri .fromFile(file)
748760
749- val obj = JSObject ()
750- obj.put(" path" , mediaResult.uri)
751- obj.put(
761+ val ret = JSObject ()
762+ ret.put(" type" , mediaResult.type)
763+ ret.put(" uri" , mediaResult.uri)
764+ ret.put(" thumbnail" , mediaResult.thumbnail)
765+ ret.put(" saved" , mediaResult.saved)
766+ ret.put(
752767 " webPath" ,
753768 FileUtils .getPortablePath(plugin.context, plugin.bridge.localUrl, uri)
754769 )
755- obj.put(" saved" , mediaResult.saved)
756770
771+ val metadata = JSObject ()
757772 mediaResult.metadata?.let {
758- obj.put(" duration" , it.duration)
759- obj.put(" size" , it.size)
760- obj.put(" format" , it.format)
773+ metadata.put(" duration" , it.duration)
774+ metadata.put(" size" , it.size)
775+ metadata.put(" format" , it.format)
776+ metadata.put(" resolution" , it.resolution)
777+ metadata.put(" creationDate" , it.creationDate)
778+ }
779+
780+ if (mediaResult.type == IONCAMRMediaType .PICTURE .type) {
781+ val bitmap = BitmapFactory .decodeFile(mediaResult.uri)
782+ if (bitmap == null ) {
783+ sendError(IONCAMRError .PROCESS_IMAGE_ERROR )
784+ return
785+ }
786+
787+ val exif = ImageUtils .getExifData(plugin.context, bitmap, uri)
788+ metadata.put(" exif" , exif.toJson())
761789 }
762790
763- photos.put(obj)
791+ ret.put(" metadata" , metadata)
792+ photos.put(ret)
764793 }
765794
766795 val ret = JSObject ()
@@ -948,7 +977,7 @@ class IonCameraFlow(
948977 when (call.getMethodName()) {
949978 " takePhoto" -> openCamera(call)
950979 " recordVideo" -> openRecordVideo(call)
951- " pickImages " -> openGallery(call)
980+ " chooseFromGallery " -> openGallery(call)
952981 else -> sendError(IONCAMRError .CONTEXT_ERROR )
953982 }
954983 }
0 commit comments