Commit Graph
272 Commits
Author SHA1 Message Date
Marius Van NieuwenhuyseandGitHub 2470f8d970 feat(android): Added originalDateTime to exif handling 2026-07-27 20:37:01 +02:00
dd39592faf fix(android): Prevent out of memory errors on Android when selecting large media (video) files from the gallery picker. (#923)
Changes from #906 resulted in all gallery picker results being read in full into a byte array. This works fine when dealing with images, however when larger files (videos for example) are selected it will nearly always result in an out of memory error (reading too much data in one go). With videos no transformation is required, the URI simply need to be returned.

Co-authored-by: Alister Stevens <alister@pebblepad.co.uk>
2026-04-20 18:19:26 +02:00
Manuel BeckandGitHub 0d87f93a2e ios: rename variables cameraPicker to cdvUIImagePickerController (#950)
* ios: Rename variables `cameraPicker` to `cdvUIImagePickerController`

- Make clear, that `CDVUIImagePickerController` is used for these variables
- When it's used as weak variable, it's renamed to `weakCDVUIImagePickerController`

* fox(ios): Don't use `weak` in variable name

- Rename `weakCDVUIImagePickerController` to `cdvUIImagePickerController`
- It doesn't matter if it's a weak reference or not, it works like any other variable. The only reason `weakSelf` is a convention is because you need to explicitly create a variable to hold the weak reference.
2026-04-20 18:18:10 +02:00
Manuel BeckandGitHub 9cf4a9c897 refactor(ios): resultForImage: (#951)
* refactor(ios): small refactoring on `resultForImage:`

- Document meta data processing
- Remove any reference of `self.cdvUIImagePickerController` since it is not needed here and also not set, when `PHPickerViewController` is used
- Use `pictureOptions.sourceType` instead of `self.cdvUIImagePickerController.sourceType``
- Use `pictureOptions` parameter instead of `self.cdvUIImagePickerController.pictureOptions`

* fix(ios): Improve code for meta data processing in `resultForImage:``

- Fix: Use local variable `imageDataToWrite` instead of `self.data` to create the `CGImageSourceRef`. This code was wrong.
2026-04-20 18:17:13 +02:00
エリスandGitHub 571f1169fd chore(license): update header formatting (#958) 2026-03-24 13:52:15 +09:00
Manuel BeckandGitHub 59f421982f refactor(ios): processPHPickerImage: and retrieveImage: (#952)
- Remove redundant image processing code in `processPHPickerImage:`, which is already done in `retrieveImage:`
- Improve documentation
2026-02-04 14:57:51 +01:00
Manuel BeckandGitHub 1848db07ef ios: rename property pickerController to cdvUIImagePickerController (#949)
- Make clear that is a `CDVUIImagePickerController`
2026-01-30 19:19:49 +01:00
Manuel BeckandGitHub 77e85f2f08 ios! rename CDVCameraPicker to CDVUIImagePickerController (#948)
- Rename to `CDVUIImagePickerController ` since it inherits from `UIImagePickerController` and is not only for taking pictures
- This is a breaking change because it renames an externally visible interface.
2026-01-30 18:41:01 +01:00
Manuel BeckandGitHub b75cff893e ios: rename method finalizePHPickerImage: and document it (#947)
- Rename to `processPHPickerImage:` since it does rotating, scaling and cropping and prepare the metadata
- Document the method and code
2026-01-30 17:49:52 +01:00
Manuel BeckandGitHub 3c1268531e fix(ios): get correctly metadata with PHPicker (#944)
- `pickerResult.assetIdentifier` was wrongly used to get metadata, while `PHPickerConfiguration` was initialized with `init` which will not return any asset identifiers. Only `initWithPhotoLibrary:` would work. Since `init` is more flexible and lets the picker return items that aren’t PHAssets (e.g., cloud/shared providers) we use that and do not rely anymore on `assetIdentifier` to get the image data. The image data will now get by `[NSItemProvider loadDataRepresentationForTypeIdentifier:]` instead of `[PHImageManager requestImageDataAndOrientationForAsset:]`. The image data is needed to get meta data.
2026-01-29 20:11:08 +01:00
Manuel BeckandGitHub fe1896cf1e doc(ios): Document PHPickerConfigurationAssetRepresentationModeCurrent (#945) 2026-01-29 19:31:30 +01:00
Manuel BeckandGitHub d731cb9ad3 fix(ios): don't copy temporary video file on main thread and cleanup (#942)
- A user commented that`window.resolveLocalFileSystemURL` will fail when using the uri result for picking a video with PHPicker: https://github.com/apache/cordova-plugin-camera/issues/935#issuecomment-3742776758. The temporary video file provided by PHPickerViewController gets deleted when the completion handler exits. The copying of the video file was wrongly done on the main thread, rather than on the completion handler background thread.
- Report error to webview, if the video file could not successful copied to the temp directory

* Code refactoring and documentation

- Renamed `createTmpVideo` to `copyFileToTemp`, since it has no special code for just video files
- Log errors, if something is wrong in `copyFileToTemp `
- Document property `hasPendingOperation`
- Remove `dispatch_async` for returning `CDVPluginResult`. Internally, `CDVCommandDelegate` has a queue of plugin messages to send and it ensures that those are always sent to the webview on the main thread.
- Only use `dispatch_async(dispatch_get_main_queue(), ...` for UI operations
- Some minor code formatting for calling `CDVPluginResult` initializer
- Removed method `urlTransformer` which was deprecated in cordova-ios 8 and has no use anymore
- Removed unused method `integerValueForKey`: This method is legacy and was nowhere used
- Resolve method `processPHPickerImage`. This extra method is not needed
- Replace `IsAtLeastiOSVersion` with `@available`, `IsAtLeastiOSVersion` is deprecated
- Remove `IsAtLeastiOSVersion(@"8.0")` check for [locationManager requestWhenInUseAuthorization]. This plugins supports minimum iOS 11.
- Documentation and small refactoring regarding gettting GPS location for capturing JPEGs
- Use modern code for working with dictionaries
- fix: deprecation of `requestImageDataForAsset:options:resultHandler:`, which was deprecated in iOS 13. Replaced with `requestImageDataAndOrientationForAsset:options:resultHandler:`, which was introduced in iOS 11.

* Some cleanup regarding temporary file handling

- Renamed `createTmpVideo`to `copyFileToTemp` and keep the method generic, since it has no special code for video files
- Renamed `tempFilePath` to `tempFilePathForExtension`, since it creates unique path only for a file extension
- Document `tempFilePathForExtension`
- Refactoring and documentation of method `cleanup:`
- Moved `cleanup`, `tempFilePath` and `copyFileToTemp` at one place, since they are related
- creating unique temporary files with milliseconds: This is more precise than just using seconds
2026-01-29 14:08:55 +01:00
Manuel BeckandGitHub 90ad137398 fix(ios)! remove iPadOS popover code (#941)
- On iPadOS it was possible to configure a popover for setting the position, width and arrow position of the popover.  The code used the deprecated `UIPopoverController`, which would have to be fixed. To keep the plugin also maintainable, this was removed.
- The popover could repositioned with a `CameraPopoverHandle` on a `window.onorientationchange`. This was removed also.
- Removed documentation for popover from `README.md`
2026-01-15 17:26:37 +01:00
Manuel BeckandGitHub dc682b2532 feat(ios): use PHPickerViewController for iOS 14+ (#937)
- Does not need any permissions for reading images
- The PHPickerViewController class is an alternative to UIImagePickerController. PHPickerViewController improves stability and reliability, and includes several benefits to developers and users, such as the following:
- Deferred image loading and recovery UI
- Reliable handling of large and complex assets, like RAW and panoramic images
- User-selectable assets that aren’t available for UIImagePickerController
- Configuration of the picker to display only Live Photos
- Availability of PHLivePhoto objects without library access
- Stricter validations against invalid inputs
- See documentation of PHPickerViewController: https://developer.apple.com/documentation/photosui/phpickerviewcontroller?language=objc
- Added tests for PHPickerViewController in `CameraTest.m`

* Documentation and formatting

- Document `takePicture` and `showCameraPicker` in `CDVCamera.m`
- A pragmas for UIImagePickerControllerDelegate methods and CLLocationManager methods
- Format some long methods declarations to multi-line instead single-line for better readability
- Remove unnecessry `dispatch_async(dispatch_get_main_queue() ...` in `takePicture` before calling `showCameraPicker`. This is already done in `showCameraPicker`.
- Source out code for permission denied alert dialog when accessing the camera or UIImagePickerController on iOS < 14 for picking images

* feat(ios): proper formatting of methods

- Use linux brace style: A brace have to be on a new line for method declarations
- Remove unnecessary whitespaces in method declrations

* doc: readme update

- Better document usage descriptions
- `NSPhotoLibraryUsageDescription` not needed for iOS 14+ when only picking images
- Improve formatting for xml, js
- sourceType `SAVEDPHOTOALBUM` is the same as `PHOTOLIBRARY` on Android and iOS 14+
- Use `PHOTOLIBRARY` as sourceType instead of `SAVEDPHOTOALBUM` in  photo picker example

* Android: Document `SAVEDPHOTOALBUM``

- Make clear that `SAVEDPHOTOALBUM` is the same like `PHOTOLIBRARY` and has only an effect on iOS < 14
- Format code when creating image chooser and document the request code parameter
2026-01-13 08:33:59 +01:00
Norman BreauandGitHub 8864262022 fix(android): Error propagation when no Camera application is available (#926) 2025-03-20 16:13:02 -03:00
Norman BreauandGitHub 48c4cdd47f refactor(android): Make WRITE_EXTERNAL_STORAGE optional (#909)
* refactor(android): Rework permission management to make WRITE_EXTERNAL_STORAGE optional

* removed unused getPermissions API

* Proper error if WRITE_EXTERNAL_STORAGE is required but missing the declaration

* removed obsolete hasPermissions API
2024-10-28 15:21:37 -03:00
Norman BreauandGitHub c208754c08 refactor(android): remove query img usage (#907)
* refactor: remove unnecessary duplicate image checks and queryImgDb usage

* remove unused imageType parameter, because it's a private API anyway
2024-10-28 13:32:35 -03:00
Norman BreauandGitHub 0d86764b90 refactor(android): replace image path usage with image uris (#906)
* refactor(android): clean up image file path usages

* removed references of image paths in log messages
2024-10-28 12:35:50 -03:00
Norman BreauandGitHub 7adccc8ee9 fix(ios): Sync camera API return to match Android changes (#911) 2024-10-27 08:32:38 -03:00
Norman BreauandGitHub 53795454f4 fix(browser): Make data uri be returned as actual URI strings (#912) 2024-10-27 08:32:14 -03:00
Norman BreauandGitHub 2eaa9a3972 fix: return content uris when possible when selecting from gallery (#902) 2024-10-26 00:58:24 -03:00
Norman BreauandGitHub a672c31efb fix(android): Return data uris as an URI (#910) 2024-10-26 00:58:00 -03:00
Norman BreauandGitHub 16325102c7 fix(android): Improper serialization of image uri in save instance state (#903) 2024-10-25 13:59:29 -03:00
Norman BreauandGitHub 36bf8e7331 fix(android): improper cache path construction during image manipulation (#905) 2024-10-25 13:15:59 -03:00
Norman BreauandGitHub feb7643bc3 fix(android): Use VERSION_CODES instead of hard-coded API literals (#904) 2024-10-25 13:10:05 -03:00
Norman BreauandGitHub 44480300d9 fix(android): Isolate provider access to a subdirectory (#901) 2024-10-25 13:09:03 -03:00
faa4615ee0 Remove media permissions to make complaint with Android 14 requirements (#889)
Co-authored-by: Ravi Yakasiri <ravi.yakasiri@planonsoftware.com>
2024-10-24 13:38:18 -03:00
jcesarmobileandGitHub 20293f3d64 fix!: remove deprecated platforms (#848) 2023-09-01 00:34:30 +02:00
505ccefb4c feat(android)!: Android 13 support (#844)
* feat(android)!: Android 13 support
* refactor(android): simplify getPermissions logic
* feat(android)!: bump cordova-android requirement to >=12.0.0
* feat(android): update saveAlbumPermission to include Android 9 and below use case

---------

Co-authored-by: ochakov <evgeny@ochakov.com>
2023-08-26 20:21:32 +09:00
エリスandGitHub 61a6e9bb44 dep(dev)!: bump @cordova/eslint-config@5.0.0 (#846)
* dep(dev)!: bump @cordova/eslint-config@5.0.0
* chore: apply automatic lint fix
2023-08-18 00:59:25 +09:00
Norman BreauandGitHub 84166f6355 chore(android): Cleanup obsolete BuildConfig comments (#831) 2023-04-14 08:48:12 -03:00
2c09ade500 fix(android): set applicationId (#827)
Co-authored-by: Alexandre Alves <aalves@seamlink.com>
2023-04-14 08:06:30 -03:00
jcesarmobileandGitHub d0545c879f fix(browser): use navigator.mediaDevices.getUserMedia (#810) 2022-09-30 00:59:27 +02:00
Scott MurphyandGitHub 4608f8ef80 fix(ios): preserving EXIF data (#712) 2022-03-22 16:23:56 +09:00
e9db20e381 fix(android): return exception message (where it exists) (#687)
Co-authored-by: エリス <erisu@users.noreply.github.com>
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
2021-08-11 16:56:42 +09:00
c7971d9f63 fix(android): file path correction if Uri authority is FileProvider (#585)
Co-authored-by: Tim Brust <ratchet.player@gmx.de>
Co-authored-by: Francis Monier <contactpro@francismonier.com>
Co-authored-by: Norman Breau <norman@normanbreau.com>
2021-08-11 16:34:20 +09:00
エリスandGitHub 0227cdcf14 feat(android)!: support AndroidX (#751)
* feat: migrate FileProvider to androidx
* feat: add androidx.core:core with variable override ANDROIDX_CORE_VERSION
2021-08-09 23:09:29 +09:00
Pieter Van PoyerandGitHub 75bf807261 Bugfix issue 711 heic format (#731)
* Android - issue/711 - support .heic format
2021-08-09 15:36:58 +02:00
f704689200 Bugfix issue 665 (#700)
* GH-665 - store the imageFilePath when the app is paused (onSaveInstance) and restore it back.

* Update src/android/CameraLauncher.java whitespace layout

Co-authored-by: Tim Brust <github@timbrust.de>

Co-authored-by: Tim Brust <github@timbrust.de>
2021-02-02 14:43:26 -04:00
エリスandGitHub 8975171d7a chore(android): add missing apache license header (#686) 2020-11-04 10:12:19 +09:00
jcesarmobileandGitHub 2d1ee66a2b fix(ios): correctly append exif on iOS 14 (#685) 2020-10-28 18:47:10 +01:00
Pieter Van PoyerandGitHub ebe0517a24 Bugfix issue 341 save to photo gallery - Fixes #341, fixes #577 (#669)
* GH-341 - GH-577 Fixed the Save Photo To Album starting from camera - Android

- saveToPhotoAlbum feature fixed by taken into count content - uri. (writeUncompressedImage method) ( see: https://github.com/apache/cordova-plugin-camera/issues/611#issuecomment-700273405 )
- make saveToPhotoAlbum future proof by using the MediaStore to insert the taken image
- made a method to calculate the compressFormat based on the encodingType (JPEG or PNG)
- layout of the performCrop method is adjusted
- removed unused rotate variable inside processResultFromGallery method

* Add extra VO class to the plugin.xml

* added package declaration to new VO

* GH-341 - GH-577 https://github.com/apache/cordova-plugin-camera/pull/669#discussion_r504632953 listen to review
2020-10-16 23:48:22 -03:00
jcesarmobileandGitHub 0333d001c7 breaking: remove NATIVE_URI DestinationType (#637) 2020-08-07 14:38:05 +02:00
jcesarmobileandGitHub e2ecd7fe91 fix(android): return error if file url is null (#632) 2020-07-23 12:11:55 +02:00
eb7fc333ee fix(android): use provider prefix to avoid conflicts other plugin providers (#510)
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
2020-07-16 13:08:40 +02:00
jcesarmobileandGitHub fd155d9705 breaking(android): stop using CordovaUri helper class (#617) 2020-07-14 16:26:09 +02:00
エリスandGitHub 973bbbbac7 feat: migrate to @cordova/eslint-config@3.x (#629) 2020-07-14 19:15:29 +09:00
jcesarmobileandGitHub d89c25cd82 fix(ios): tempFilePath called twice if using CameraUsesGeolocation (#612) 2020-06-25 18:23:01 +02:00
Jesse MacFadyen df14414203 Cache images in device storage, devices have enough space now. 2020-04-28 13:57:00 -07:00
jcesarmobileandGitHub bfa38fed2c fix(ios): return copy of video when picking from gallery on iOS 13 (#580) 2020-04-15 11:41:21 +02:00