Skip to content

Commit 3601686

Browse files
Merge pull request #6 from ionic-team/feat/RMET-4099/editInApp
feat: added editInApp
2 parents 28fa2f8 + eaf6bf1 commit 3601686

11 files changed

Lines changed: 459 additions & 162 deletions

File tree

android/src/main/java/com/capacitorjs/plugins/camera/CameraPlugin.kt

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import android.content.pm.PackageManager
77
import android.content.pm.ResolveInfo
88
import android.os.Build
99
import android.os.Bundle
10-
import android.util.Log
1110
import androidx.activity.result.ActivityResult
1211
import com.getcapacitor.Logger
1312
import com.getcapacitor.PermissionState
@@ -19,7 +18,6 @@ import com.getcapacitor.annotation.CapacitorPlugin
1918
import com.getcapacitor.annotation.Permission
2019
import com.getcapacitor.annotation.PermissionCallback
2120
import org.json.JSONException
22-
import io.ionic.libs.ioncameralib.model.IONCAMRMediaType
2321
/**
2422
* The Camera plugin makes it easy to take a photo or have the user select a photo
2523
* from their albums.
@@ -61,8 +59,6 @@ class CameraPlugin : Plugin() {
6159

6260
private lateinit var legacyFlow: LegacyCameraFlow
6361
private lateinit var ionFlow: IonCameraFlow
64-
private var videoSettings = VideoSettings()
65-
private var gallerySettings = GallerySettings()
6662

6763
override fun load() {
6864
super.load()
@@ -79,14 +75,12 @@ class CameraPlugin : Plugin() {
7975

8076
@PluginMethod
8177
fun takePhoto(call: PluginCall) {
82-
val settings = getSettings(call)
83-
ionFlow.takePhoto(call, settings)
78+
ionFlow.takePhoto(call)
8479
}
8580

8681
@PluginMethod
8782
fun recordVideo(call: PluginCall) {
88-
videoSettings = getVideoSettings(call)
89-
ionFlow.recordVideo(call, videoSettings)
83+
ionFlow.recordVideo(call)
9084
}
9185

9286
@PluginMethod
@@ -96,8 +90,7 @@ class CameraPlugin : Plugin() {
9690

9791
@PluginMethod
9892
fun chooseFromGallery(call: PluginCall) {
99-
gallerySettings = getGallerySettings(call)
100-
ionFlow.chooseFromGallery(call, gallerySettings)
93+
ionFlow.chooseFromGallery(call)
10194
}
10295

10396
@PluginMethod
@@ -229,46 +222,6 @@ class CameraPlugin : Plugin() {
229222
return permissionStates
230223
}
231224

232-
fun getSettings(call: PluginCall): CameraSettings {
233-
val settings = CameraSettings()
234-
settings.resultType = getResultType(call.getString("resultType"))
235-
settings.saveToGallery =
236-
call.getBoolean("saveToGallery", CameraSettings.DEFAULT_SAVE_IMAGE_TO_GALLERY)!!
237-
settings.allowEditing = call.getBoolean("allowEditing", false)!!
238-
settings.quality = call.getInt("quality", CameraSettings.DEFAULT_QUALITY)!!
239-
settings.width = call.getInt("width", 0)!!
240-
settings.height = call.getInt("height", 0)!!
241-
settings.shouldResize = settings.width > 0 || settings.height > 0
242-
settings.shouldCorrectOrientation =
243-
call.getBoolean("correctOrientation", CameraSettings.DEFAULT_CORRECT_ORIENTATION)!!
244-
try {
245-
settings.source =
246-
CameraSource.valueOf(call.getString("source", CameraSource.PROMPT.getSource())!!)
247-
} catch (ex: IllegalArgumentException) {
248-
settings.source = CameraSource.PROMPT
249-
}
250-
return settings
251-
}
252-
253-
fun getVideoSettings(call: PluginCall): VideoSettings {
254-
return VideoSettings(
255-
saveToGallery = call.getBoolean("saveToGallery") ?: false,
256-
includeMetadata = call.getBoolean("includeMetadata") ?: false,
257-
isPersistent = call.getBoolean("isPersistent") ?: true
258-
)
259-
}
260-
261-
fun getGallerySettings(call: PluginCall): GallerySettings {
262-
return GallerySettings(
263-
mediaType = IONCAMRMediaType.fromValue((call.getInt("mediaType") ?: 0)),
264-
allowMultipleSelection = call.getBoolean("allowMultipleSelection") ?: false,
265-
includeMetadata = call.getBoolean("includeMetadata") ?: false,
266-
allowEdit = call.getBoolean("allowEdit") ?: false,
267-
limit = call.getInt("limit") ?: 0,
268-
editInApp = call.getBoolean("editInApp") ?: true
269-
)
270-
}
271-
272225
private fun getResultType(resultType: String?): CameraResultType? {
273226
if (resultType == null) {
274227
return null
@@ -321,7 +274,4 @@ class CameraPlugin : Plugin() {
321274
requestPermissionForAliases(aliases, call, callbackName)
322275
}
323276

324-
fun getLegacyLogTag(): String {
325-
return getLogTag()
326-
}
327277
}

0 commit comments

Comments
 (0)