You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/15 19:21:11 UTC
spec commit: [CB-2213] Added a test for NATIVE_URI.
Updated Branches:
refs/heads/master 1f8bd78ff -> e84886540
[CB-2213] Added a test for NATIVE_URI.
The test uses the camera to get the native URI of an image from the device's photo library, and uses that URI to display the file's info.
Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/e8488654
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/e8488654
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/e8488654
Branch: refs/heads/master
Commit: e8488654049157e2a2c0d232a4f23d0066baa1b0
Parents: 1f8bd78
Author: Max Woghiren <ma...@gmail.com>
Authored: Tue Jan 15 10:49:39 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jan 15 13:21:04 2013 -0500
----------------------------------------------------------------------
camera/index.html | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/e8488654/camera/index.html
----------------------------------------------------------------------
diff --git a/camera/index.html b/camera/index.html
index ec6b0de..aa44085 100644
--- a/camera/index.html
+++ b/camera/index.html
@@ -64,9 +64,9 @@
};
/**
- * Select image from library
+ * Select image from library using a FILE_URI destination type
*/
- function getImage() {
+ function getImageUsingFileUri() {
navigator.camera.getPicture(
function(data) {
var img = document.getElementById('camera_image');
@@ -84,7 +84,27 @@
Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
};
-
+ /**
+ * Select image from library using a NATIVE_URI destination type
+ */
+ function getImageInfoUsingNativeUri() {
+ var onFileReceived = function(file) {
+ document.getElementById('camera_status').innerHTML = "Success; fullPath: " + file.fullPath + ", name: " + file.name + ", type: " + file.type + ", size: " + file.size + ", date: " + file.lastModifiedDate;
+ }
+ var onError = function(e) {
+ console.log("Error getting picture: " + e);
+ document.getElementById('camera_status').innerHTML = "Error getting picture.";
+ }
+ navigator.camera.getPicture(
+ function(data) {
+ var fileEntry = new FileEntry('image_name.png', data);
+ var file = fileEntry.file(onFileReceived, onError);
+ },
+ onError,
+ { quality: 50, destinationType:
+ Camera.DestinationType.NATIVE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
+ };
+
/**
* Function called when page has finished loading.
*/
@@ -112,7 +132,8 @@
</div>
<h2>Action</h2>
<div class="btn large" onclick="getPicture();">Take Picture</div>
- <div class="btn large" onclick="getImage();">Select Image from Library</div>
+ <div class="btn large" onclick="getImageUsingFileUri();">Select Image Using File URI</div>
+ <div class="btn large" onclick="getImageInfoUsingNativeUri();">Select Image Using Native URI</div>
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
</body>
</html>