You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2012/05/25 22:09:53 UTC

js commit: Fixes CB-56 iOS Popover placement

Updated Branches:
  refs/heads/master 184b040fb -> eab1ae45c


Fixes CB-56 iOS Popover placement

Added another option to Camera.getPicture() to pass
a CameraPopoverOptions object to iOS inorder to specify
the location of the image picker popover on iPad. Needed
because apps were getting rejected from app store due to
poor arrow placement.  Added CameraPopoverOptions just for iOS.


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/eab1ae45
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/eab1ae45
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/eab1ae45

Branch: refs/heads/master
Commit: eab1ae45c970f66068784cb614bf544508e0654a
Parents: 184b040
Author: Becky Gibson <be...@apache.org>
Authored: Fri May 25 13:54:44 2012 -0400
Committer: Becky Gibson <be...@apache.org>
Committed: Fri May 25 16:09:19 2012 -0400

----------------------------------------------------------------------
 lib/common/plugin/Camera.js                |    6 +++++-
 lib/common/plugin/CameraConstants.js       |    7 +++++++
 lib/ios/platform.js                        |    3 +++
 lib/ios/plugin/ios/CameraPopoverOptions.js |   16 ++++++++++++++++
 4 files changed, 31 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/eab1ae45/lib/common/plugin/Camera.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/Camera.js b/lib/common/plugin/Camera.js
index f62dc47..fe48f63 100644
--- a/lib/common/plugin/Camera.js
+++ b/lib/common/plugin/Camera.js
@@ -98,8 +98,12 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) {
     } else if (typeof options.saveToPhotoAlbum == "number") {
         saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
     }
+    var popoverOptions = null;
+    if (typeof options.popoverOptions == "object") {
+        popoverOptions = options.popoverOptions;
+    }
 
-    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation, saveToPhotoAlbum]);
+    exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions]);
 };
 
 module.exports = cameraExport;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/eab1ae45/lib/common/plugin/CameraConstants.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/CameraConstants.js b/lib/common/plugin/CameraConstants.js
index 7043ec7..5fa31dd 100644
--- a/lib/common/plugin/CameraConstants.js
+++ b/lib/common/plugin/CameraConstants.js
@@ -16,5 +16,12 @@ module.exports = {
     PHOTOLIBRARY : 0,    // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
     CAMERA : 1,          // Take picture from camera
     SAVEDPHOTOALBUM : 2  // Choose image from picture library (same as PHOTOLIBRARY for Android)
+  },
+  PopoverArrowDirection:{
+      ARROW_UP : 1,        // matches iOS UIPopoverArrowDirection constants to specify arrow location on popover
+      ARROW_DOWN : 2,
+      ARROW_LEFT : 4,
+      ARROW_RIGHT : 8,
+      ARROW_ANY : 15
   }
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/eab1ae45/lib/ios/platform.js
----------------------------------------------------------------------
diff --git a/lib/ios/platform.js b/lib/ios/platform.js
index 128b2c2..ed99819 100644
--- a/lib/ios/platform.js
+++ b/lib/ios/platform.js
@@ -21,6 +21,9 @@ module.exports = {
         },
         console: {
             path: 'cordova/plugin/ios/console'
+        },
+        CameraPopoverOptions: {
+            path: 'cordova/plugin/ios/CameraPopoverOptions'
         }
     },
     merges:{

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/eab1ae45/lib/ios/plugin/ios/CameraPopoverOptions.js
----------------------------------------------------------------------
diff --git a/lib/ios/plugin/ios/CameraPopoverOptions.js b/lib/ios/plugin/ios/CameraPopoverOptions.js
new file mode 100644
index 0000000..a74b36b
--- /dev/null
+++ b/lib/ios/plugin/ios/CameraPopoverOptions.js
@@ -0,0 +1,16 @@
+var Camera = require('cordova/plugin/CameraConstants');
+
+/**
+ * Encapsulates options for iOS Popover image picker
+ */
+var CameraPopoverOptions = function(x,y,width,height,arrowDir){
+    // information of rectangle that popover should be anchored to
+    this.x = x || 0;
+    this.y = y || 32;
+    this.width = width || 320;
+    this.height = height || 480;
+    // The direction of the popover arrow
+    this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
+};
+
+module.exports = CameraPopoverOptions;
\ No newline at end of file