mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-18 19:22:51 +08:00
commit
2bad1fd81c
@ -15,6 +15,7 @@ environment:
|
|||||||
matrix:
|
matrix:
|
||||||
- nodejs_version: "10"
|
- nodejs_version: "10"
|
||||||
- nodejs_version: "12"
|
- nodejs_version: "12"
|
||||||
|
- nodejs_version: "14"
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
- x86
|
- x86
|
||||||
|
@ -17,7 +17,7 @@ env:
|
|||||||
- ANDROID_BUILD_TOOLS_VERSION=29.0.2
|
- ANDROID_BUILD_TOOLS_VERSION=29.0.2
|
||||||
|
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js: 12
|
node_js: 14
|
||||||
|
|
||||||
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
|
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
|
||||||
|
|
||||||
|
@ -20,6 +20,14 @@
|
|||||||
-->
|
-->
|
||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
|
### 5.0.1 (Nov 04, 2020)
|
||||||
|
|
||||||
|
* [GH-686](https://github.com/apache/cordova-plugin-camera/pull/686) chore(android): add missing apache license header
|
||||||
|
* [GH-685](https://github.com/apache/cordova-plugin-camera/pull/685) fix(ios): correctly append exif on **iOS** 14
|
||||||
|
* [GH-669](https://github.com/apache/cordova-plugin-camera/pull/669) fix(android): save to photo gallery - fixes issues [#341](https://github.com/apache/cordova-plugin-camera/pull/341) & [#577](https://github.com/apache/cordova-plugin-camera/pull/577)
|
||||||
|
* [GH-672](https://github.com/apache/cordova-plugin-camera/pull/672) chore: Fix JIRA links in RELEASENOTES.md
|
||||||
|
* [GH-664](https://github.com/apache/cordova-plugin-camera/pull/664) chore: Update RELEASENOTES
|
||||||
|
|
||||||
### 5.0.0 (Sep 14, 2020)
|
### 5.0.0 (Sep 14, 2020)
|
||||||
|
|
||||||
* [GH-648](https://github.com/apache/cordova-plugin-camera/pull/648) ci(travis): update osx xcode image
|
* [GH-648](https://github.com/apache/cordova-plugin-camera/pull/648) ci(travis): update osx xcode image
|
||||||
@ -62,23 +70,23 @@
|
|||||||
- fix(ios): fixes UIImagePickerController cancel handling for iOS11+ ([#377](https://github.com/apache/cordova-plugin-camera/issues/377)) ([`24c8b6c`](https://github.com/apache/cordova-plugin-camera/commit/24c8b6c))
|
- fix(ios): fixes UIImagePickerController cancel handling for iOS11+ ([#377](https://github.com/apache/cordova-plugin-camera/issues/377)) ([`24c8b6c`](https://github.com/apache/cordova-plugin-camera/commit/24c8b6c))
|
||||||
- docs: Remove deprecated platforms from docs ([#394](https://github.com/apache/cordova-plugin-camera/issues/394)) ([`7ddb3df`](https://github.com/apache/cordova-plugin-camera/commit/7ddb3df))
|
- docs: Remove deprecated platforms from docs ([#394](https://github.com/apache/cordova-plugin-camera/issues/394)) ([`7ddb3df`](https://github.com/apache/cordova-plugin-camera/commit/7ddb3df))
|
||||||
- fix(android): return DATA_URL for ALLMEDIA if it's an image ([#382](https://github.com/apache/cordova-plugin-camera/issues/382)) ([`60e7795`](https://github.com/apache/cordova-plugin-camera/commit/60e7795))
|
- fix(android): return DATA_URL for ALLMEDIA if it's an image ([#382](https://github.com/apache/cordova-plugin-camera/issues/382)) ([`60e7795`](https://github.com/apache/cordova-plugin-camera/commit/60e7795))
|
||||||
- refactor(ios): [CB-13813](https://issues.apache.org/jira/browse/13813): Remove old iOS code ([#381](https://github.com/apache/cordova-plugin-camera/issues/381)) ([`ce77aab`](https://github.com/apache/cordova-plugin-camera/commit/ce77aab))
|
- refactor(ios): [CB-13813](https://issues.apache.org/jira/browse/CB-13813): Remove old iOS code ([#381](https://github.com/apache/cordova-plugin-camera/issues/381)) ([`ce77aab`](https://github.com/apache/cordova-plugin-camera/commit/ce77aab))
|
||||||
- feat(ios): [CB-13865](https://issues.apache.org/jira/browse/13865): (Ipad) Making popover Window Size configurable using popoverOptions - imagePicker ([#314](https://github.com/apache/cordova-plugin-camera/issues/314)) ([`cd72047`](https://github.com/apache/cordova-plugin-camera/commit/cd72047))
|
- feat(ios): [CB-13865](https://issues.apache.org/jira/browse/CB-13865): (Ipad) Making popover Window Size configurable using popoverOptions - imagePicker ([#314](https://github.com/apache/cordova-plugin-camera/issues/314)) ([`cd72047`](https://github.com/apache/cordova-plugin-camera/commit/cd72047))
|
||||||
- chore(types): [CB-13837](https://issues.apache.org/jira/browse/13837): fix TypeScript Definition for CameraPopoverOptions ([#379](https://github.com/apache/cordova-plugin-camera/issues/379)) ([`86b0bf2`](https://github.com/apache/cordova-plugin-camera/commit/86b0bf2))
|
- chore(types): [CB-13837](https://issues.apache.org/jira/browse/CB-13837): fix TypeScript Definition for CameraPopoverOptions ([#379](https://github.com/apache/cordova-plugin-camera/issues/379)) ([`86b0bf2`](https://github.com/apache/cordova-plugin-camera/commit/86b0bf2))
|
||||||
- docs(android): clarify android quirk of cameraDirection ([`a5a3d88`](https://github.com/apache/cordova-plugin-camera/commit/a5a3d88), [`bfbe4a1`](https://github.com/apache/cordova-plugin-camera/commit/bfbe4a1))
|
- docs(android): clarify android quirk of cameraDirection ([`a5a3d88`](https://github.com/apache/cordova-plugin-camera/commit/a5a3d88), [`bfbe4a1`](https://github.com/apache/cordova-plugin-camera/commit/bfbe4a1))
|
||||||
- chore(release): Bump minor version ([#370](https://github.com/apache/cordova-plugin-camera/issues/370)) ([`eed4433`](https://github.com/apache/cordova-plugin-camera/commit/eed4433))
|
- chore(release): Bump minor version ([#370](https://github.com/apache/cordova-plugin-camera/issues/370)) ([`eed4433`](https://github.com/apache/cordova-plugin-camera/commit/eed4433))
|
||||||
- build: Remove automatic README generation ([#365](https://github.com/apache/cordova-plugin-camera/issues/365)) ([`07e8574`](https://github.com/apache/cordova-plugin-camera/commit/07e8574))
|
- build: Remove automatic README generation ([#365](https://github.com/apache/cordova-plugin-camera/issues/365)) ([`07e8574`](https://github.com/apache/cordova-plugin-camera/commit/07e8574))
|
||||||
- docs: remove JIRA link ([`bcb26fb`](https://github.com/apache/cordova-plugin-camera/commit/bcb26fb))
|
- docs: remove JIRA link ([`bcb26fb`](https://github.com/apache/cordova-plugin-camera/commit/bcb26fb))
|
||||||
- ci(travis): also accept terms for android sdk `android-27` ([`a346212`](https://github.com/apache/cordova-plugin-camera/commit/a346212))
|
- ci(travis): also accept terms for android sdk `android-27` ([`a346212`](https://github.com/apache/cordova-plugin-camera/commit/a346212))
|
||||||
- docs: remove outdated docs translations that haven't been touched for 3 years ([`403682b`](https://github.com/apache/cordova-plugin-camera/commit/403682b))
|
- docs: remove outdated docs translations that haven't been touched for 3 years ([`403682b`](https://github.com/apache/cordova-plugin-camera/commit/403682b))
|
||||||
- fix(android): [CB-14097](https://issues.apache.org/jira/browse/14097): Fix crash when selecting some files with getPicture ([#322](https://github.com/apache/cordova-plugin-camera/issues/322)) ([`5c23b65`](https://github.com/apache/cordova-plugin-camera/commit/5c23b65))
|
- fix(android): [CB-14097](https://issues.apache.org/jira/browse/CB-14097): Fix crash when selecting some files with getPicture ([#322](https://github.com/apache/cordova-plugin-camera/issues/322)) ([`5c23b65`](https://github.com/apache/cordova-plugin-camera/commit/5c23b65))
|
||||||
- fix(browser): [CB-13384](https://issues.apache.org/jira/browse/13384): Added deprecation of video.src compatibility ([#288](https://github.com/apache/cordova-plugin-camera/issues/288)) ([`5163d38`](https://github.com/apache/cordova-plugin-camera/commit/5163d38))
|
- fix(browser): [CB-13384](https://issues.apache.org/jira/browse/CB-13384): Added deprecation of video.src compatibility ([#288](https://github.com/apache/cordova-plugin-camera/issues/288)) ([`5163d38`](https://github.com/apache/cordova-plugin-camera/commit/5163d38))
|
||||||
- fix(browser): Remove audio flag from getUserMedia ([#284](https://github.com/apache/cordova-plugin-camera/issues/284)) ([`36343a8`](https://github.com/apache/cordova-plugin-camera/commit/36343a8))
|
- fix(browser): Remove audio flag from getUserMedia ([#284](https://github.com/apache/cordova-plugin-camera/issues/284)) ([`36343a8`](https://github.com/apache/cordova-plugin-camera/commit/36343a8))
|
||||||
- docs: replace warning emoji with warning unicode ([#317](https://github.com/apache/cordova-plugin-camera/issues/317)) ([`ead7d5e`](https://github.com/apache/cordova-plugin-camera/commit/ead7d5e))
|
- docs: replace warning emoji with warning unicode ([#317](https://github.com/apache/cordova-plugin-camera/issues/317)) ([`ead7d5e`](https://github.com/apache/cordova-plugin-camera/commit/ead7d5e))
|
||||||
- feat(android): Update engines to use variables ([#323](https://github.com/apache/cordova-plugin-camera/issues/323)) ([`6899c5e`](https://github.com/apache/cordova-plugin-camera/commit/6899c5e))
|
- feat(android): Update engines to use variables ([#323](https://github.com/apache/cordova-plugin-camera/issues/323)) ([`6899c5e`](https://github.com/apache/cordova-plugin-camera/commit/6899c5e))
|
||||||
- feat(android): [CB-14017](https://issues.apache.org/jira/browse/14017): Make com.android.support:support-v4 version configurable ([#318](https://github.com/apache/cordova-plugin-camera/issues/318)) ([`e334656`](https://github.com/apache/cordova-plugin-camera/commit/e334656))
|
- feat(android): [CB-14017](https://issues.apache.org/jira/browse/CB-14017): Make com.android.support:support-v4 version configurable ([#318](https://github.com/apache/cordova-plugin-camera/issues/318)) ([`e334656`](https://github.com/apache/cordova-plugin-camera/commit/e334656))
|
||||||
- refactor(android): [CB-14047](https://issues.apache.org/jira/browse/14047): CameraLauncher: Replacing Repeated String literals with final variables ([#319](https://github.com/apache/cordova-plugin-camera/issues/319)) ([`5ec121b`](https://github.com/apache/cordova-plugin-camera/commit/5ec121b))
|
- refactor(android): [CB-14047](https://issues.apache.org/jira/browse/CB-14047): CameraLauncher: Replacing Repeated String literals with final variables ([#319](https://github.com/apache/cordova-plugin-camera/issues/319)) ([`5ec121b`](https://github.com/apache/cordova-plugin-camera/commit/5ec121b))
|
||||||
- fix(windows): [CB-11714](https://issues.apache.org/jira/browse/11714): added extra check for content-type in savePhoto() without options.targetWidth/Height ([#242](https://github.com/apache/cordova-plugin-camera/issues/242)) ([`a201722`](https://github.com/apache/cordova-plugin-camera/commit/a201722), [`dc73954`](https://github.com/apache/cordova-plugin-camera/commit/dc73954), [`dca4b9c`](https://github.com/apache/cordova-plugin-camera/commit/dca4b9c), [`c1b9772`](https://github.com/apache/cordova-plugin-camera/commit/c1b9772), [`eb57b02`](https://github.com/apache/cordova-plugin-camera/commit/eb57b02))
|
- fix(windows): [CB-11714](https://issues.apache.org/jira/browse/CB-11714): added extra check for content-type in savePhoto() without options.targetWidth/Height ([#242](https://github.com/apache/cordova-plugin-camera/issues/242)) ([`a201722`](https://github.com/apache/cordova-plugin-camera/commit/a201722), [`dc73954`](https://github.com/apache/cordova-plugin-camera/commit/dc73954), [`dca4b9c`](https://github.com/apache/cordova-plugin-camera/commit/dca4b9c), [`c1b9772`](https://github.com/apache/cordova-plugin-camera/commit/c1b9772), [`eb57b02`](https://github.com/apache/cordova-plugin-camera/commit/eb57b02))
|
||||||
|
|
||||||
|
|
||||||
### 4.0.3 (Apr 12, 2018)
|
### 4.0.3 (Apr 12, 2018)
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cordova-plugin-camera",
|
"name": "cordova-plugin-camera",
|
||||||
"version": "5.0.1-dev",
|
"version": "5.0.2-dev",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cordova-plugin-camera",
|
"name": "cordova-plugin-camera",
|
||||||
"version": "5.0.1-dev",
|
"version": "5.0.2-dev",
|
||||||
"description": "Cordova Camera Plugin",
|
"description": "Cordova Camera Plugin",
|
||||||
"types": "./types/index.d.ts",
|
"types": "./types/index.d.ts",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="cordova-plugin-camera"
|
id="cordova-plugin-camera"
|
||||||
version="5.0.1-dev">
|
version="5.0.2-dev">
|
||||||
<name>Camera</name>
|
<name>Camera</name>
|
||||||
<description>Cordova Camera Plugin</description>
|
<description>Cordova Camera Plugin</description>
|
||||||
<license>Apache 2.0</license>
|
<license>Apache 2.0</license>
|
||||||
@ -73,6 +73,7 @@
|
|||||||
<source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/camera" />
|
<source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/camera" />
|
||||||
<source-file src="src/android/ExifHelper.java" target-dir="src/org/apache/cordova/camera" />
|
<source-file src="src/android/ExifHelper.java" target-dir="src/org/apache/cordova/camera" />
|
||||||
<source-file src="src/android/FileProvider.java" target-dir="src/org/apache/cordova/camera" />
|
<source-file src="src/android/FileProvider.java" target-dir="src/org/apache/cordova/camera" />
|
||||||
|
<source-file src="src/android/GalleryPathVO.java" target-dir="src/org/apache/cordova/camera" />
|
||||||
<source-file src="src/android/xml/camera_provider_paths.xml" target-dir="res/xml" />
|
<source-file src="src/android/xml/camera_provider_paths.xml" target-dir="res/xml" />
|
||||||
|
|
||||||
<js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
|
<js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
|
||||||
|
@ -21,6 +21,7 @@ package org.apache.cordova.camera;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@ -34,6 +35,7 @@ import android.media.ExifInterface;
|
|||||||
import android.media.MediaScannerConnection;
|
import android.media.MediaScannerConnection;
|
||||||
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
|
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
@ -51,7 +53,6 @@ import org.json.JSONException;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -405,58 +406,57 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Brings up the UI to perform crop on passed image URI
|
||||||
* Brings up the UI to perform crop on passed image URI
|
*
|
||||||
*
|
* @param picUri
|
||||||
* @param picUri
|
*/
|
||||||
*/
|
private void performCrop(Uri picUri, int destType, Intent cameraIntent) {
|
||||||
private void performCrop(Uri picUri, int destType, Intent cameraIntent) {
|
try {
|
||||||
try {
|
Intent cropIntent = new Intent("com.android.camera.action.CROP");
|
||||||
Intent cropIntent = new Intent("com.android.camera.action.CROP");
|
// indicate image type and Uri
|
||||||
// indicate image type and Uri
|
cropIntent.setDataAndType(picUri, "image/*");
|
||||||
cropIntent.setDataAndType(picUri, "image/*");
|
// set crop properties
|
||||||
// set crop properties
|
cropIntent.putExtra("crop", "true");
|
||||||
cropIntent.putExtra("crop", "true");
|
|
||||||
|
|
||||||
|
|
||||||
// indicate output X and Y
|
// indicate output X and Y
|
||||||
if (targetWidth > 0) {
|
if (targetWidth > 0) {
|
||||||
cropIntent.putExtra("outputX", targetWidth);
|
cropIntent.putExtra("outputX", targetWidth);
|
||||||
|
}
|
||||||
|
if (targetHeight > 0) {
|
||||||
|
cropIntent.putExtra("outputY", targetHeight);
|
||||||
|
}
|
||||||
|
if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) {
|
||||||
|
cropIntent.putExtra("aspectX", 1);
|
||||||
|
cropIntent.putExtra("aspectY", 1);
|
||||||
|
}
|
||||||
|
// create new file handle to get full resolution crop
|
||||||
|
croppedFilePath = createCaptureFile(this.encodingType, System.currentTimeMillis() + "").getAbsolutePath();
|
||||||
|
croppedUri = Uri.parse(croppedFilePath);
|
||||||
|
cropIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
cropIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
|
cropIntent.putExtra("output", croppedUri);
|
||||||
|
|
||||||
|
|
||||||
|
// start the activity - we handle returning in onActivityResult
|
||||||
|
|
||||||
|
if (this.cordova != null) {
|
||||||
|
this.cordova.startActivityForResult((CordovaPlugin) this,
|
||||||
|
cropIntent, CROP_CAMERA + destType);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException anfe) {
|
||||||
|
LOG.e(LOG_TAG, "Crop operation not supported on this device");
|
||||||
|
try {
|
||||||
|
processResultFromCamera(destType, cameraIntent);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
LOG.e(LOG_TAG, "Unable to write to file");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (targetHeight > 0) {
|
|
||||||
cropIntent.putExtra("outputY", targetHeight);
|
|
||||||
}
|
|
||||||
if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) {
|
|
||||||
cropIntent.putExtra("aspectX", 1);
|
|
||||||
cropIntent.putExtra("aspectY", 1);
|
|
||||||
}
|
|
||||||
// create new file handle to get full resolution crop
|
|
||||||
croppedFilePath = createCaptureFile(this.encodingType, System.currentTimeMillis() + "").getAbsolutePath();
|
|
||||||
croppedUri = Uri.parse(croppedFilePath);
|
|
||||||
cropIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
cropIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
|
||||||
cropIntent.putExtra("output", croppedUri);
|
|
||||||
|
|
||||||
|
|
||||||
// start the activity - we handle returning in onActivityResult
|
|
||||||
|
|
||||||
if (this.cordova != null) {
|
|
||||||
this.cordova.startActivityForResult((CordovaPlugin) this,
|
|
||||||
cropIntent, CROP_CAMERA + destType);
|
|
||||||
}
|
|
||||||
} catch (ActivityNotFoundException anfe) {
|
|
||||||
LOG.e(LOG_TAG, "Crop operation not supported on this device");
|
|
||||||
try {
|
|
||||||
processResultFromCamera(destType, cameraIntent);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
LOG.e(LOG_TAG, "Unable to write to file");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies all needed transformation to the image received from the camera.
|
* Applies all needed transformation to the image received from the camera.
|
||||||
@ -494,16 +494,18 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
// in the gallery and the modified image is saved in the temporary
|
// in the gallery and the modified image is saved in the temporary
|
||||||
// directory
|
// directory
|
||||||
if (this.saveToPhotoAlbum) {
|
if (this.saveToPhotoAlbum) {
|
||||||
galleryUri = Uri.fromFile(new File(getPicturesPath()));
|
GalleryPathVO galleryPathVO = getPicturesPath();
|
||||||
|
galleryUri = Uri.fromFile(new File(galleryPathVO.getGalleryPath()));
|
||||||
|
|
||||||
if (this.allowEdit && this.croppedUri != null) {
|
if (this.allowEdit && this.croppedUri != null) {
|
||||||
writeUncompressedImage(croppedUri, galleryUri);
|
writeUncompressedImage(croppedUri, galleryUri);
|
||||||
} else {
|
} else {
|
||||||
Uri imageUri = this.imageUri;
|
if (Build.VERSION.SDK_INT <= 28) { // Between LOLLIPOP_MR1 and P, can be changed later to the constant Build.VERSION_CODES.P
|
||||||
writeUncompressedImage(imageUri, galleryUri);
|
writeTakenPictureToGalleryLowerThanAndroidQ(galleryUri);
|
||||||
|
} else { // Android Q or higher
|
||||||
|
writeTakenPictureToGalleryStartingFromAndroidQ(galleryPathVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshGallery(galleryUri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If sending base64 image back
|
// If sending base64 image back
|
||||||
@ -567,9 +569,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
|
|
||||||
// Add compressed version of captured image to returned media store Uri
|
// Add compressed version of captured image to returned media store Uri
|
||||||
OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
|
OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
|
||||||
CompressFormat compressFormat = encodingType == JPEG ?
|
CompressFormat compressFormat = getCompressFormatForEncodingType(encodingType);
|
||||||
CompressFormat.JPEG :
|
|
||||||
CompressFormat.PNG;
|
|
||||||
|
|
||||||
bitmap.compress(compressFormat, this.mQuality, os);
|
bitmap.compress(compressFormat, this.mQuality, os);
|
||||||
os.close();
|
os.close();
|
||||||
@ -597,18 +597,41 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
bitmap = null;
|
bitmap = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPicturesPath() {
|
private void writeTakenPictureToGalleryLowerThanAndroidQ(Uri galleryUri) throws IOException {
|
||||||
|
writeUncompressedImage(imageUri, galleryUri);
|
||||||
|
refreshGallery(galleryUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeTakenPictureToGalleryStartingFromAndroidQ(GalleryPathVO galleryPathVO) throws IOException {
|
||||||
|
// Starting from Android Q, working with the ACTION_MEDIA_SCANNER_SCAN_FILE intent is deprecated
|
||||||
|
// https://developer.android.com/reference/android/content/Intent#ACTION_MEDIA_SCANNER_SCAN_FILE
|
||||||
|
// we must start working with the MediaStore from Android Q on.
|
||||||
|
ContentResolver resolver = this.cordova.getActivity().getContentResolver();
|
||||||
|
ContentValues contentValues = new ContentValues();
|
||||||
|
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, galleryPathVO.getGalleryFileName());
|
||||||
|
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, getMimetypeForFormat(encodingType));
|
||||||
|
Uri galleryOutputUri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
|
||||||
|
|
||||||
|
InputStream fileStream = org.apache.cordova.camera.FileHelper.getInputStreamFromUriString(imageUri.toString(), cordova);
|
||||||
|
writeUncompressedImage(fileStream, galleryOutputUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompressFormat getCompressFormatForEncodingType(int encodingType) {
|
||||||
|
return encodingType == JPEG ? CompressFormat.JPEG : CompressFormat.PNG;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GalleryPathVO getPicturesPath() {
|
||||||
String timeStamp = new SimpleDateFormat(TIME_FORMAT).format(new Date());
|
String timeStamp = new SimpleDateFormat(TIME_FORMAT).format(new Date());
|
||||||
String imageFileName = "IMG_" + timeStamp + (this.encodingType == JPEG ? JPEG_EXTENSION : PNG_EXTENSION);
|
String imageFileName = "IMG_" + timeStamp + (this.encodingType == JPEG ? JPEG_EXTENSION : PNG_EXTENSION);
|
||||||
File storageDir = Environment.getExternalStoragePublicDirectory(
|
File storageDir = Environment.getExternalStoragePublicDirectory(
|
||||||
Environment.DIRECTORY_PICTURES);
|
Environment.DIRECTORY_PICTURES);
|
||||||
storageDir.mkdirs();
|
storageDir.mkdirs();
|
||||||
String galleryPath = storageDir.getAbsolutePath() + "/" + imageFileName;
|
return new GalleryPathVO(storageDir.getAbsolutePath(), imageFileName);
|
||||||
return galleryPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshGallery(Uri contentUri) {
|
private void refreshGallery(Uri contentUri) {
|
||||||
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||||
|
// Starting from Android Q, working with the ACTION_MEDIA_SCANNER_SCAN_FILE intent is deprecated
|
||||||
mediaScanIntent.setData(contentUri);
|
mediaScanIntent.setData(contentUri);
|
||||||
this.cordova.getActivity().sendBroadcast(mediaScanIntent);
|
this.cordova.getActivity().sendBroadcast(mediaScanIntent);
|
||||||
}
|
}
|
||||||
@ -640,9 +663,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
String modifiedPath = getTempDirectoryPath() + "/" + fileName;
|
String modifiedPath = getTempDirectoryPath() + "/" + fileName;
|
||||||
|
|
||||||
OutputStream os = new FileOutputStream(modifiedPath);
|
OutputStream os = new FileOutputStream(modifiedPath);
|
||||||
CompressFormat compressFormat = this.encodingType == JPEG ?
|
CompressFormat compressFormat = getCompressFormatForEncodingType(this.encodingType);
|
||||||
CompressFormat.JPEG :
|
|
||||||
CompressFormat.PNG;
|
|
||||||
|
|
||||||
bitmap.compress(compressFormat, this.mQuality, os);
|
bitmap.compress(compressFormat, this.mQuality, os);
|
||||||
os.close();
|
os.close();
|
||||||
@ -679,7 +700,6 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int rotate = 0;
|
|
||||||
|
|
||||||
String fileLocation = FileHelper.getRealPath(uri, this.cordova);
|
String fileLocation = FileHelper.getRealPath(uri, this.cordova);
|
||||||
LOG.d(LOG_TAG, "File location is: " + fileLocation);
|
LOG.d(LOG_TAG, "File location is: " + fileLocation);
|
||||||
@ -900,34 +920,11 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
private void writeUncompressedImage(Uri src, Uri dest) throws FileNotFoundException,
|
private void writeUncompressedImage(Uri src, Uri dest) throws FileNotFoundException,
|
||||||
IOException {
|
IOException {
|
||||||
|
|
||||||
FileInputStream fis = new FileInputStream(FileHelper.stripFileProtocol(src.toString()));
|
InputStream fis = FileHelper.getInputStreamFromUriString(src.toString(), cordova);
|
||||||
writeUncompressedImage(fis, dest);
|
writeUncompressedImage(fis, dest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create entry in media store for image
|
|
||||||
*
|
|
||||||
* @return uri
|
|
||||||
*/
|
|
||||||
private Uri getUriFromMediaStore() {
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(MediaStore.Images.Media.MIME_TYPE, JPEG_MIME_TYPE);
|
|
||||||
Uri uri;
|
|
||||||
try {
|
|
||||||
uri = this.cordova.getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
LOG.d(LOG_TAG, "Can't write to external media storage.");
|
|
||||||
try {
|
|
||||||
uri = this.cordova.getActivity().getContentResolver().insert(MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
|
|
||||||
} catch (RuntimeException ex) {
|
|
||||||
LOG.d(LOG_TAG, "Can't write to internal media storage.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a scaled and rotated bitmap based on the target width and height
|
* Return a scaled and rotated bitmap based on the target width and height
|
||||||
*
|
*
|
||||||
@ -1258,9 +1255,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
*/
|
*/
|
||||||
public void processPicture(Bitmap bitmap, int encodingType) {
|
public void processPicture(Bitmap bitmap, int encodingType) {
|
||||||
ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream();
|
ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream();
|
||||||
CompressFormat compressFormat = encodingType == JPEG ?
|
CompressFormat compressFormat = getCompressFormatForEncodingType(encodingType);
|
||||||
CompressFormat.JPEG :
|
|
||||||
CompressFormat.PNG;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (bitmap.compress(compressFormat, mQuality, jpeg_data)) {
|
if (bitmap.compress(compressFormat, mQuality, jpeg_data)) {
|
||||||
|
43
src/android/GalleryPathVO.java
Normal file
43
src/android/GalleryPathVO.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
package org.apache.cordova.camera;
|
||||||
|
|
||||||
|
public class GalleryPathVO {
|
||||||
|
private final String galleryPath;
|
||||||
|
private String picturesDirectory;
|
||||||
|
private String galleryFileName;
|
||||||
|
|
||||||
|
public GalleryPathVO(String picturesDirectory, String galleryFileName) {
|
||||||
|
this.picturesDirectory = picturesDirectory;
|
||||||
|
this.galleryFileName = galleryFileName;
|
||||||
|
this.galleryPath = this.picturesDirectory + "/" + this.galleryFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGalleryPath() {
|
||||||
|
return galleryPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPicturesDirectory() {
|
||||||
|
return picturesDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGalleryFileName() {
|
||||||
|
return galleryFileName;
|
||||||
|
}
|
||||||
|
}
|
@ -651,13 +651,15 @@ static NSString* toBase64(NSData* data) {
|
|||||||
CDVPluginResult* result = nil;
|
CDVPluginResult* result = nil;
|
||||||
|
|
||||||
if (self.metadata) {
|
if (self.metadata) {
|
||||||
CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge CFDataRef)self.data, NULL);
|
NSData* dataCopy = [self.data mutableCopy];
|
||||||
|
CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge CFDataRef)dataCopy, NULL);
|
||||||
CFStringRef sourceType = CGImageSourceGetType(sourceImage);
|
CFStringRef sourceType = CGImageSourceGetType(sourceImage);
|
||||||
|
|
||||||
CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)self.data, sourceType, 1, NULL);
|
CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)self.data, sourceType, 1, NULL);
|
||||||
CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata);
|
CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata);
|
||||||
CGImageDestinationFinalize(destinationImage);
|
CGImageDestinationFinalize(destinationImage);
|
||||||
|
|
||||||
|
dataCopy = nil;
|
||||||
CFRelease(sourceImage);
|
CFRelease(sourceImage);
|
||||||
CFRelease(destinationImage);
|
CFRelease(destinationImage);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cordova-plugin-camera-tests",
|
"name": "cordova-plugin-camera-tests",
|
||||||
"version": "5.0.1-dev",
|
"version": "5.0.2-dev",
|
||||||
"description": "",
|
"description": "",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "cordova-plugin-camera-tests",
|
"id": "cordova-plugin-camera-tests",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||||
id="cordova-plugin-camera-tests"
|
id="cordova-plugin-camera-tests"
|
||||||
version="5.0.1-dev">
|
version="5.0.2-dev">
|
||||||
<name>Cordova Camera Plugin Tests</name>
|
<name>Cordova Camera Plugin Tests</name>
|
||||||
<license>Apache 2.0</license>
|
<license>Apache 2.0</license>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user