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 21:14:47 UTC
ios commit: fixes CB-56 popover placement
Updated Branches:
refs/heads/master 50d2be0bb -> bebfd7aae
fixes CB-56 popover placement
Modified takePicture() to accept an options dictionary
with parameters defining the placement of the popover
image picker on the iPad. Created a static to test for
valid arrow placement values.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/bebfd7aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/bebfd7aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/bebfd7aa
Branch: refs/heads/master
Commit: bebfd7aaeb691ad0341feeab2f0c9d5328b1c3a9
Parents: 50d2be0
Author: Becky Gibson <be...@apache.org>
Authored: Thu May 24 11:51:22 2012 -0400
Committer: Becky Gibson <be...@apache.org>
Committed: Fri May 25 14:24:33 2012 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVCamera.m | 28 ++++++++++++++++++--
CordovaLib/Classes/NSDictionary+Extensions.h | 1 +
CordovaLib/Classes/NSDictionary+Extensions.m | 11 ++++++++
3 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/bebfd7aa/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
index a9dedba..282d8c1 100644
--- a/CordovaLib/Classes/CDVCamera.m
+++ b/CordovaLib/Classes/CDVCamera.m
@@ -22,6 +22,7 @@
#import "NSDictionary+Extensions.h"
#import <MobileCoreServices/UTCoreTypes.h>
+static NSSet* org_apache_cordova_validArrowDirections;
@interface CDVCamera ()
@@ -31,6 +32,11 @@
@implementation CDVCamera
++ (void) initialize
+{
+ org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects: [NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown],[NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
+}
+
@synthesize hasPendingOperation, pickerController;
- (BOOL) popoverSupported
@@ -122,11 +128,27 @@
{
cameraPicker.popoverController = [[[NSClassFromString(@"UIPopoverController") alloc]
initWithContentViewController:cameraPicker] autorelease];
- }
+ }
+ int x = 0;
+ int y = 32;
+ int width = 320;
+ int height = 480;
+ UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny;
+ if (options) {
+ x = [options integerValueForKey:@"x" defaultValue:0];
+ y = [options integerValueForKey:@"y" defaultValue:32];
+ width = [options integerValueForKey:@"width" defaultValue:320];
+ height = [options integerValueForKey:@"height" defaultValue:480];
+ arrowDirection = [options integerValueForKey: @"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
+ if(![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithInt:arrowDirection]]){
+ arrowDirection = UIPopoverArrowDirectionAny;
+ }
+ }
+
cameraPicker.popoverController.delegate = self;
- [cameraPicker.popoverController presentPopoverFromRect:CGRectMake(0,32,320,480)
+ [cameraPicker.popoverController presentPopoverFromRect:CGRectMake(x,y,width,height)
inView:[self.webView superview]
- permittedArrowDirections:UIPopoverArrowDirectionAny
+ permittedArrowDirections:arrowDirection
animated:YES];
}
else
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/bebfd7aa/CordovaLib/Classes/NSDictionary+Extensions.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/NSDictionary+Extensions.h b/CordovaLib/Classes/NSDictionary+Extensions.h
index cc85128..88ac69d 100644
--- a/CordovaLib/Classes/NSDictionary+Extensions.h
+++ b/CordovaLib/Classes/NSDictionary+Extensions.h
@@ -23,6 +23,7 @@
- (bool) existsValue:(NSString*)expectedValue forKey:(NSString*)key;
- (NSInteger) integerValueForKey:(NSString*)key defaultValue:(NSInteger)defaultValue withRange:(NSRange)range;
+- (NSInteger) integerValueForKey:(NSString*)key defaultValue:(NSInteger)defaultValue;
- (BOOL) typeValueForKey:(NSString *)key isArray:(BOOL*)bArray isNull:(BOOL*)bNull isNumber:(BOOL*) bNumber isString:(BOOL*)bString;
- (BOOL) valueForKeyIsArray:(NSString *)key;
- (BOOL) valueForKeyIsNull:(NSString *)key;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/bebfd7aa/CordovaLib/Classes/NSDictionary+Extensions.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/NSDictionary+Extensions.m b/CordovaLib/Classes/NSDictionary+Extensions.m
index eb987b2..b0f76f9 100644
--- a/CordovaLib/Classes/NSDictionary+Extensions.m
+++ b/CordovaLib/Classes/NSDictionary+Extensions.m
@@ -50,6 +50,17 @@
return value;
}
+- (NSInteger) integerValueForKey:(NSString*)key defaultValue:(NSInteger)defaultValue
+{
+
+ NSInteger value = defaultValue;
+
+ NSNumber* val = [self valueForKey:key]; //value is an NSNumber
+ if (val != nil) {
+ value = [val integerValue];
+ }
+ return value;
+}
/*
* Determine the type of object stored in a dictionary