You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2014/09/05 20:09:03 UTC

[08/11] git commit: CB-4003 - Add config option to not use location information in Camera plugin (and default to not use it)

CB-4003 - Add config option to not use location information in Camera plugin (and default to not use it)


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/ae228200
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/ae228200
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/ae228200

Branch: refs/heads/master
Commit: ae228200464023cf7fada8d483a3ed647bc864cc
Parents: fa30a56
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Sep 3 17:40:20 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Fri Sep 5 11:08:15 2014 -0700

----------------------------------------------------------------------
 doc/index.md        |  9 ++++++++-
 plugin.xml          |  1 +
 src/ios/CDVCamera.h |  1 +
 src/ios/CDVCamera.m | 36 +++++++++++++++++++++++-------------
 4 files changed, 33 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/ae228200/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 8429769..0ca141f 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -85,6 +85,13 @@ than `DATA_URL`.
 - Windows Phone 7 and 8
 - Windows 8
 
+### Preferences (iOS)
+
+-  __CameraUsesGeolocation__ (boolean, defaults to false). For capturing JPEGs, set to true to get geolocation data in the EXIF header. This will trigger a request for geolocation permissions if set to true.
+
+        <preference name="CameraUsesGeolocation" value="false" />
+
+
 ### Amazon Fire OS Quirks
 
 Amazon Fire OS uses intents to launch the camera activity on the device to capture
@@ -226,7 +233,7 @@ Optional parameters to customize the camera settings.
             FRONT : 1      // Use the front-facing camera
         };
 
-### Amazon Fire OSQuirks
+### Amazon Fire OS Quirks
 
 - Any `cameraDirection` value results in a back-facing photo.
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/ae228200/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index c9276e5..a124ee9 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -126,6 +126,7 @@
              <feature name="Camera">
                  <param name="ios-package" value="CDVCamera" />
              </feature>
+             <preference name="CameraUsesGeolocation" value="false" />
          </config-file>
 
          <js-module src="www/ios/CameraPopoverHandle.js" name="CameraPopoverHandle">

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/ae228200/src/ios/CDVCamera.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVCamera.h b/src/ios/CDVCamera.h
index 5d4a81d..c2a71ac 100644
--- a/src/ios/CDVCamera.h
+++ b/src/ios/CDVCamera.h
@@ -57,6 +57,7 @@ typedef NSUInteger CDVMediaType;
 @property (assign) bool cropToSize;
 @property (strong) UIView* webView;
 @property (assign) BOOL popoverSupported;
+@property (assign) BOOL usesGeolocation;
 
 @end
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/ae228200/src/ios/CDVCamera.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m
index ac20c39..c2409be 100644
--- a/src/ios/CDVCamera.m
+++ b/src/ios/CDVCamera.m
@@ -49,6 +49,13 @@ static NSSet* org_apache_cordova_validArrowDirections;
 
 @synthesize hasPendingOperation, pickerController, locationManager;
 
+
+- (BOOL)usesGeolocation
+{
+    id useGeo = [self.commandDelegate.settings objectForKey:[@"CameraUsesGeolocation" lowercaseString]];
+    return [(NSNumber*)useGeo boolValue];
+}
+
 - (BOOL)popoverSupported
 {
     return (NSClassFromString(@"UIPopoverController") != nil) &&
@@ -121,6 +128,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
     // we need to capture this state for memory warnings that dealloc this object
     cameraPicker.webView = self.webView;
     cameraPicker.popoverSupported = [self popoverSupported];
+    cameraPicker.usesGeolocation = [self usesGeolocation];
 
     cameraPicker.correctOrientation = [[arguments objectAtIndex:8] boolValue];
     cameraPicker.saveToPhotoAlbum = [[arguments objectAtIndex:9] boolValue];
@@ -306,20 +314,22 @@ static NSSet* org_apache_cordova_validArrowDirections;
                 data = UIImageJPEGRepresentation(returnedImage, 1.0);
             } else {
                 data = UIImageJPEGRepresentation(returnedImage, cameraPicker.quality / 100.0f);
-
-                NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
-                if (controllerMetadata) {
-                    self.data = data;
-                    self.metadata = [[NSMutableDictionary alloc] init];
-                    
-                    NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];
-                    if (EXIFDictionary)	[self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];
-                    
-                    if (IsAtLeastiOSVersion(@"8.0")) {
-                        [[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0];
+                
+                if (cameraPicker.usesGeolocation) {
+                    NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
+                    if (controllerMetadata) {
+                        self.data = data;
+                        self.metadata = [[NSMutableDictionary alloc] init];
+                        
+                        NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];
+                        if (EXIFDictionary)	[self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];
+                        
+                        if (IsAtLeastiOSVersion(@"8.0")) {
+                            [[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0];
+                        }
+                        [[self locationManager] startUpdatingLocation];
+                        return;
                     }
-                    [[self locationManager] startUpdatingLocation];
-                    return;
                 }
             }