Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 6 additions & 7 deletions camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ with the camera.
pickImages(options: GalleryImageOptions) => Promise<GalleryPhotos>
```

Allows the user to pick multiple pictures from the photo gallery.
On iOS 13 and older it only allows to pick one picture.
Allows the user to pick multiplef pictures from the photo gallery.

| Param | Type |
| ------------- | ------------------------------------------------------------------- |
Expand All @@ -163,9 +162,9 @@ On iOS 13 and older it only allows to pick one picture.
pickLimitedLibraryPhotos() => Promise<GalleryPhotos>
```

iOS 14+ Only: Allows the user to update their limited photo library selection.
On iOS 15+ returns all the limited photos after the picker dismissal.
On iOS 14 or if the user gave full access to the photos it returns an empty array.
Allows the user to update their limited photo library selection.
Returns all the limited photos after the picker dismissal.
If instead the user gave full access to the photos it returns an empty array.

**Returns:** <code>Promise&lt;<a href="#galleryphotos">GalleryPhotos</a>&gt;</code>

Expand All @@ -180,7 +179,7 @@ On iOS 14 or if the user gave full access to the photos it returns an empty arra
getLimitedLibraryPhotos() => Promise<GalleryPhotos>
```

iOS 14+ Only: Return an array of photos selected from the limited photo library.
Return an array of photos selected from the limited photo library.

**Returns:** <code>Promise&lt;<a href="#galleryphotos">GalleryPhotos</a>&gt;</code>

Expand Down Expand Up @@ -244,7 +243,7 @@ Request camera and photo album permissions
| Prop | Type | Description | Default | Since |
| ------------------------ | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ----- |
| **`quality`** | <code>number</code> | The quality of image to return as JPEG, from 0-100 Note: This option is only supported on Android and iOS | | 1.0.0 |
| **`allowEditing`** | <code>boolean</code> | Whether to allow the user to crop or make small edits (platform specific). On iOS 14+ it's only supported for <a href="#camerasource">CameraSource.Camera</a>, but not for <a href="#camerasource">CameraSource.Photos</a>. | | 1.0.0 |
| **`allowEditing`** | <code>boolean</code> | Whether to allow the user to crop or make small edits (platform specific). On iOS it's only supported for <a href="#camerasource">CameraSource.Camera</a>, but not for <a href="#camerasource">CameraSource.Photos</a>. | | 1.0.0 |
| **`resultType`** | <code><a href="#cameraresulttype">CameraResultType</a></code> | How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported | | 1.0.0 |
| **`saveToGallery`** | <code>boolean</code> | Whether to save the photo to the gallery. If the photo was picked from the gallery, it will only be saved if edited. | <code>: false</code> | 1.0.0 |
| **`width`** | <code>number</code> | The desired maximum width of the saved image. The aspect ratio is respected. | | 1.0.0 |
Expand Down
121 changes: 45 additions & 76 deletions camera/ios/Sources/CameraPlugin/CameraPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ public class CameraPlugin: CAPPlugin, CAPBridgedPlugin {
case .camera:
state = AVCaptureDevice.authorizationStatus(for: .video).authorizationState
case .photos:
if #available(iOS 14, *) {
state = PHPhotoLibrary.authorizationStatus(for: .readWrite).authorizationState
} else {
state = PHPhotoLibrary.authorizationStatus().authorizationState
}
state = PHPhotoLibrary.authorizationStatus(for: .readWrite).authorizationState
Copy link
Member

Choose a reason for hiding this comment

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

This stuff all has async/await support now, but we should do that refactor separately. But we should mark down that it needs doing.

}
result[permission.rawValue] = state
}
Expand All @@ -60,14 +56,8 @@ public class CameraPlugin: CAPPlugin, CAPBridgedPlugin {
}
case .photos:
group.enter()
if #available(iOS 14, *) {
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (_) in
group.leave()
}
} else {
PHPhotoLibrary.requestAuthorization({ (_) in
group.leave()
})
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (_) in
group.leave()
}
}
}
Expand All @@ -77,77 +67,62 @@ public class CameraPlugin: CAPPlugin, CAPBridgedPlugin {
}

@objc func pickLimitedLibraryPhotos(_ call: CAPPluginCall) {
if #available(iOS 14, *) {
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (granted) in
if granted == .limited {
if let viewController = self.bridge?.viewController {
if #available(iOS 15, *) {
PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: viewController) { _ in
self.getLimitedLibraryPhotos(call)
}
} else {
PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: viewController)
call.resolve([
"photos": []
])
}
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (granted) in
if granted == .limited {
if let viewController = self.bridge?.viewController {
PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: viewController) { _ in
self.getLimitedLibraryPhotos(call)
}
} else {
call.resolve([
"photos": []
])
}
} else {
call.resolve([
"photos": []
])
}
} else {
call.unavailable("Not available on iOS 13")
}
}

@objc func getLimitedLibraryPhotos(_ call: CAPPluginCall) {
if #available(iOS 14, *) {
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (granted) in
if granted == .limited {

self.call = call

DispatchQueue.global(qos: .utility).async {
let assets = PHAsset.fetchAssets(with: .image, options: nil)
var processedImages: [ProcessedImage] = []

let imageManager = PHImageManager.default()
let options = PHImageRequestOptions()
options.deliveryMode = .highQualityFormat

let group = DispatchGroup()
if assets.count > 0 {
for index in 0...(assets.count - 1) {
let asset = assets.object(at: index)
let fullSize = CGSize(width: asset.pixelWidth, height: asset.pixelHeight)

group.enter()
imageManager.requestImage(for: asset, targetSize: fullSize, contentMode: .default, options: options) { image, _ in
guard let image = image else {
group.leave()
return
}
processedImages.append(self.processedImage(from: image, with: asset.imageData))
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (granted) in
if granted == .limited {

self.call = call

DispatchQueue.global(qos: .utility).async {
let assets = PHAsset.fetchAssets(with: .image, options: nil)
var processedImages: [ProcessedImage] = []

let imageManager = PHImageManager.default()
let options = PHImageRequestOptions()
options.deliveryMode = .highQualityFormat

let group = DispatchGroup()
if assets.count > 0 {
for index in 0...(assets.count - 1) {
let asset = assets.object(at: index)
let fullSize = CGSize(width: asset.pixelWidth, height: asset.pixelHeight)

group.enter()
imageManager.requestImage(for: asset, targetSize: fullSize, contentMode: .default, options: options) { image, _ in
guard let image = image else {
group.leave()
return
}
processedImages.append(self.processedImage(from: image, with: asset.imageData))
group.leave()
}
}
}

group.notify(queue: .global(qos: .utility)) { [weak self] in
self?.returnImages(processedImages)
}
group.notify(queue: .global(qos: .utility)) { [weak self] in
self?.returnImages(processedImages)
}
} else {
call.resolve([
"photos": []
])
}
} else {
call.resolve([
"photos": []
])
}
} else {
call.unavailable("Not available on iOS 13")
}
}

Expand Down Expand Up @@ -252,7 +227,6 @@ extension CameraPlugin: UIImagePickerControllerDelegate, UINavigationControllerD
}
}

@available(iOS 14, *)
extension CameraPlugin: PHPickerViewControllerDelegate {
public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
picker.dismiss(animated: true, completion: nil)
Expand Down Expand Up @@ -490,11 +464,7 @@ private extension CameraPlugin {
}

func presentSystemAppropriateImagePicker() {
if #available(iOS 14, *) {
presentPhotoPicker()
} else {
presentImagePicker()
}
presentPhotoPicker()
}

func presentImagePicker() {
Expand All @@ -512,7 +482,6 @@ private extension CameraPlugin {
bridge?.viewController?.present(picker, animated: true, completion: nil)
}

@available(iOS 14, *)
func presentPhotoPicker() {
var configuration = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared())
configuration.selectionLimit = self.multiple ? (self.call?.getInt("limit") ?? 0) : 1
Expand Down
13 changes: 6 additions & 7 deletions camera/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,22 @@ export interface CameraPlugin {
getPhoto(options: ImageOptions): Promise<Photo>;

/**
* Allows the user to pick multiple pictures from the photo gallery.
* On iOS 13 and older it only allows to pick one picture.
* Allows the user to pick multiplef pictures from the photo gallery.
*
* @since 1.2.0
*/
pickImages(options: GalleryImageOptions): Promise<GalleryPhotos>;

/**
* iOS 14+ Only: Allows the user to update their limited photo library selection.
* On iOS 15+ returns all the limited photos after the picker dismissal.
* On iOS 14 or if the user gave full access to the photos it returns an empty array.
* Allows the user to update their limited photo library selection.
* Returns all the limited photos after the picker dismissal.
* If instead the user gave full access to the photos it returns an empty array.
*
* @since 4.1.0
*/
pickLimitedLibraryPhotos(): Promise<GalleryPhotos>;
/**
* iOS 14+ Only: Return an array of photos selected from the limited photo library.
* Return an array of photos selected from the limited photo library.
*
* @since 4.1.0
*/
Expand Down Expand Up @@ -72,7 +71,7 @@ export interface ImageOptions {
quality?: number;
/**
* Whether to allow the user to crop or make small edits (platform specific).
* On iOS 14+ it's only supported for CameraSource.Camera, but not for CameraSource.Photos.
* On iOS it's only supported for CameraSource.Camera, but not for CameraSource.Photos.
*
* @since 1.0.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,8 @@ public String getWebViewVersion() {
return android.os.Build.VERSION.RELEASE;
}

@SuppressWarnings("deprecation")
private PackageInfo getWebViewVersionSubAndroid26() throws PackageManager.NameNotFoundException {
String webViewPackage = "com.google.android.webview";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
webViewPackage = "com.android.chrome";
}
PackageManager pm = this.context.getPackageManager();
return pm.getPackageInfo(webViewPackage, 0);
return pm.getPackageInfo("com.android.chrome", 0);
}
}
10 changes: 5 additions & 5 deletions keyboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ Remove all native listeners for this plugin.

#### KeyboardStyle

| Members | Value | Description | Since |
| ------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`Dark`** | <code>'DARK'</code> | Dark keyboard. | 1.0.0 |
| **`Light`** | <code>'LIGHT'</code> | Light keyboard. | 1.0.0 |
| **`Default`** | <code>'DEFAULT'</code> | On iOS 13 and newer the keyboard style is based on the device appearance. If the device is using Dark mode, the keyboard will be dark. If the device is using Light mode, the keyboard will be light. On iOS 12 the keyboard will be light. | 1.0.0 |
| Members | Value | Description | Since |
| ------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`Dark`** | <code>'DARK'</code> | Dark keyboard. | 1.0.0 |
| **`Light`** | <code>'LIGHT'</code> | Light keyboard. | 1.0.0 |
| **`Default`** | <code>'DEFAULT'</code> | The keyboard style is based on the device appearance. If the device is using Dark mode, the keyboard will be dark. If the device is using Light mode, the keyboard will be light. | 1.0.0 |


#### KeyboardResize
Expand Down
3 changes: 1 addition & 2 deletions keyboard/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ export enum KeyboardStyle {
Light = 'LIGHT',

/**
* On iOS 13 and newer the keyboard style is based on the device appearance.
* The keyboard style is based on the device appearance.
* If the device is using Dark mode, the keyboard will be dark.
* If the device is using Light mode, the keyboard will be light.
* On iOS 12 the keyboard will be light.
*
* @since 1.0.0
*/
Expand Down
Loading
Loading