Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,30 @@ class IonCameraFlow(
return IonGallerySettings(
mediaType = IONCAMRMediaType.fromValue((call.getInt("mediaType") ?: 0)),
allowMultipleSelection = call.getBoolean("allowMultipleSelection") ?: false,
limit = call.getInt("limit") ?: 0,
includeMetadata = call.getBoolean("includeMetadata") ?: false,
allowEdit = call.getBoolean("allowEdit") ?: false,
limit = call.getInt("limit") ?: 0,
editInApp = call.getBoolean("editInApp") ?: true
editInApp = call.getBoolean("editInApp") ?: true,
quality = call.getInt("quality") ?: DEFAULT_QUALITY,
width = call.getInt("width") ?: 0,
height = call.getInt("height") ?: 0,
Comment on lines +191 to +192
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on which PR gets merged first, this or #11, there may be conflicts to resolve, as the name changed to targetWidth/targetHeight.

correctOrientation = call.getBoolean("correctOrientation") ?: DEFAULT_CORRECT_ORIENTATION
)
}

data class IonGallerySettings (
var mediaType: IONCAMRMediaType = IONCAMRMediaType.ALL,
var allowMultipleSelection: Boolean = false,
var limit: Int = 0,
var includeMetadata: Boolean = false,
var allowEdit: Boolean = false,
var editInApp: Boolean = true,
var quality: Int = 90,
var width: Int = 0,
var height: Int = 0,
var correctOrientation: Boolean = true
)

fun getCameraSettings(call: PluginCall): IonCameraSettings {
val settings = IonCameraSettings()
settings.quality = call.getInt("quality", IonCameraSettings.DEFAULT_QUALITY)!!
Expand Down Expand Up @@ -685,8 +702,6 @@ class IonCameraFlow(
return
}



val exif = ImageUtils.getExifData(plugin.context, bitmap, uri)
val ret = JSObject()
ret.put("type", mediaResult.type)
Expand All @@ -695,8 +710,6 @@ class IonCameraFlow(
ret.put("webPath", FileUtils.getPortablePath(plugin.context, plugin.bridge.localUrl, uri))
ret.put("saved", mediaResult.saved)



val metadata = JSObject()
mediaResult.metadata?.let {
metadata.put("duration", it.duration)
Expand Down Expand Up @@ -746,21 +759,38 @@ class IonCameraFlow(
val file = File(mediaResult.uri)
val uri = Uri.fromFile(file)

val obj = JSObject()
obj.put("path", mediaResult.uri)
obj.put(
val ret = JSObject()
ret.put("type", mediaResult.type)
ret.put("uri", mediaResult.uri)
ret.put("thumbnail", mediaResult.thumbnail)
ret.put("saved", mediaResult.saved)
ret.put(
"webPath",
FileUtils.getPortablePath(plugin.context, plugin.bridge.localUrl, uri)
)
obj.put("saved", mediaResult.saved)

val metadata = JSObject()
mediaResult.metadata?.let {
obj.put("duration", it.duration)
obj.put("size", it.size)
obj.put("format", it.format)
metadata.put("duration", it.duration)
metadata.put("size", it.size)
metadata.put("format", it.format)
metadata.put("resolution", it.resolution)
metadata.put("creationDate", it.creationDate)
}

if (mediaResult.type == IONCAMRMediaType.PICTURE.type) {
val bitmap = BitmapFactory.decodeFile(mediaResult.uri)
if (bitmap == null) {
sendError(IONCAMRError.PROCESS_IMAGE_ERROR)
return
}

val exif = ImageUtils.getExifData(plugin.context, bitmap, uri)
metadata.put("exif", exif.toJson())
}

photos.put(obj)
ret.put("metadata", metadata)
photos.put(ret)
}

val ret = JSObject()
Expand Down Expand Up @@ -948,7 +978,7 @@ class IonCameraFlow(
when (call.getMethodName()) {
"takePhoto" -> openCamera(call)
"recordVideo" -> openRecordVideo(call)
"pickImages" -> openGallery(call)
"chooseFromGallery" -> openGallery(call)
else -> sendError(IONCAMRError.CONTEXT_ERROR)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ package com.capacitorjs.plugins.camera

import io.ionic.libs.ioncameralib.model.IONCAMRMediaType

data class IonGallerySettings(
val mediaType: IONCAMRMediaType = IONCAMRMediaType.ALL,
val allowMultipleSelection: Boolean = false,
val limit: Int = 0,
val includeMetadata: Boolean = false,
val allowEdit: Boolean = false,
val editInApp: Boolean = true
)
class IonGallerySettings {
var mediaType: IONCAMRMediaType = IONCAMRMediaType.ALL
var allowMultipleSelection: Boolean = false
var limit: Int = 0
var includeMetadata: Boolean = false
var allowEdit: Boolean = false
var editInApp: Boolean = true
var quality: Int = DEFAULT_QUALITY
var width: Int = 0
var height: Int = 0
var correctOrientation: Boolean = DEFAULT_CORRECT_ORIENTATION

companion object {
const val DEFAULT_QUALITY: Int = 90
const val DEFAULT_CORRECT_ORIENTATION: Boolean = true
}
}
Loading