From c696f6e0b3f9d4461d86cb6481c56cca57676f88 Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Mon, 28 Jul 2014 20:42:43 -0500 Subject: [PATCH 1/7] update CameraProxy.js --- src/firefoxos/CameraProxy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/firefoxos/CameraProxy.js b/src/firefoxos/CameraProxy.js index 9afb343..872d0ad 100644 --- a/src/firefoxos/CameraProxy.js +++ b/src/firefoxos/CameraProxy.js @@ -48,4 +48,4 @@ module.exports = { cleanup: function(){} }; -require("cordova/firefoxos/commandProxy").add("Camera", module.exports); +require("cordova/exec/proxy").add("Camera", module.exports); From dbaa458b7f0c1abce1a6e9cc100e03dc8b13cf28 Mon Sep 17 00:00:00 2001 From: Staci Cooper Date: Thu, 31 Jul 2014 12:45:05 -0400 Subject: [PATCH 2/7] Renamed test dir, added nested plugin.xml --- tests/plugin.xml | 31 +++++++++++++++++++++++++++++++ {test => tests}/tests.js | 0 2 files changed, 31 insertions(+) create mode 100644 tests/plugin.xml rename {test => tests}/tests.js (100%) diff --git a/tests/plugin.xml b/tests/plugin.xml new file mode 100644 index 0000000..403753b --- /dev/null +++ b/tests/plugin.xml @@ -0,0 +1,31 @@ + + + + + Cordova Camera Plugin Tests + Apache 2.0 + + + + diff --git a/test/tests.js b/tests/tests.js similarity index 100% rename from test/tests.js rename to tests/tests.js From 0d63ac27ca6911d34a3eef76e393d64e898d8b47 Mon Sep 17 00:00:00 2001 From: Lisa Seacat DeLuca Date: Fri, 1 Aug 2014 16:22:53 -0400 Subject: [PATCH 3/7] CB-7249cordova-plugin-camera documentation translation: cordova-plugin-camera --- doc/fr/index.md | 2 +- doc/pl/index.md | 26 ++++++++++++++------------ doc/ru/index.md | 6 +++--- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/doc/fr/index.md b/doc/fr/index.md index ca504f0..d2a06f9 100644 --- a/doc/fr/index.md +++ b/doc/fr/index.md @@ -218,7 +218,7 @@ Paramètres optionnels pour personnaliser les réglages de l'appareil. * Ignore le paramètre `quality`. -* Ignore le paramètre `allowEdit`. +* Ignore la `allowEdit` paramètre. * `Camera.MediaType`n'est pas pris en charge. diff --git a/doc/pl/index.md b/doc/pl/index.md index 7b1d12a..3149bfa 100644 --- a/doc/pl/index.md +++ b/doc/pl/index.md @@ -28,7 +28,7 @@ Wtyczka dostarcza API do robienia zdjęć i wybór zdjęć z biblioteki obrazu s Pobiera zdjęcia za pomocą aparatu lub z galerii zdjęć w urządzeniu. Obraz jest przekazywany do funkcji zwrotnej success jako `String` kodowany za pomocą base64 lub jako URI do pliku. Sama metoda zwraca obiekt `CameraPopoverHandle`, który może służyć do zmiany położenia wyskakującego okna wyboru pliku. - navigator.camera.getPicture( cameraSuccess, cameraError, [ cameraOptions ] ); + navigator.camera.getPicture( cameraSuccess, cameraError, cameraOptions ); ### Opis @@ -147,9 +147,9 @@ Opcjonalne parametry, aby dostosować ustawienia aparatu. ### Opcje -* **quality**: Jakość zapisywanego obrazu, wyrażona w przedziale 0-100, gdzie 100 zazwyczaj jest maksymalną rozdzielczością bez strat w czasie kompresji pliku. *(Liczba)* (Pamiętaj, że informacja o rozdzielczości aparatu jest niedostępna.) +* **quality**: Jakość zapisywanego obrazu, wyrażona w przedziale 0-100, gdzie 100 zazwyczaj jest maksymalną rozdzielczością bez strat w czasie kompresji pliku. Wartością domyślną jest 50. *(Liczba)* (Należy zauważyć, że informacje o rozdzielczość kamery jest niedostępny). -* **destinationType**: Wybierz format zwracanej wartości. Zdefiniowane w `navigator.camera.DestinationType` *(numer)* +* **destinationType**: Wybierz format zwracanej wartości. Wartością domyślną jest FILE_URI. Zdefiniowane w `navigator.camera.DestinationType` *(numer)* Camera.DestinationType = { DATA_URL : 0, // Return image as base64-encoded string @@ -158,7 +158,7 @@ Opcjonalne parametry, aby dostosować ustawienia aparatu. }; -* **sourceType**: Ustaw źródło obrazu. Zdefiniowane w `navigator.camera.PictureSourceType` *(numer)* +* **sourceType**: Ustaw źródło obrazu. Wartością domyślną jest aparat fotograficzny. Zdefiniowane w `navigator.camera.PictureSourceType` *(numer)* Camera.PictureSourceType = { PHOTOLIBRARY : 0, @@ -169,7 +169,7 @@ Opcjonalne parametry, aby dostosować ustawienia aparatu. * **allowEdit**: Pozwala na prostą edycję obrazu przed zaznaczeniem. *(Boolean)* -* **encodingType**: Wybierz plik obrazu zwracany jest kodowanie. Zdefiniowane w `navigator.camera.EncodingType` *(numer)* +* **encodingType**: Wybierz plik obrazu zwracany jest kodowanie. Domyślnie jest JPEG. Zdefiniowane w `navigator.camera.EncodingType` *(numer)* Camera.EncodingType = { JPEG : 0, // Return JPEG encoded image @@ -196,7 +196,7 @@ Opcjonalne parametry, aby dostosować ustawienia aparatu. * **popoverOptions**: Opcja tylko dla platformy iOS, która określa położenie wyskakującego okna na iPadzie. Zdefiniowane w `CameraPopoverOptions`. -* **cameraDirection**: Wybierz aparat do korzystania (lub z powrotem przodem). Zdefiniowane w `navigator.camera.Direction` *(numer)* +* **cameraDirection**: Wybierz aparat do korzystania (lub z powrotem przodem). Wartością domyślną jest z powrotem. Zdefiniowane w `navigator.camera.Direction` *(numer)* Camera.Direction = { BACK : 0, // Używa tylnej kamery @@ -224,15 +224,13 @@ Opcjonalne parametry, aby dostosować ustawienia aparatu. * Parametr `quality` jest ignorowany. -* Parametr `sourceType` jest ignorowany. - * Ignoruje `allowEdit` parametr. -* Nie jest wspierane `Camera.MediaType`. +* `Camera.MediaType`nie jest obsługiwane. -* Parametr `correctOrientation` jest ignorowany. +* Ignoruje `correctOrientation` parametr. -* Parametr `cameraDirection` jest ignorowany. +* Ignoruje `cameraDirection` parametr. ### Firefox OS dziwactwa @@ -258,7 +256,7 @@ Opcjonalne parametry, aby dostosować ustawienia aparatu. * Ustaw `quality` poniżej 50 aby uniknąć błędów pamięci na niektórych urządzeniach. -* Jeśli użyjesz `destinationType.FILE_URI` zdjęcia zostaną zapisane w katalogu tymczasowym aplikacji. Jeżeli masz problemy z miejscem, możesz usunąć zawartość tego katalogu używając API `navigator.fileMgr`. +* Podczas korzystania z `destinationType.FILE_URI` , zdjęcia są zapisywane w katalogu tymczasowego stosowania. Zawartość katalogu tymczasowego stosowania jest usuwany po zakończeniu aplikacji. ### Osobliwości Tizen @@ -274,8 +272,12 @@ Opcjonalne parametry, aby dostosować ustawienia aparatu. * Ignoruje `cameraDirection` parametr. +* Ignoruje `saveToPhotoAlbum` parametr. Ważne: Wszystkie zdjęcia zrobione aparatem wp7/8 cordova API są zawsze kopiowane do telefonu w kamerze. W zależności od ustawień użytkownika może to też oznaczać że obraz jest automatycznie przesłane do ich OneDrive. Potencjalnie może to oznaczać, że obraz jest dostępne dla szerszego grona odbiorców niż Twoja aplikacja przeznaczona. Jeśli ten bloker aplikacji, trzeba będzie wdrożenie CameraCaptureTask, opisane na msdn: można także komentarz lub górę głosowanie powiązanych kwestii w [śledzenia błędów][3] + * Ignoruje `mediaType` Właściwość `cameraOptions` jako SDK Windows Phone nie umożliwiają wybór filmów z PHOTOLIBRARY. + [3]: https://issues.apache.org/jira/browse/CB-2083 + ## CameraError funkcja wywołania zwrotnego PrzyBłędzie, która zawiera komunikat o błędzie. diff --git a/doc/ru/index.md b/doc/ru/index.md index a0c1348..a1a17fd 100644 --- a/doc/ru/index.md +++ b/doc/ru/index.md @@ -221,11 +221,11 @@ Tizen поддерживает только `destinationType` из `Camera.Desti * Игнорирует `allowEdit` параметр. -* `Camera.MediaType` не поддерживается. +* `Camera.MediaType`не поддерживается. -* Игнорирует параметр `correctOrientation`. +* Игнорирует `correctOrientation` параметр. -* Игнорирует параметр `cameraDirection`. +* Игнорирует `cameraDirection` параметр. ### Firefox OS причуды From 823eb5d27a5f77d081e55cbed40952b04d8504ed Mon Sep 17 00:00:00 2001 From: Steven Gill Date: Wed, 6 Aug 2014 18:58:20 -0700 Subject: [PATCH 4/7] CB-7244 Updated version and RELEASENOTES.md for release 0.3.1 --- RELEASENOTES.md | 14 ++++++++++++++ plugin.xml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 9cb208a..07153ed 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -100,3 +100,17 @@ * CB-6491 add CONTRIBUTING.md * CB-6546 android: Fix a couple bugs with allowEdit pull request * CB-6546 android: Add support for allowEdit Camera option + +### 0.3.1 (Aug 06, 2014) +* **FFOS** update CameraProxy.js +* CB-7187 ios: Add explicit dependency on CoreLocation.framework +* [BlackBerry10] Doc correction - sourceType is supported +* CB-7071 android: Fix callback firing before CROP intent is sent when allowEdit=true +* CB-6875 android: Handle exception when SDCard is not mounted +* ios: Delete postImage (dead code) +* Prevent NPE on processResiultFromGallery when intent comes null +* Remove iOS doc reference to non-existing navigator.fileMgr API +* Docs updated with some default values +* Removes File plugin dependency from windows8 code. +* Use WinJS functionality to resize image instead of File plugin functionality +* CB-6127 Updated translations for docs diff --git a/plugin.xml b/plugin.xml index 4f47e3d..1fdf515 100644 --- a/plugin.xml +++ b/plugin.xml @@ -22,7 +22,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:rim="http://www.blackberry.com/ns/widgets" id="org.apache.cordova.camera" - version="0.3.1-dev"> + version="0.3.1"> Camera Cordova Camera Plugin Apache 2.0 From 6366aeba472beaf3770c06f347fcb47845274d9a Mon Sep 17 00:00:00 2001 From: Steven Gill Date: Wed, 6 Aug 2014 19:24:26 -0700 Subject: [PATCH 5/7] CB-7244 Incremented plugin version. --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 1fdf515..3afc48f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -22,7 +22,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:rim="http://www.blackberry.com/ns/widgets" id="org.apache.cordova.camera" - version="0.3.1"> + version="0.3.2-dev"> Camera Cordova Camera Plugin Apache 2.0 From 42bf5d29838e38591eac66e8c05c66eae2ac79ec Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Mon, 11 Aug 2014 23:13:15 -0700 Subject: [PATCH 6/7] CB-7180 - Update Camera plugin to support generic plugin webView UIView (which can be either a UIWebView or WKWebView) --- src/ios/CDVCamera.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ios/CDVCamera.h b/src/ios/CDVCamera.h index 63deac9..5d4a81d 100644 --- a/src/ios/CDVCamera.h +++ b/src/ios/CDVCamera.h @@ -55,7 +55,7 @@ typedef NSUInteger CDVMediaType; @property (assign) bool correctOrientation; @property (assign) bool saveToPhotoAlbum; @property (assign) bool cropToSize; -@property (strong) UIWebView* webView; +@property (strong) UIView* webView; @property (assign) BOOL popoverSupported; @end From d53a7770d9b064f3fa5140a5aa58707a9853e5d6 Mon Sep 17 00:00:00 2001 From: Bryan Higgins Date: Fri, 8 Aug 2014 15:54:42 -0400 Subject: [PATCH 7/7] CB-7286 [BlackBerry10] Use getUserMedia if camera card is unavailable --- plugin.xml | 4 +- src/blackberry10/index.js | 99 ++++++++++++++++++++++++++++- www/blackberry10/assets/camera.html | 82 ++++++++++++++++++++++++ www/blackberry10/assets/camera.js | 46 ++++++++++++++ 4 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 www/blackberry10/assets/camera.html create mode 100644 www/blackberry10/assets/camera.js diff --git a/plugin.xml b/plugin.xml index 3afc48f..1bb7b57 100644 --- a/plugin.xml +++ b/plugin.xml @@ -56,7 +56,7 @@ - + @@ -153,10 +153,12 @@ access_shared + use_camera + diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js index 9a5ebf3..74cb191 100644 --- a/src/blackberry10/index.js +++ b/src/blackberry10/index.js @@ -27,7 +27,98 @@ var PictureSourceType = { DATA_URL: 0, // Return base64 encoded string FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android) NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS) - }; + }, + savePath = window.qnx.webplatform.getApplication().getEnv("HOME").replace('/data', '') + '/shared/camera/', + invokeAvailable = true; + +//check for camera card - it isn't currently availble in work perimeter +window.qnx.webplatform.getApplication().invocation.queryTargets( + { + type: 'image/jpeg', + action: 'bb.action.CAPTURE', + target_type: 'CARD' + }, + function (error, targets) { + invokeAvailable = !error && targets && targets instanceof Array && + targets.filter(function (t) { return t.default === 'sys.camera.card' }).length > 0; + } +); + +//open a webview with getUserMedia camera card implementation when camera card not available +function showCameraDialog (done, cancel, fail) { + var wv = qnx.webplatform.createWebView(function () { + wv.url = 'local:///chrome/camera.html'; + wv.allowQnxObject = true; + wv.allowRpc = true; + wv.zOrder = 1; + wv.setGeometry(0, 0, screen.width, screen.height); + wv.backgroundColor = 0x00000000; + wv.active = true; + wv.visible = true; + wv.on('UserMediaRequest', function (evt, args) { + wv.allowUserMedia(JSON.parse(args).id, 'CAMERA_UNIT_REAR'); + }); + wv.on('JavaScriptCallback', function (evt, data) { + var args = JSON.parse(data).args; + if (args[0] === 'org.apache.cordova.camera') { + if (args[1] === 'cancel') { + cancel('User canceled'); + } else if (args[1] === 'error') { + fail(args[2]); + } else { + saveImage(args[1], done, fail); + } + wv.un('JavaScriptCallback', arguments.callee); + wv.visible = false; + wv.destroy(); + qnx.webplatform.getApplication().unlockRotation(); + } + }); + wv.on('Destroyed', function () { + wv.delete(); + }); + qnx.webplatform.getApplication().lockRotation(); + qnx.webplatform.getController().dispatchEvent('webview.initialized', [wv]); + }); +} + +//create unique name for saved file (same pattern as BB10 camera app) +function imgName() { + var date = new Date(), + pad = function (n) { return n < 10 ? '0' + n : n }; + return 'IMG_' + date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) + '_' + + pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + '.png'; +} + +//convert dataURI to Blob +function dataURItoBlob(dataURI) { + var byteString = atob(dataURI.split(',')[1]), + mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0], + arrayBuffer = new ArrayBuffer(byteString.length), + ia = new Uint8Array(arrayBuffer), + i; + for (i = 0; i < byteString.length; i++) { + ia[i] = byteString.charCodeAt(i); + } + return new Blob([new DataView(arrayBuffer)], { type: mimeString }); +} + +//save dataURI to file system and call success with path +function saveImage(data, success, fail) { + var name = savePath + imgName(); + require('lib/webview').setSandbox(false); + window.webkitRequestFileSystem(window.PERSISTENT, 0, function (fs) { + fs.root.getFile(name, { create: true }, function (entry) { + entry.createWriter(function (writer) { + writer.onwriteend = function () { + success(name); + }; + writer.onerror = fail; + writer.write(dataURItoBlob(data)); + }); + }, fail); + }, fail); +} function encodeBase64(filePath, callback) { var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox, // save original sandbox value @@ -112,7 +203,11 @@ module.exports = { switch(sourceType) { case PictureSourceType.CAMERA: - window.qnx.webplatform.getApplication().cards.camera.open("photo", done, cancel, invoked); + if (invokeAvailable) { + window.qnx.webplatform.getApplication().cards.camera.open("photo", done, cancel, invoked); + } else { + showCameraDialog(done, cancel, fail); + } break; case PictureSourceType.PHOTOLIBRARY: diff --git a/www/blackberry10/assets/camera.html b/www/blackberry10/assets/camera.html new file mode 100644 index 0000000..2ebd9d1 --- /dev/null +++ b/www/blackberry10/assets/camera.html @@ -0,0 +1,82 @@ + + + + + + + + + + +
+ +
+
+ +
+
+
+
+
+
+ + diff --git a/www/blackberry10/assets/camera.js b/www/blackberry10/assets/camera.js new file mode 100644 index 0000000..6d163d0 --- /dev/null +++ b/www/blackberry10/assets/camera.js @@ -0,0 +1,46 @@ +/* + * 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. + * +*/ + +document.addEventListener('DOMContentLoaded', function () { + document.getElementById('back').onclick = function () { + window.qnx.callExtensionMethod('org.apache.cordova.camera', 'cancel'); + }; + window.navigator.webkitGetUserMedia( + { video: true }, + function (stream) { + var video = document.getElementById('v'), + canvas = document.getElementById('c'), + camera = document.getElementById('camera'); + video.autoplay = true; + video.width = window.innerWidth; + video.height = window.innerHeight - 100; + video.src = window.webkitURL.createObjectURL(stream); + camera.onclick = function () { + canvas.width = video.videoWidth; + canvas.height = video.videoHeight; + canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight); + window.qnx.callExtensionMethod('org.apache.cordova.camera', canvas.toDataURL('img/png')); + }; + }, + function () { + window.qnx.callExtensionMethod('org.apache.cordova.camera', 'error', 'getUserMedia failed'); + } + ); +});