Skip to content

Commit

Permalink
Merge commit 'c4feee0846830308a38154b9c1538031b374e2b8' into ios-loca…
Browse files Browse the repository at this point in the history
…tion-aware-camera-5.x

* commit 'c4feee0846830308a38154b9c1538031b374e2b8':
  fix(ios): apply filter to fetch correct scene object (ionic-team#2103)
  fix(ios): Picking ProRAW pictures from Gallery (ionic-team#2098) (ionic-team#2099)
  fix(android): removes setOnExitAnimationListener when fade out is disabled
  fix(ios): iOS panorama photos selected through CameraPlugin are corrupted (ionic-team#2088)
  bug(@capacitor/screen-orientation): iOS landscape lock using incorrect mappings (ionic-team#2049)
  chore: Update install instructions with latest-5 tag (ionic-team#2084)
  chore: publish as latest-5 (ionic-team#2081)
  • Loading branch information
NetEvolutions committed May 27, 2024
2 parents bb6ca86 + c4feee0 commit 4c4407a
Show file tree
Hide file tree
Showing 29 changed files with 90 additions and 89 deletions.
2 changes: 1 addition & 1 deletion app-launcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Example:
## Install

```bash
npm install @capacitor/app-launcher
npm install @capacitor/app-launcher@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The App API handles high level App state and events. For example, this API emits
## Install

```bash
npm install @capacitor/app
npm install @capacitor/app@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ On iOS, this uses `SFSafariViewController` and is compliant with leading OAuth s
## Install

```bash
npm install @capacitor/browser
npm install @capacitor/browser@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Camera API provides the ability to take a photo with the camera or choose an
## Install

```bash
npm install @capacitor/camera
npm install @capacitor/camera@latest-5
npx cap sync
```

Expand Down
12 changes: 5 additions & 7 deletions camera/ios/Plugin/CameraExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ internal extension UIImage {
targetHeight = maxHeight
}
// generate the new image and return
let format: UIGraphicsImageRendererFormat = UIGraphicsImageRendererFormat.default()
format.scale = 1.0
format.opaque = false
let renderer = UIGraphicsImageRenderer(size: CGSize(width: targetWidth, height: targetHeight), format: format)
return renderer.image { (_) in
self.draw(in: CGRect(origin: .zero, size: CGSize(width: targetWidth, height: targetHeight)))
}
UIGraphicsBeginImageContextWithOptions(.init(width: targetWidth, height: targetHeight), false, 1.0) // size, opaque and scale
self.draw(in: .init(origin: .zero, size: .init(width: targetWidth, height: targetHeight)))
let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return resizedImage ?? self
}
}
90 changes: 46 additions & 44 deletions camera/ios/Plugin/CameraPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,59 +247,61 @@ extension CameraPlugin: UIImagePickerControllerDelegate, UINavigationControllerD
extension CameraPlugin: PHPickerViewControllerDelegate {
public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
picker.dismiss(animated: true, completion: nil)
guard let result = results.first else {

guard !results.isEmpty else {
self.call?.reject("User cancelled photos app")
return
}
if multiple {
var images: [ProcessedImage] = []
var processedCount = 0
for img in results {
guard img.itemProvider.canLoadObject(ofClass: UIImage.self) else {
self.call?.reject("Error loading image")
return
}
// extract the image
img.itemProvider.loadObject(ofClass: UIImage.self) { [weak self] (reading, _) in
if let image = reading as? UIImage {
var asset: PHAsset?
if let assetId = img.assetIdentifier {
asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
}
if let processedImage = self?.processedImage(from: image, with: asset?.imageData) {
images.append(processedImage)
}
processedCount += 1
if processedCount == results.count {
self?.returnImages(images)
}
} else {
self?.call?.reject("Error loading image")
}
}
}

} else {
guard result.itemProvider.canLoadObject(ofClass: UIImage.self) else {
self.call?.reject("Error loading image")

self.fetchProcessedImages(from: results) { [weak self] processedImageArray in
guard let processedImageArray else {
self?.call?.reject("Error loading image")
return
}
// extract the image
result.itemProvider.loadObject(ofClass: UIImage.self) { [weak self] (reading, _) in
if let image = reading as? UIImage {
var asset: PHAsset?
if let assetId = result.assetIdentifier {
asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
}
if var processedImage = self?.processedImage(from: image, with: asset?.imageData) {
processedImage.flags = .gallery
self?.returnProcessedImage(processedImage)
return

if self?.multiple == true {
self?.returnImages(processedImageArray)
} else if var processedImage = processedImageArray.first {
processedImage.flags = .gallery
self?.returnProcessedImage(processedImage)
}
}
}

private func fetchProcessedImages(from pickerResultArray: [PHPickerResult], accumulating: [ProcessedImage] = [], _ completionHandler: @escaping ([ProcessedImage]?) -> Void) {
func loadImage(from pickerResult: PHPickerResult,_ completionHandler: @escaping (UIImage?) -> Void) {
let itemProvider = pickerResult.itemProvider
if itemProvider.canLoadObject(ofClass: UIImage.self) {
// extract the image
itemProvider.loadObject(ofClass: UIImage.self) { itemProviderReading, _ in
completionHandler(itemProviderReading as? UIImage)
}
} else {
// extract the image's data representation
itemProvider.loadDataRepresentation(forTypeIdentifier: UTType.image.identifier) { data, _ in
guard let data else {
return completionHandler(nil)
}
completionHandler(UIImage(data: data))
}
self?.call?.reject("Error loading image")
}
}

guard let currentPickerResult = pickerResultArray.first else { return completionHandler(accumulating) }

loadImage(from: currentPickerResult) { [weak self] loadedImage in
guard let self, let loadedImage else { return completionHandler(nil) }
var asset: PHAsset?
if let assetId = currentPickerResult.assetIdentifier {
asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
}
let newElement = self.processedImage(from: loadedImage, with: asset?.imageData)
self.fetchProcessedImages(
from: Array(pickerResultArray.dropFirst()),
accumulating: accumulating + [newElement],
completionHandler
)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion clipboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Clipboard API enables copy and pasting to/from the system clipboard.
## Install

```bash
npm install @capacitor/clipboard
npm install @capacitor/clipboard@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion device/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Device API exposes internal information about the device, such as the model
## Install

```bash
npm install @capacitor/device
npm install @capacitor/device@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Dialog API provides methods for triggering native dialog windows for alerts,
## Install

```bash
npm install @capacitor/dialog
npm install @capacitor/dialog@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion filesystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Filesystem API provides a NodeJS-like API for working with files on the devi
## Install

```bash
npm install @capacitor/filesystem
npm install @capacitor/filesystem@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion geolocation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Geolocation API provides simple methods for getting and tracking the current
## Install

```bash
npm install @capacitor/geolocation
npm install @capacitor/geolocation@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion haptics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ On devices that don't have Taptic Engine or Vibrator, the API calls will resolve
## Install

```bash
npm install @capacitor/haptics
npm install @capacitor/haptics@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion keyboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Keyboard API provides keyboard display and visibility control, along with ev
## Install

```bash
npm install @capacitor/keyboard
npm install @capacitor/keyboard@latest-5
npx cap sync
```

Expand Down
3 changes: 2 additions & 1 deletion keyboard/ios/Plugin/Keyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ - (void)_updateFrame

if (!window) {
if (@available(iOS 13.0, *)) {
UIScene *scene = [UIApplication sharedApplication].connectedScenes.allObjects.firstObject;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self isKindOfClass: %@", UIWindowScene.class];
UIScene *scene = [UIApplication.sharedApplication.connectedScenes.allObjects filteredArrayUsingPredicate:predicate].firstObject;
window = [[(UIWindowScene*)scene windows] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isKeyWindow == YES"]].firstObject;
}
}
Expand Down
2 changes: 1 addition & 1 deletion local-notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Local Notifications API provides a way to schedule device notifications loca
## Install

```bash
npm install @capacitor/local-notifications
npm install @capacitor/local-notifications@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion motion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Motion API tracks accelerometer and device orientation (compass heading, etc
## Install

```bash
npm install @capacitor/motion
npm install @capacitor/motion@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Network API provides network and connectivity information.
## Install

```bash
npm install @capacitor/network
npm install @capacitor/network@latest-5
npx cap sync
```

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"ci:publish:alpha": "lerna publish prerelease --conventional-commits --conventional-prerelease --preid alpha --force-publish --dist-tag next-5 --yes",
"ci:publish:beta": "lerna publish prerelease --conventional-commits --conventional-prerelease --preid beta --force-publish --dist-tag next-5 --yes",
"ci:publish:rc": "lerna publish prerelease --conventional-commits --conventional-prerelease --preid rc --force-publish --dist-tag next-5 --yes",
"ci:publish:latest": "lerna publish --conventional-commits --dist-tag latest --no-verify-access --yes",
"ci:publish:latest-from-pre": "lerna publish --conventional-graduate --conventional-commits --dist-tag latest --no-verify-access --force-publish --yes",
"ci:publish:latest": "lerna publish --conventional-commits --dist-tag latest-5 --no-verify-access --yes",
"ci:publish:latest-from-pre": "lerna publish --conventional-graduate --conventional-commits --dist-tag latest-5 --no-verify-access --force-publish --yes",
"ci:publish:dev": "lerna publish prerelease --conventional-commits --conventional-prerelease --preid dev-$(date +\"%Y%m%dT%H%M%S\") --force-publish --no-changelog --no-git-tag-version --dist-tag dev-5 --no-push --yes"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion preferences/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ we recommend taking a look at a SQLite-based solution. One such solution is [Ion
## Install

```bash
npm install @capacitor/preferences
npm install @capacitor/preferences@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion push-notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Push Notifications API provides access to native push notifications.
## Install

```bash
npm install @capacitor/push-notifications
npm install @capacitor/push-notifications@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion screen-orientation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Screen Orientation API provides information and functionality related to the
## Install

```bash
npm install @capacitor/screen-orientation
npm install @capacitor/screen-orientation@latest-5
npx cap sync
```

Expand Down
16 changes: 12 additions & 4 deletions screen-orientation/ios/Plugin/ScreenOrientation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ public class ScreenOrientation: NSObject {
case "any":
return UIInterfaceOrientationMask.all
case "landscape", "landscape-primary":
return UIInterfaceOrientationMask.landscapeLeft
case "landscape-secondary":
// UIInterfaceOrientationMask.landscapeRight is the same as UIDeviceOrientation.landscapeLeft
return UIInterfaceOrientationMask.landscapeRight
case "landscape-secondary":
// UIInterfaceOrientationMask.landscapeLeft is the same as UIDeviceOrientation.landscapeRight
return UIInterfaceOrientationMask.landscapeLeft
case "portrait-secondary":
return UIInterfaceOrientationMask.portraitUpsideDown
default:
Expand All @@ -101,9 +103,15 @@ public class ScreenOrientation: NSObject {
case "any":
return UIInterfaceOrientation.unknown.rawValue
case "landscape", "landscape-primary":
return UIInterfaceOrientation.landscapeLeft.rawValue
case "landscape-secondary":
// UIInterfaceOrientation.landscapeRight is the same as UIDeviceOrientation.landscapeLeft
// @see https://developer.apple.com/documentation/uikit/uiinterfaceorientation/landscaperight
// @see https://developer.apple.com/documentation/uikit/uideviceorientation/landscapeleft
return UIInterfaceOrientation.landscapeRight.rawValue
case "landscape-secondary":
// UIInterfaceOrientation.landscapeLeft is the same as UIDeviceOrientation.landscapeRight
// @see https://developer.apple.com/documentation/uikit/uiinterfaceorientation/landscapeleft
// @see https://developer.apple.com/documentation/uikit/uideviceorientation/landscaperight
return UIInterfaceOrientation.landscapeLeft.rawValue
case "portrait-secondary":
return UIInterfaceOrientation.portraitUpsideDown.rawValue
default:
Expand Down
2 changes: 1 addition & 1 deletion screen-reader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Screen Reader API provides access to TalkBack/VoiceOver/etc. and provides si
## Install

```bash
npm install @capacitor/screen-reader
npm install @capacitor/screen-reader@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion share/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ API](https://web.dev/web-share/)), though web support is currently spotty.
## Install

```bash
npm install @capacitor/share
npm install @capacitor/share@latest-5
npx cap sync
```
## Android
Expand Down
2 changes: 1 addition & 1 deletion splash-screen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Splash Screen API provides methods for showing or hiding a Splash image.
## Install

```bash
npm install @capacitor/splash-screen
npm install @capacitor/splash-screen@latest-5
npx cap sync
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,6 @@ public void onAnimationEnd(Animator animation) {
isVisible = false;
}
);
} else {
windowSplashScreen.setOnExitAnimationListener(
windowSplashScreenView -> {
isHiding = false;
isVisible = false;
windowSplashScreenView.remove();
}
);
}

// Set Pre Draw Listener & Delay Drawing Until Duration Elapses
Expand Down
2 changes: 1 addition & 1 deletion status-bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The StatusBar API Provides methods for configuring the style of the Status Bar,
## Install

```bash
npm install @capacitor/status-bar
npm install @capacitor/status-bar@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion text-zoom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The Text Zoom API provides the ability to change Web View text size for visual a
## Install

```bash
npm install @capacitor/text-zoom
npm install @capacitor/text-zoom@latest-5
npx cap sync
```

Expand Down
2 changes: 1 addition & 1 deletion toast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Toast API provides a notification pop up for displaying important informatio
## Install

```bash
npm install @capacitor/toast
npm install @capacitor/toast@latest-5
npx cap sync
```

Expand Down

0 comments on commit 4c4407a

Please sign in to comment.