Skip to content

Commit

Permalink
Revert "fix!: remove deprecated platforms (apache#848)"
Browse files Browse the repository at this point in the history
This reverts commit 20293f3.
  • Loading branch information
bniciakhexagon committed Oct 4, 2023
1 parent 606f47e commit a998bff
Show file tree
Hide file tree
Showing 7 changed files with 1,239 additions and 4 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ __Supported Platforms__
- Android
- Browser
- iOS
- Windows
- OSX

More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks).

Expand Down Expand Up @@ -474,6 +476,16 @@ displays:
// do your thing here!
}, 0);

#### Windows quirks

On Windows Phone 8.1 using `SAVEDPHOTOALBUM` or `PHOTOLIBRARY` as a source type causes application to suspend until file picker returns the selected image and
then restore with start page as defined in app's `config.xml`. In case when `camera.getPicture` was called from different page, this will lead to reloading
start page from scratch and success and error callbacks will never be called.

To avoid this we suggest using SPA pattern or call `camera.getPicture` only from your app's start page.

More information about Windows Phone 8.1 picker APIs is here: [How to continue your Windows Phone app after calling a file picker](https://msdn.microsoft.com/en-us/library/windows/apps/dn720490.aspx)

## `CameraOptions` Errata <a name="CameraOptions-quirks"></a>

#### Android Quirks
Expand Down Expand Up @@ -559,6 +571,12 @@ function displayImage(imgUri) {
}
```

To display the image on some platforms, you might need to include the main part of the URI in the Content-Security-Policy `<meta>` element in index.html. For example, on Windows 10, you can include `ms-appdata:` in your `<meta>` element. Here is an example.

```html
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: ms-appdata: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
```

## Take a Picture and Return Thumbnails (Resize the Picture) <a name="getThumbnails"></a>

To get smaller images, you can return a resized image by passing both `targetHeight` and `targetWidth` values with your CameraOptions object. In this example, you resize the returned image to fit in a 100px by 100px box (the aspect ratio is maintained, so 100px is either the height or width, whichever is greater in the source).
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"platforms": [
"android",
"ios",
"browser"
"browser",
"windows",
"osx"
]
},
"repository": "github:apache/cordova-plugin-camera",
Expand All @@ -19,7 +21,9 @@
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"cordova-browser"
"cordova-browser",
"cordova-windows",
"cordova-osx"
],
"scripts": {
"test": "npm run lint",
Expand Down
80 changes: 80 additions & 0 deletions src/osx/CDVCamera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <Quartz/Quartz.h>
#import <AppKit/AppKit.h>
#import <Cordova/CDVPlugin.h>



enum CDVDestinationType {
DestinationTypeDataUrl = 0,
DestinationTypeFileUri
};
typedef NSUInteger CDVDestinationType;

enum CDVSourceType {
SourceTypePhotoLibrary = 0,
SourceTypeCamera,
SourceTypePhotoAlbum
};
typedef NSUInteger CDVSourceType;

enum CDVEncodingType {
EncodingTypeJPEG = 0,
EncodingTypePNG
};
typedef NSUInteger CDVEncodingType;

enum CDVMediaType {
MediaTypePicture = 0,
MediaTypeVideo,
MediaTypeAll
};
typedef NSUInteger CDVMediaType;


// ======================================================================= //


@interface CDVPictureOptions : NSObject

@property (strong) NSNumber *quality;
@property (assign) CDVDestinationType destinationType;
@property (assign) CDVSourceType sourceType;
@property (assign) CGSize targetSize;
@property (assign) CDVEncodingType encodingType;
@property (assign) CDVMediaType mediaType;
@property (assign) BOOL allowsEditing;
@property (assign) BOOL correctOrientation;
@property (assign) BOOL saveToPhotoAlbum;

+ (instancetype) createFromTakePictureArguments:(CDVInvokedUrlCommand *)command;

@end


// ======================================================================= //


@interface CDVCamera : CDVPlugin

- (void)takePicture:(CDVInvokedUrlCommand *)command;
- (void)cleanup:(CDVInvokedUrlCommand *)command;

@end
Loading

0 comments on commit a998bff

Please sign in to comment.