Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera #33

Merged
merged 71 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
2eff57f
Initial recreation.
ikeith Nov 9, 2020
042474c
Adding license, lerna package
ikeith Sep 3, 2020
066c342
Importing
ikeith Nov 10, 2020
a6b4e12
Updating gradle file, docgen result
ikeith Nov 11, 2020
2f6ed22
Migrated to new permission annotation on android.
ikeith Nov 17, 2020
2990dba
Matching iOS permission types to android
ikeith Nov 17, 2020
d34c9ca
Export iOS methods
ikeith Nov 17, 2020
4d4e37a
Adding web definitions and implementation for permissions.
ikeith Nov 17, 2020
f7d3bbd
Code formatting
ikeith Nov 17, 2020
44dc648
Update camera/android/src/main/java/com/capacitorjs/plugins/camera/Ca…
ikeith Nov 19, 2020
26c25cd
Update camera/android/src/main/java/com/capacitorjs/plugins/camera/Ca…
ikeith Nov 19, 2020
cdf8d90
Update camera/android/src/main/java/com/capacitorjs/plugins/camera/Ca…
ikeith Nov 25, 2020
4436d33
Update camera/android/src/main/java/com/capacitorjs/plugins/camera/Ca…
ikeith Nov 25, 2020
5b9098d
Updating plugin registration for runtime refactor.
ikeith Nov 25, 2020
c6d9904
Updating methods for alpha.
ikeith Nov 25, 2020
5fd7614
Removing logging code.
ikeith Dec 2, 2020
b189933
Avoiding exception by setting source type, fixing logic bugs.
ikeith Dec 2, 2020
e58b1b4
Updating to latest path methods.
ikeith Dec 2, 2020
da26eee
Removing deprecated calls.
ikeith Dec 2, 2020
ec9091b
minor cleanup
ikeith Dec 2, 2020
4c58bc0
Use stream to get exif data.
ikeith Dec 2, 2020
c5d5711
Updating permissions.
ikeith Dec 2, 2020
312157a
Fmt
ikeith Dec 2, 2020
68384de
Exposing 'limited' permissions state.
ikeith Dec 3, 2020
1c20ee4
Adopting new iOS 14 APIs.
ikeith Dec 3, 2020
5421b54
Merge branch 'main' into camera
ikeith Dec 3, 2020
1fe4305
Fmt
ikeith Dec 3, 2020
f736146
Updating dependencies to alpha 7
ikeith Dec 3, 2020
ac4a0da
Merge branch 'main' into camera
ikeith Dec 3, 2020
69a1fae
update gradle wrapper and plugin
jcesarmobile Dec 3, 2020
f973808
remove bridge_layout_main.xml
jcesarmobile Dec 3, 2020
921496d
Removed contributing.md file.
ikeith Dec 3, 2020
4b82a66
Update camera/package.json
ikeith Dec 3, 2020
ca49f3c
Update camera/package.json
ikeith Dec 3, 2020
3d9cd51
Merge branch 'camera' of github.com:ionic-team/capacitor-plugins into…
ikeith Dec 3, 2020
a9c2028
Updating gradle file to use version variables.
ikeith Dec 3, 2020
7a791f6
Fix error handling
ikeith Dec 3, 2020
4674a34
Updating JSDoc comments
ikeith Dec 3, 2020
85bc009
Removing unused file.
ikeith Dec 3, 2020
9d575d9
Fixing build.gradle file.
ikeith Dec 3, 2020
e9752c9
Merge branch 'main' into camera
jcesarmobile Dec 4, 2020
869f412
Removing unneeded dependency.
ikeith Dec 4, 2020
dda75ac
Updating package.json
ikeith Dec 4, 2020
1031f56
Removing Xcode 11 support
ikeith Dec 4, 2020
bbdafb0
Fixing argument name, adding centering for alert.
ikeith Dec 4, 2020
4ef3fea
Defaulting photo permissions to `granted` on the web.
ikeith Dec 4, 2020
0cc8310
Making arguments optional on requestPermissions.
ikeith Dec 4, 2020
835e646
Updating doc comments.
ikeith Dec 4, 2020
4b5f1c0
Updated deprecated call for bottom sheet.
ikeith Dec 4, 2020
c657851
Updating documentation comments.
ikeith Dec 7, 2020
aca99a8
Fmt
ikeith Dec 7, 2020
97dae9b
Update camera/ios/Plugin/CameraPlugin.swift
ikeith Dec 7, 2020
582bda7
Fix for conflicting mutations of a captured variable, incorrect resul…
ikeith Dec 7, 2020
7c57f28
Merge branch 'main' into camera
ikeith Dec 7, 2020
4a05581
Merge branch 'main' into camera
ikeith Dec 7, 2020
5086434
Updated to support permission override (requires latest capacitor code).
ikeith Dec 8, 2020
3b7600b
Fmt
ikeith Dec 9, 2020
f9378b2
Merge branch 'main' into camera
ikeith Dec 11, 2020
1351a8d
Updated readme
ikeith Dec 11, 2020
b53456f
Update permissions handling
ikeith Dec 11, 2020
fe0c3a0
Fmt
ikeith Dec 11, 2020
56c2443
Merge branch 'main' into camera
imhoffd Dec 15, 2020
e18c466
Updating to alpha 10
ikeith Dec 15, 2020
b123a61
Fixed alpha versions
ikeith Dec 15, 2020
167a628
Merge branch 'main' into camera
imhoffd Dec 16, 2020
e337b1a
Imported PermissionState from @capacitor/core
ikeith Dec 16, 2020
e84cb5e
Merge branch 'main' into camera
ikeith Dec 16, 2020
160dbfa
Merge branch 'main' into camera
imhoffd Dec 16, 2020
b4cf552
docgen update
imhoffd Dec 16, 2020
3dee0d9
Merge branch 'main' into camera
imhoffd Dec 16, 2020
ce8fa9e
Merge branch 'main' into camera
imhoffd Dec 17, 2020
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
2 changes: 2 additions & 0 deletions camera/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
61 changes: 61 additions & 0 deletions camera/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# node files
dist
node_modules

# iOS files
Pods
Podfile.lock
Build
xcuserdata

# macOS files
.DS_Store



# Based on Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin
gen
out

# Gradle files
.gradle
build

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation

# Android Studio captures folder
captures

# IntelliJ
*.iml
.idea

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
2 changes: 2 additions & 0 deletions camera/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
17 changes: 17 additions & 0 deletions camera/CapacitorCamera.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = 'CapacitorCamera'
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.homepage = package['repository']['url']
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '11.0'
s.dependency 'Capacitor'
s.swift_version = '5.1'
end
23 changes: 23 additions & 0 deletions camera/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright 2020-present Ionic
https://ionic.io

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
131 changes: 131 additions & 0 deletions camera/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# @capacitor/camera

The Camera API provides the ability to take a photo with the camera or choose an existing one from the photo album.

## Install

```bash
npm install @capacitor/camera
npx cap sync
```

## API

<docgen-index>

* [`getPhoto(...)`](#getphoto)
* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions(...)`](#requestpermissions)
* [Interfaces](#interfaces)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### getPhoto(...)

```typescript
getPhoto(options: CameraOptions) => Promise<CameraPhoto>
```

Prompt the user to pick a photo from an album, or take a new photo
with the camera.

| Param | Type |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#cameraoptions">CameraOptions</a></code> |

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

**Since:** 1.0.0

--------------------


### checkPermissions()

```typescript
checkPermissions() => Promise<CameraPermissionStatus>
```

Check camera and photo album permissions

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

**Since:** 1.0.0

--------------------


### requestPermissions(...)

```typescript
requestPermissions(permissions?: CameraPluginPermissions | undefined) => Promise<CameraPermissionStatus>
```

Request camera and photo album permissions

| Param | Type |
| ----------------- | --------------------------------------------------------------------------- |
| **`permissions`** | <code><a href="#camerapluginpermissions">CameraPluginPermissions</a></code> |

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

**Since:** 1.0.0

--------------------


### Interfaces


#### CameraPhoto

| Prop | Type | Description | Since |
| ------------------ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`base64String`** | <code>string</code> | The base64 encoded string representation of the image, if using CameraResultType.Base64. | 1.0.0 |
| **`dataUrl`** | <code>string</code> | The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl. | 1.0.0 |
| **`path`** | <code>string</code> | If using CameraResultType.Uri, the path will contain a full, platform-specific file URL that can be read later using the Filsystem API. | 1.0.0 |
| **`webPath`** | <code>string</code> | webPath returns a path that can be used to set the src attribute of an image for efficient loading and rendering. | 1.0.0 |
| **`exif`** | <code>any</code> | Exif data, if any, retrieved from the image | 1.0.0 |
| **`format`** | <code>string</code> | The format of the image, ex: jpeg, png, gif. iOS and Android only support jpeg. Web supports jpeg and png. gif is only supported if using file input. | 1.0.0 |


#### CameraOptions

| Prop | Type | Description | Default | Since |
| ------------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ----- |
| **`quality`** | <code>number</code> | The quality of image to return as JPEG, from 0-100 | | 1.0.0 |
| **`allowEditing`** | <code>boolean</code> | Whether to allow the user to crop or make small edits (platform specific) | | 1.0.0 |
| **`resultType`** | <code>"uri" \| "base64" \| "dataUrl"</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 width of the saved image | | 1.0.0 |
| **`height`** | <code>number</code> | The height of the saved image | | 1.0.0 |
| **`preserveAspectRatio`** | <code>boolean</code> | Whether to preserve the aspect ratio of the image. If this flag is true, the width and height will be used as max values and the aspect ratio will be preserved. This is only relevant when both a width and height are passed. When only width or height is provided the aspect ratio is always preserved (and this option is a no-op). A future major version will change this behavior to be default, and may also remove this option altogether. | <code>: false</code> | 1.0.0 |
| **`correctOrientation`** | <code>boolean</code> | Whether to automatically rotate the image "up" to correct for orientation in portrait mode | <code>: true</code> | 1.0.0 |
| **`source`** | <code>"camera" \| "photos" \| "prompt"</code> | The source to get the photo from. By default this prompts the user to select either the photo album or take a photo. | <code>: CameraSource.prompt</code> | 1.0.0 |
| **`direction`** | <code>"rear" \| "front"</code> | iOS and Web only: The camera direction. | <code>: CameraDirection.rear</code> | 1.0.0 |
| **`presentationStyle`** | <code>"fullscreen" \| "popover"</code> | iOS only: The presentation style of the Camera. | <code>: 'fullscreen'</code> | 1.0.0 |
| **`webUseInput`** | <code>boolean</code> | Web only: Whether to use the PWA Element experience or file input. The default is to use PWA Elements if installed and fall back to file input. To always use file input, set this to `true`. Learn more about PWA Elements: https://capacitorjs.com/docs/pwa-elements | | 1.0.0 |
| **`promptLabelHeader`** | <code>string</code> | Text value to use when displaying the prompt. iOS only: The title of the action sheet. | <code>: 'Photo'</code> | 1.0.0 |
| **`promptLabelCancel`** | <code>string</code> | Text value to use when displaying the prompt. iOS only: The label of the 'cancel' button. | <code>: 'Cancel'</code> | 1.0.0 |
| **`promptLabelPhoto`** | <code>string</code> | Text value to use when displaying the prompt. The label of the button to select a saved image. | <code>: 'From Photos'</code> | 1.0.0 |
| **`promptLabelPicture`** | <code>string</code> | Text value to use when displaying the prompt. The label of the button to open the camera. | <code>: 'Take Picture'</code> | 1.0.0 |


#### CameraPermissionStatus

| Prop | Type |
| ------------ | ---------------- |
| **`camera`** | <code>any</code> |
| **`photos`** | <code>any</code> |


#### CameraPluginPermissions

| Prop | Type |
| ----------------- | ----------------------------------- |
| **`permissions`** | <code>CameraPermissionType[]</code> |

</docgen-api>
1 change: 1 addition & 0 deletions camera/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
62 changes: 62 additions & 0 deletions camera/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.2.0'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
androidxMaterialVersion = project.hasProperty('androidxMaterialVersion') ? rootProject.ext.androidxMaterialVersion : '1.1.0-rc02'
}

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 29
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
google()
jcenter()
mavenCentral()
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')
implementation "androidx.exifinterface:exifinterface:$androidxExifInterfaceVersion"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "com.google.android.material:material:$androidxMaterialVersion"
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
}
Loading