Skip to content

Commit

Permalink
RMET-3888 - Prepare to release version 4.2.0-OS52 (#146)
Browse files Browse the repository at this point in the history
* RMET-3653 - Add support for capacitor and add missing permissions (#139)

* test: remove hook to test plugin

* test: use edit-config instead of config-file

* fix: replace config-file with edit-config and remove unnecessary hook

References: https://outsystemsrd.atlassian.net/browse/RMET-3653

* chore: remove unused hook

References: https://outsystemsrd.atlassian.net/browse/RMET-3653

* chore: remove the usage of kotlin-kapt plugin

Context: It wasn't being used.

References: https://outsystemsrd.atlassian.net/browse/RMET-3653

* feat: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3653

* test: use manifest as parent

References: https://outsystemsrd.atlassian.net/browse/RMET-3653

* chore: don't need to specify Manifest as parent

References: https://outsystemsrd.atlassian.net/browse/RMET-3653

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3653

* fix: add necessary permissions to AndroidManifest.xml

Context: MABS 11 was updated with the latest version of the native shell, which removes this permissions, so plugins need to add them.

References: https://outsystemsrd.atlassian.net/browse/RMET-3856

* chore(release): prepare to release version 4.2.0-OS51

References: https://outsystemsrd.atlassian.net/browse/RMET-3857

* RMET-3810 ::: Generated Thumbnail Bigger than Expected (#136)

* chore: update libraries for testing

This adds the fix on the library side.

References: https://outsystemsrd.atlassian.net/browse/RMET-3810

* chore: migrating theses codes from library

These are only used here, so this is where they belong.

* chore: remove unused variables

* chore: add CHANGELOG entry

References: https://outsystemsrd.atlassian.net/browse/RMET-3810

---------

Co-authored-by: Alexandre Jacinto <alexandre.jacinto@outsystems.com>

* RMET-3812 - Use PhotoPicker API to select media from gallery (#141)

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: include Jetpack Compose dependencies

Context: Without these, the Photo Picker is not launched for Android 12 devices.

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: update changelog

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: remove unnecessary dependencies

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: include activity dependency

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3812

* RMET-3875 - Fix issue in permission request for `EditURIPicture` and remove unnecessary permissions (#142)

* fix: properly check if gallery permissions are needed

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* fix: avoid requesting unnecessary permission when choosing media from the gallery

Context: When using intents or the Photo Picker API for the user to select media (images and videos) we don't need to request the READ_EXTERNAL_STORAGE permission. That is only necessary when accessing files in the external storage (e.g. when calling editURIPicture)

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* fix: remove unnecessary permissions from plugin

Context: We actually never request these permissions, so there's no point in declaring them in the AndroidManifest.xml file.

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* chore: update changelog

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* refactor: avoid asking unnecessary permissions

Context: As we use the MediaStore to fetch and store photos in the device's gallery, these permissions aren't necessary.

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* chore: set lib to dev version

* Revert "refactor: avoid asking unnecessary permissions"

This reverts commit 28d61e4.

* revert: revert commit where we removed the READ_EXTERNAL_STORAGE permission request for Android < 13

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* chore: remove entry from changelog

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* chore: update dependency to OSCameraLib-Android

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* chore(release): raise to version 4.2.0-OS52

References: https://outsystemsrd.atlassian.net/browse/RMET-3875

* RMET-3894 ::: Improve Error Handling for Size (#144)

* fix(ios): improve error handling for OSCAMRTakePictureParameters

Make 'targetWidth' and 'targetHeight' optional and 'includeMetadata' and 'latestVersion' mandatory.
Validate all optional fields and, when the result is missing or out of bounds, return the new OSCAMRTakePictureParametersError invalid error. This error is also managed on OSCamera's takePicture method.
Update iOS library, that also adds error handling on its side.

References: https://outsystemsrd.atlassian.net/browse/RMET-3894

* fix(js): remove default value for takePicture's targetWidth and targetHeight

The nil values are supposed to go into the native code for proper error handling.
Sync default quality value with Outsystems.

References: https://outsystemsrd.atlassian.net/browse/RMET-3894

* chore(android): adapt code to new JavaScript structure

'targetWidth' and 'targetHeight' can be passed as 'null', so they need a fallback value when retrieved.

References: https://outsystemsrd.atlassian.net/browse/RMET-3894

* refactor(android): code cleanse

Remove unused and unnecessary variable definition.
Simplify 'includeMetadata' and 'latestVersion' value retrieval.

References: https://outsystemsrd.atlassian.net/browse/RMET-3894

* chore: add CHANGELOG entry

References: https://outsystemsrd.atlassian.net/browse/RMET-3894

* chore(release): set to version 4.2.0-OS52 (#145)

References: https://outsystemsrd.atlassian.net/browse/RMET-3888

* Revert "Merge branch 'outsystems' into development"

This reverts commit 5e44264, reversing
changes made to b9bd0e9.

* chore: remove unnecessary entry from changelog

References: https://outsystemsrd.atlassian.net/browse/RMET-3888

* chore: add missing entries to CHANGELOG.md

References: https://outsystemsrd.atlassian.net/browse/RMET-3888

---------

Co-authored-by: Ricardo Silva <97543217+OS-ricardomoreirasilva@users.noreply.github.com>
  • Loading branch information
1 parent 9f8f517 commit c2c8ce0
Show file tree
Hide file tree
Showing 27 changed files with 356 additions and 264 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ The changes documented here do not include those from the original repository.
- (android) Use PhotoPicker to select media from gallery (https://outsystemsrd.atlassian.net/browse/RMET-3812).

### Fixes
- (android, ios) Improve error handling for height x width invalid values (https://outsystemsrd.atlassian.net/browse/RMET-3894).
- (android) Add image resolution and quality when creating its thumbnail (https://outsystemsrd.atlassian.net/browse/RMET-3810).
- (android) Fixes an issue in the permission request in the `callEditUriImage` function, where in some cases the permission kept being requested. (https://outsystemsrd.atlassian.net/browse/RMET-3875).
- (android) Removes `READ_MEDIA_IMAGE` and `READ_MEDIA_VIDEO` permissions from the AndroidManifest.xml file of the resulting app, since these are never requested by the plugin, so there's no point in having them in the manifest file. (https://outsystemsrd.atlassian.net/browse/RMET-3875).
- (android) Fixes edge-to-Edge for loading screen.
- (android) Fix to give persistable permissions for returned URIs (https://outsystemsrd.atlassian.net/browse/RMET-3812).
- (android) Fix exception being thrown on Android 10 when selecting media from gallery (https://outsystemsrd.atlassian.net/browse/RMET-3812).
- (android) Always show loading screen while processing selected media (https://outsystemsrd.atlassian.net/browse/RMET-3812).

## 4.2.0-OS51

Expand Down
27 changes: 4 additions & 23 deletions src/android/CameraLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class CameraLauncher : CordovaPlugin() {
= false
private var correctOrientation // Should the pictures orientation be corrected
= false
private var orientationCorrected // Has the picture's orientation been corrected
= false
private var allowEdit // Should we allow the user to crop the image.
= false
private var saveVideoToGallery
Expand Down Expand Up @@ -159,37 +157,20 @@ class CameraLauncher : CordovaPlugin() {

when(action) {
"takePicture" -> {
srcType = CAMERA
destType = FILE_URI
saveToPhotoAlbum = false
targetHeight = 0
targetWidth = 0
encodingType = JPEG
mediaType = PICTURE
mQuality = 50

val parameters = args.getJSONObject(0)
//Take the values from the arguments if they're not already defined (this is tricky)
mQuality = parameters.getInt(QUALITY)
targetWidth = parameters.getInt(WIDTH)
targetHeight = parameters.getInt(HEIGHT)
targetWidth = parameters.optInt(WIDTH, -1)
targetHeight = parameters.optInt(HEIGHT, -1)
encodingType = parameters.getInt(ENCODING_TYPE)
allowEdit = parameters.getBoolean(ALLOW_EDIT)
correctOrientation = parameters.getBoolean(CORRECT_ORIENTATION)
saveToPhotoAlbum = parameters.getBoolean(SAVE_TO_ALBUM)
destType = parameters.getInt(DEST_TYPE)
srcType = parameters.getInt(SOURCE_TYPE)
mediaType = parameters.getInt(MEDIA_TYPE)
includeMetadata = false
latestVersion = false

if (parameters.has(INCLUDE_METADATA)) {
includeMetadata = parameters.getBoolean(INCLUDE_METADATA)
}

if (parameters.has(LATEST_VERSION)) {
latestVersion = parameters.getBoolean(LATEST_VERSION)
}
includeMetadata = parameters.optBoolean(INCLUDE_METADATA, false)
latestVersion = parameters.optBoolean(LATEST_VERSION, false)

// If the user specifies a 0 or smaller width/height
// make it -1 so later comparisons succeed
Expand Down
46 changes: 31 additions & 15 deletions src/ios/OSCAMRTakePictureParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,50 @@ import OSCameraLib

struct OSCAMRTakePictureParameters: Decodable {
let quality: Int
let targetWidth: Int
let targetHeight: Int
let targetWidth: Int?
let targetHeight: Int?
let encodingType: Int
let sourceType: Int
let allowEdit: Bool
let correctOrientation: Bool
let saveToPhotoAlbum: Bool
let cameraDirection: Int
let includeMetadata: Bool?
let latestVersion: Bool?
let includeMetadata: Bool
let latestVersion: Bool
}

private enum OSCAMRTakePictureParametersError: Error {
case invalid(field: String)
}

extension OSCAMRPictureOptions {
convenience init(from parameters: OSCAMRTakePictureParameters) {
let targetSize = OSCAMRSize(width: parameters.targetWidth, height: parameters.targetHeight)
let encodingType = OSCAMREncodingType(rawValue: parameters.encodingType) ?? .jpeg
let direction = OSCAMRDirection(rawValue: parameters.cameraDirection) ?? .back
convenience init(from parameters: OSCAMRTakePictureParameters) throws {
func throwError(field: String) -> OSCAMRTakePictureParametersError {
OSCAMRTakePictureParametersError.invalid(field: field)
}

if parameters.quality < 0 || parameters.quality > 100 { throw throwError(field: "quality") }
guard let encodingType = OSCAMREncodingType(rawValue: parameters.encodingType) else { throw throwError(field: "encodingType") }
guard let cameraDirection = OSCAMRDirection(rawValue: parameters.cameraDirection) else { throw throwError(field: "cameraDirection") }

self.init(
quality: parameters.quality,
size: targetSize,
var targetSize: OSCAMRSize?
if let targetWidth = parameters.targetWidth, let targetHeight = parameters.targetHeight {
guard targetWidth > 0 else { throw throwError(field: "targetWidth") }
guard targetHeight > 0 else { throw throwError(field: "targetHeight") }

targetSize = try OSCAMRSize(width: targetWidth, height: targetHeight)
}

try self.init(
quality: parameters.quality,
size: targetSize,
correctOrientation: parameters.correctOrientation,
encodingType: encodingType,
saveToPhotoAlbum: parameters.saveToPhotoAlbum,
direction: direction,
direction: cameraDirection,
allowEdit: parameters.allowEdit,
returnMetadata: parameters.includeMetadata ?? false,
latestVersion: parameters.latestVersion ?? false
returnMetadata: parameters.includeMetadata,
latestVersion: parameters.latestVersion
)
}
}
}
10 changes: 5 additions & 5 deletions src/ios/OSCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ class OSCamera: CDVPlugin {
guard let parametersDictionary = command.argument(at: 0) as? [String: Any],
let parametersData = try? JSONSerialization.data(withJSONObject: parametersDictionary),
let parameters = try? JSONDecoder().decode(OSCAMRTakePictureParameters.self, from: parametersData)
else { return self.callback(error: .takePictureIssue) }
else { return self.callback(error: .takePictureArguments) }

// This 🔨 is required in order not to break Android's implementation
if parameters.sourceType == 0 {
self.chooseSinglePicture(allowEdit: parameters.allowEdit)
return
return self.chooseSinglePicture(allowEdit: parameters.allowEdit)
}

let options = OSCAMRPictureOptions(from: parameters)

guard let options = try? OSCAMRPictureOptions(from: parameters)
else { return self.callback(error: .takePictureArguments) }

self.commandDelegate.run { [weak self] in
guard let self = self else { return }
self.plugin?.captureMedia(with: options)
Expand Down
10 changes: 5 additions & 5 deletions src/ios/frameworks/OSCameraLib.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
<key>BinaryPath</key>
<string>OSCameraLib.framework/OSCameraLib</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>OSCameraLib.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>OSCameraLib.framework/OSCameraLib</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>OSCameraLib.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit c2c8ce0

Please sign in to comment.