You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/07/21 00:56:18 UTC
[10/11] js commit: Camera takePicture
Camera takePicture
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/ba3c88b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/ba3c88b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/ba3c88b5
Branch: refs/heads/master
Commit: ba3c88b575b9380b4c68372f9c2cde7862e355a5
Parents: 539ea47
Author: Jesse <pu...@gmail.com>
Authored: Mon Jul 16 03:06:50 2012 -0700
Committer: Jesse <pu...@gmail.com>
Committed: Mon Jul 16 03:06:50 2012 -0700
----------------------------------------------------------------------
lib/win8metro/exec.js | 77 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 74 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ba3c88b5/lib/win8metro/exec.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/exec.js b/lib/win8metro/exec.js
index cc05a72..d258d53 100644
--- a/lib/win8metro/exec.js
+++ b/lib/win8metro/exec.js
@@ -62,6 +62,80 @@ var NativeProxy = {
}
}
},
+ "Camera":{
+ // args will contain ... it is an array, so be careful
+ // 0 quality:50,
+ // 1 destinationType:Camera.DestinationType.FILE_URI,
+ // 2 sourceType:Camera.PictureSourceType.CAMERA,
+ // 3 targetWidth:-1,
+ // 4 targetHeight:-1,
+ // 5 encodingType:Camera.EncodingType.JPEG,
+ // 6 mediaType:Camera.MediaType.PICTURE,
+ // 7 allowEdit:false,
+ // 8 correctOrientation:false,
+ // 9 saveToPhotoAlbum:false,
+ // 10 popoverOptions:null
+ "takePicture":function(win,lose,args) {
+ var dialog = new Windows.Media.Capture.CameraCaptureUI();
+ var allowCrop = !!args[7];
+ if(!allowCrop) {
+ dialog.photoSettings.allowCrop = false;
+ }
+ else {
+ var aspectRatio = { width:args[3] > 0 ? args[3] : 1, height: args[4] > 0 ? args[4] : 1};
+ dialog.photoSettings.croppedAspectRatio = aspectRatio;
+ }
+ if(args[5] == Camera.EncodingType.JPEG) {
+ dialog.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.jpeg;
+ }
+ else if (args[5] == Camera.EncodingType.PNG) {
+ dialog.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.png;
+ }
+
+ dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(
+ function(file){
+ if(file) {
+ console.log("got a file in success handler");
+ if(args[1] == Camera.DestinationType.FILE_URI)
+ {
+ var imageBlobUrl = URL.createObjectURL(file);
+ win(imageBlobUrl);
+ }
+ }
+ else {
+ console.log("success handler without file ...")
+ }
+ },
+ function(err) {
+ console.log("err in camerq")
+ });
+
+
+ }
+
+ },
+ "Compass":{
+ //compass = Windows.Devices.Sensors.Compass.getDefault();
+ //
+ getHeading:function(win,lose) {
+ var comp = Windows.Devices.Sensors.Compass.getDefault();
+ if(!comp) {
+ setTimeout(function(){lose("Compass not available");},0);
+ }
+ else {
+ var onResult = function(e) {
+ comp.removeEventListener("readingchanged",onResult);
+ var reading = e.reading;
+ //result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp
+ };
+ comp.addEventListener("readingchanged",onResult);
+ }
+
+ },
+ stopHeading:function(win,lose) {
+
+ }
+ },
"Device": {
getDeviceInfo:function(win,fail,args){
console.log("NativeProxy::getDeviceInfo");
@@ -73,9 +147,6 @@ var NativeProxy = {
"NetworkStatus": {
getConnectionInfo:function(win,fail,args)
{
- console.log("getConnectionInfo");
-
-
var winNetConn = Windows.Networking.Connectivity;
var networkInfo = winNetConn.NetworkInformation;
var networkCostInfo = winNetConn.NetworkCostType;