cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [05/38] updated android, ios, bb libraries to 2.8.x branch. fixed a few assertions with project changes. removed blackberry support until create script can be finalized.
Date Thu, 23 May 2013 23:41:26 GMT
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVCamera.h b/lib/cordova-ios/CordovaLib/Classes/CDVCamera.h
index 65eac77..2932e3b 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVCamera.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVCamera.h
@@ -18,6 +18,8 @@
  */
 
 #import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+#import <CoreLocation/CLLocationManager.h>
 #import "CDVPlugin.h"
 
 enum CDVDestinationType {
@@ -62,10 +64,14 @@ typedef NSUInteger CDVMediaType;
 
 @interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
                        UINavigationControllerDelegate,
-                       UIPopoverControllerDelegate>
+                       UIPopoverControllerDelegate,
+                       CLLocationManagerDelegate>
 {}
 
 @property (strong) CDVCameraPicker* pickerController;
+@property (strong) NSMutableDictionary *metadata;
+@property (strong, nonatomic) CLLocationManager *locationManager;
+@property (strong) NSData* data;
 
 /*
  * getPicture
@@ -85,8 +91,12 @@ typedef NSUInteger CDVMediaType;
 - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
 - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image
editingInfo:(NSDictionary*)editingInfo;
 - (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
+- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController
*)viewController animated:(BOOL)animated;
 - (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize;
 - (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize;
 - (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage;
 
+- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation
fromLocation:(CLLocation*)oldLocation;
+- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m b/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
index 823fde9..1ee641c 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVCamera.m
@@ -22,6 +22,11 @@
 #import "NSArray+Comparisons.h"
 #import "NSData+Base64.h"
 #import "NSDictionary+Extensions.h"
+#import <ImageIO/CGImageProperties.h>
+#import <AssetsLibrary/ALAssetRepresentation.h>
+#import <ImageIO/CGImageSource.h>
+#import <ImageIO/CGImageProperties.h>
+#import <ImageIO/CGImageDestination.h>
 #import <MobileCoreServices/UTCoreTypes.h>
 
 #define CDV_PHOTO_PREFIX @"cdv_photo_"
@@ -41,7 +46,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
     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;
+@synthesize hasPendingOperation, pickerController, locationManager;
 
 - (BOOL)popoverSupported
 {
@@ -187,6 +192,17 @@ static NSSet* org_apache_cordova_validArrowDirections;
                                                                animated:YES];
 }
 
+- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController
*)viewController animated:(BOOL)animated
+{
+    if([navigationController isKindOfClass:[UIImagePickerController class]]){
+        UIImagePickerController * cameraPicker = (UIImagePickerController*)navigationController;
+        
+        if(![cameraPicker.mediaTypes containsObject:(NSString*) kUTTypeImage]){
+            [viewController.navigationItem setTitle:NSLocalizedString(@"Videos title", nil)];
+        }
+    }
+}
+
 - (void)cleanup:(CDVInvokedUrlCommand*)command
 {
     // empty the tmp directory
@@ -271,10 +287,6 @@ static NSSet* org_apache_cordova_validArrowDirections;
                 image = [info objectForKey:UIImagePickerControllerOriginalImage];
             }
 
-            if (cameraPicker.saveToPhotoAlbum) {
-                UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
-            }
-
             if (cameraPicker.correctOrientation) {
                 image = [self imageCorrectedForCaptureOrientation:image];
             }
@@ -295,12 +307,22 @@ static NSSet* org_apache_cordova_validArrowDirections;
             if (cameraPicker.encodingType == EncodingTypePNG) {
                 data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
             } else {
-                data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage,
cameraPicker.quality / 100.0f);
-
-                /* splice loc */
-                CDVJpegHeaderWriter* exifWriter = [[CDVJpegHeaderWriter alloc] init];
-                NSString* headerstring = [exifWriter createExifAPP1:[info objectForKey:@"UIImagePickerControllerMediaMetadata"]];
-                data = [exifWriter spliceExifBlockIntoJpeg:data withExifBlock:headerstring];
+                self.data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage,
cameraPicker.quality / 100.0f);
+
+                NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
+                if (controllerMetadata) {
+                    self.metadata = [[NSMutableDictionary alloc] init];
+                    
+                    NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString
*)kCGImagePropertyExifDictionary]mutableCopy];
+                    if (EXIFDictionary)	[self.metadata setObject:EXIFDictionary forKey:(NSString
*)kCGImagePropertyExifDictionary];
+                    
+                    [[self locationManager] startUpdatingLocation];
+                    return;
+                }
+            }
+            
+            if (cameraPicker.saveToPhotoAlbum) {
+                UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);
             }
 
             if (cameraPicker.returnType == DestinationTypeFileUri) {
@@ -551,6 +573,143 @@ static NSSet* org_apache_cordova_validArrowDirections;
     self.hasPendingOperation = NO;
 }
 
+
+- (CLLocationManager *)locationManager {
+    
+	if (locationManager != nil) {
+		return locationManager;
+	}
+    
+	locationManager = [[CLLocationManager alloc] init];
+	[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
+	[locationManager setDelegate:self];
+    
+	return locationManager;
+}
+
+- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation
fromLocation:(CLLocation*)oldLocation
+{
+	if (locationManager != nil) {
+		[self.locationManager stopUpdatingLocation];
+		self.locationManager = nil;
+        
+		NSMutableDictionary *GPSDictionary = [[NSMutableDictionary dictionary] init];
+        
+		CLLocationDegrees latitude  = newLocation.coordinate.latitude;
+		CLLocationDegrees longitude = newLocation.coordinate.longitude;
+        
+		// latitude
+		if (latitude < 0.0) {
+			latitude = latitude * -1.0f;
+			[GPSDictionary setObject:@"S" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
+		} else {
+			[GPSDictionary setObject:@"N" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
+		}
+		[GPSDictionary setObject:[NSNumber numberWithFloat:latitude] forKey:(NSString*)kCGImagePropertyGPSLatitude];
+        
+		// longitude
+		if (longitude < 0.0) {
+			longitude = longitude * -1.0f;
+			[GPSDictionary setObject:@"W" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
+		}
+		else {
+			[GPSDictionary setObject:@"E" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
+		}
+		[GPSDictionary setObject:[NSNumber numberWithFloat:longitude] forKey:(NSString*)kCGImagePropertyGPSLongitude];
+        
+		// altitude
+        CGFloat altitude = newLocation.altitude;
+        if (!isnan(altitude)){
+			if (altitude < 0) {
+				altitude = -altitude;
+				[GPSDictionary setObject:@"1" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
+			} else {
+				[GPSDictionary setObject:@"0" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
+			}
+			[GPSDictionary setObject:[NSNumber numberWithFloat:altitude] forKey:(NSString *)kCGImagePropertyGPSAltitude];
+        }
+        
+        // Time and date
+        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+        [formatter setDateFormat:@"HH:mm:ss.SSSSSS"];
+        [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
+        [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString
*)kCGImagePropertyGPSTimeStamp];
+        [formatter setDateFormat:@"yyyy:MM:dd"];
+        [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString
*)kCGImagePropertyGPSDateStamp];
+        
+		[self.metadata setObject:GPSDictionary forKey:(NSString *)kCGImagePropertyGPSDictionary];
+ 		[self imagePickerControllerReturnImageResult];
+	}
+}
+
+- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
+	if (locationManager != nil) {
+		[self.locationManager stopUpdatingLocation];
+		self.locationManager = nil;
+        
+		[self imagePickerControllerReturnImageResult];
+	}
+}
+
+- (void)imagePickerControllerReturnImageResult
+{
+    CDVPluginResult* result = nil;
+    
+    if (self.metadata) {
+        CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge_retained CFDataRef)self.data,
NULL);
+        CFStringRef sourceType = CGImageSourceGetType(sourceImage);
+        
+        CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge
CFMutableDataRef)self.data, sourceType, 1, NULL);
+        CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge
CFDictionaryRef)self.metadata);
+        CGImageDestinationFinalize(destinationImage);
+        
+        CFRelease(sourceImage);
+        CFRelease(destinationImage);
+    }
+    
+    if (self.pickerController.saveToPhotoAlbum) {
+        UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[self data]], nil, nil, nil);
+    }
+    
+    if (self.pickerController.returnType == DestinationTypeFileUri) {
+        // write to temp directory and return URI
+        // get the temp directory path
+        NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];
+        NSError* err = nil;
+        NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by apple (vs
[NSFileManager defaultManager]) to be threadsafe
+        // generate unique file name
+        NSString* filePath;
+        
+        int i = 1;
+        do {
+            filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX,
i++, self.pickerController.encodingType == EncodingTypePNG ? @"png":@"jpg"];
+        } while ([fileMgr fileExistsAtPath:filePath]);
+        
+        // save file
+        if (![self.data writeToFile:filePath options:NSAtomicWrite error:&err]) {
+            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err
localizedDescription]];
+        }
+        else {
+            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSURL
fileURLWithPath:filePath] absoluteString]];
+        }
+    }
+    else {
+        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[self.data
base64EncodedString]];
+    }
+    if (result) {
+        [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
+    }
+    
+    if (result) {
+        [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
+    }
+    
+    self.hasPendingOperation = NO;
+    self.pickerController = nil;
+    self.data = nil;
+    self.metadata = nil;
+}
+
 @end
 
 @implementation CDVCameraPicker

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m b/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
index d89e3d3..6b7ed44 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVCapture.m
@@ -108,7 +108,6 @@
     if ([options isKindOfClass:[NSNull class]]) {
         options = [NSDictionary dictionary];
     }
-    NSString* mode = [options objectForKey:@"mode"];
 
     // options could contain limit and mode neither of which are supported at this time
     // taking more than one picture (limit) is only supported if provide own controls via
cameraOverlayView property
@@ -139,7 +138,6 @@
         }*/
         // CDVImagePicker specific property
         pickerController.callbackId = callbackId;
-        pickerController.mimeType = mode;
 
         if ([self.viewController respondsToSelector:@selector(presentViewController:::)])
{
             [self.viewController presentViewController:pickerController animated:YES completion:nil];

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
index 7392580..2e06c88 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.h
@@ -17,7 +17,10 @@
  under the License.
  */
 
-@interface CDVConfigParser : NSObject <NSXMLParserDelegate>{}
+@interface CDVConfigParser : NSObject <NSXMLParserDelegate>
+{
+    NSString* featureName;
+}
 
 @property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict;
 @property (nonatomic, readonly, strong) NSMutableDictionary* settings;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
index ffc8ede..23ae401 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVConfigParser.m
@@ -41,6 +41,7 @@
         self.settings = [[NSMutableDictionary alloc] initWithCapacity:30];
         self.whitelistHosts = [[NSMutableArray alloc] initWithCapacity:30];
         self.startupPluginNames = [[NSMutableArray alloc] initWithCapacity:8];
+        featureName = nil;
     }
     return self;
 }
@@ -55,6 +56,24 @@
         if ([@"true" isEqualToString : attributeDict[@"onload"]]) {
             [self.startupPluginNames addObject:name];
         }
+        NSLog(@"\nUse of the <plugin> tag has been deprecated. Use a <feature>
tag instead. Change:\n"
+            @"    <plugin name=\"%@\" value=\"%@\" />\n"
+            @"To:\n"
+            @"    <feature name=\"%@\">\n"
+            @"        <param name=\"ios-package\" value=\"%@\">\n"
+            @"    </feature>\n"
+            , attributeDict[@"name"], attributeDict[@"value"], attributeDict[@"name"], attributeDict[@"value"]);
+    } else if ([elementName isEqualToString:@"feature"]) { // store feature name to use with
correct parameter set
+        featureName = [attributeDict[@"name"] lowercaseString];
+    } else if ((featureName != nil) && [elementName isEqualToString:@"param"]) {
+        NSString* paramName = [attributeDict[@"name"] lowercaseString];
+        id value = attributeDict[@"value"];
+        if ([paramName isEqualToString:@"ios-package"]) {
+            pluginsDict[featureName] = value;
+        }
+        if ([paramName isEqualToString:@"onload"] && [@"true" isEqualToString : value])
{
+            [self.startupPluginNames addObject:featureName];
+        }
     } else if ([elementName isEqualToString:@"access"]) {
         [whitelistHosts addObject:attributeDict[@"origin"]];
     } else if ([elementName isEqualToString:@"content"]) {
@@ -62,6 +81,13 @@
     }
 }
 
+- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
+{
+    if ([elementName isEqualToString:@"feature"]) { // no longer handling a feature so release
+        featureName = nil;
+    }
+}
+
 - (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
 {
     NSAssert(NO, @"config.xml parse error line %d col %d", [parser lineNumber], [parser columnNumber]);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.h b/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.h
index 765326a..f87baff 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.h
@@ -60,6 +60,8 @@
 - (void)close;
 - (void)navigateTo:(NSURL*)url;
 - (void)showLocationBar:(BOOL)show;
+- (void)showToolBar:(BOOL)show;
+- (void)setCloseButtonTitle:(NSString*)title;
 
 - (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent;
 
@@ -68,6 +70,9 @@
 @interface CDVInAppBrowserOptions : NSObject {}
 
 @property (nonatomic, assign) BOOL location;
+@property (nonatomic, assign) BOOL toolbar;
+@property (nonatomic, copy) NSString* closebuttoncaption;
+
 @property (nonatomic, copy) NSString* presentationstyle;
 @property (nonatomic, copy) NSString* transitionstyle;
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.m b/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.m
index b03d1fe..d5f06ec 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVInAppBrowser.m
@@ -103,13 +103,17 @@
 
     CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
     [self.inAppBrowserViewController showLocationBar:browserOptions.location];
+    [self.inAppBrowserViewController showToolBar:browserOptions.toolbar];
+    if (browserOptions.closebuttoncaption != nil) {
+        [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption];
+    }
 
     // Set Presentation Style
     UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
     if (browserOptions.presentationstyle != nil) {
-        if ([browserOptions.presentationstyle isEqualToString:@"pagesheet"]) {
+        if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"pagesheet"])
{
             presentationStyle = UIModalPresentationPageSheet;
-        } else if ([browserOptions.presentationstyle isEqualToString:@"formsheet"]) {
+        } else if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"formsheet"])
{
             presentationStyle = UIModalPresentationFormSheet;
         }
     }
@@ -118,9 +122,9 @@
     // Set Transition Style
     UIModalTransitionStyle transitionStyle = UIModalTransitionStyleCoverVertical; // default
     if (browserOptions.transitionstyle != nil) {
-        if ([browserOptions.transitionstyle isEqualToString:@"fliphorizontal"]) {
+        if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"fliphorizontal"])
{
             transitionStyle = UIModalTransitionStyleFlipHorizontal;
-        } else if ([browserOptions.transitionstyle isEqualToString:@"crossdissolve"]) {
+        } else if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"crossdissolve"])
{
             transitionStyle = UIModalTransitionStyleCrossDissolve;
         }
     }
@@ -401,9 +405,6 @@
 
     self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self action:@selector(close)];
     self.closeButton.enabled = YES;
-    self.closeButton.imageInsets = UIEdgeInsetsZero;
-    self.closeButton.style = UIBarButtonItemStylePlain;
-    self.closeButton.width = 32.000;
 
     UIBarButtonItem* flexibleSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil action:nil];
 
@@ -467,32 +468,132 @@
     [self.view addSubview:self.spinner];
 }
 
+- (void)setCloseButtonTitle:(NSString*)title
+{
+    // the advantage of using UIBarButtonSystemItemDone is the system will localize it for
you automatically
+    // but, if you want to set this yourself, knock yourself out (we can't set the title
for a system Done button, so we have to create a new one)
+    self.closeButton = nil;
+    self.closeButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered
target:self action:@selector(close)];
+    self.closeButton.enabled = YES;
+    self.closeButton.tintColor = [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0
/ 255.0 alpha:1];
+
+    NSMutableArray* items = [self.toolbar.items mutableCopy];
+    [items replaceObjectAtIndex:0 withObject:self.closeButton];
+    [self.toolbar setItems:items];
+}
+
 - (void)showLocationBar:(BOOL)show
 {
-    CGRect addressLabelFrame = self.addressLabel.frame;
-    BOOL locationBarVisible = (addressLabelFrame.size.height > 0);
+    CGRect locationbarFrame = self.addressLabel.frame;
+
+    BOOL toolbarVisible = !self.toolbar.hidden;
 
     // prevent double show/hide
-    if (locationBarVisible == show) {
+    if (show == !(self.addressLabel.hidden)) {
         return;
     }
 
     if (show) {
-        CGRect webViewBounds = self.view.bounds;
-        webViewBounds.size.height -= FOOTER_HEIGHT;
-        self.webView.frame = webViewBounds;
+        self.addressLabel.hidden = NO;
+
+        if (toolbarVisible) {
+            // toolBar at the bottom, leave as is
+            // put locationBar on top of the toolBar
+
+            CGRect webViewBounds = self.view.bounds;
+            webViewBounds.size.height -= FOOTER_HEIGHT;
+            self.webView.frame = webViewBounds;
+
+            locationbarFrame.origin.y = webViewBounds.size.height;
+            self.addressLabel.frame = locationbarFrame;
+        } else {
+            // no toolBar, so put locationBar at the bottom
 
-        CGRect addressLabelFrame = self.addressLabel.frame;
-        addressLabelFrame.size.height = LOCATIONBAR_HEIGHT;
-        self.addressLabel.frame = addressLabelFrame;
+            CGRect webViewBounds = self.view.bounds;
+            webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
+            self.webView.frame = webViewBounds;
+
+            locationbarFrame.origin.y = webViewBounds.size.height;
+            self.addressLabel.frame = locationbarFrame;
+        }
     } else {
-        CGRect webViewBounds = self.view.bounds;
-        webViewBounds.size.height -= TOOLBAR_HEIGHT;
-        self.webView.frame = webViewBounds;
+        self.addressLabel.hidden = YES;
+
+        if (toolbarVisible) {
+            // locationBar is on top of toolBar, hide locationBar
+
+            // webView take up whole height less toolBar height
+            CGRect webViewBounds = self.view.bounds;
+            webViewBounds.size.height -= TOOLBAR_HEIGHT;
+            self.webView.frame = webViewBounds;
+        } else {
+            // no toolBar, expand webView to screen dimensions
+
+            CGRect webViewBounds = self.view.bounds;
+            self.webView.frame = webViewBounds;
+        }
+    }
+}
+
+- (void)showToolBar:(BOOL)show
+{
+    CGRect toolbarFrame = self.toolbar.frame;
+    CGRect locationbarFrame = self.addressLabel.frame;
 
-        CGRect addressLabelFrame = self.addressLabel.frame;
-        addressLabelFrame.size.height = 0;
-        self.addressLabel.frame = addressLabelFrame;
+    BOOL locationbarVisible = !self.addressLabel.hidden;
+
+    // prevent double show/hide
+    if (show == !(self.toolbar.hidden)) {
+        return;
+    }
+
+    if (show) {
+        self.toolbar.hidden = NO;
+
+        if (locationbarVisible) {
+            // locationBar at the bottom, move locationBar up
+            // put toolBar at the bottom
+
+            CGRect webViewBounds = self.view.bounds;
+            webViewBounds.size.height -= FOOTER_HEIGHT;
+            self.webView.frame = webViewBounds;
+
+            locationbarFrame.origin.y = webViewBounds.size.height;
+            self.addressLabel.frame = locationbarFrame;
+
+            toolbarFrame.origin.y = (webViewBounds.size.height + LOCATIONBAR_HEIGHT);
+            self.toolbar.frame = toolbarFrame;
+        } else {
+            // no locationBar, so put toolBar at the bottom
+
+            CGRect webViewBounds = self.view.bounds;
+            webViewBounds.size.height -= TOOLBAR_HEIGHT;
+            self.webView.frame = webViewBounds;
+
+            toolbarFrame.origin.y = webViewBounds.size.height;
+            self.toolbar.frame = toolbarFrame;
+        }
+    } else {
+        self.toolbar.hidden = YES;
+
+        if (locationbarVisible) {
+            // locationBar is on top of toolBar, hide toolBar
+            // put locationBar at the bottom
+
+            // webView take up whole height less locationBar height
+            CGRect webViewBounds = self.view.bounds;
+            webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
+            self.webView.frame = webViewBounds;
+
+            // move locationBar down
+            locationbarFrame.origin.y = webViewBounds.size.height;
+            self.addressLabel.frame = locationbarFrame;
+        } else {
+            // no locationBar, expand webView to screen dimensions
+
+            CGRect webViewBounds = self.view.bounds;
+            self.webView.frame = webViewBounds;
+        }
     }
 }
 
@@ -655,6 +756,8 @@
     if (self = [super init]) {
         // default values
         self.location = YES;
+        self.toolbar = YES;
+        self.closebuttoncaption = nil;
 
         self.enableviewportscale = NO;
         self.mediaplaybackrequiresuseraction = NO;
@@ -679,19 +782,20 @@
 
         if ([keyvalue count] == 2) {
             NSString* key = [[keyvalue objectAtIndex:0] lowercaseString];
-            NSString* value = [[keyvalue objectAtIndex:1] lowercaseString];
+            NSString* value = [keyvalue objectAtIndex:1];
+            NSString* value_lc = [value lowercaseString];
 
-            BOOL isBoolean = [value isEqualToString:@"yes"] || [value isEqualToString:@"no"];
+            BOOL isBoolean = [value_lc isEqualToString:@"yes"] || [value_lc isEqualToString:@"no"];
             NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
             [numberFormatter setAllowsFloats:YES];
-            BOOL isNumber = [numberFormatter numberFromString:value] != nil;
+            BOOL isNumber = [numberFormatter numberFromString:value_lc] != nil;
 
             // set the property according to the key name
             if ([obj respondsToSelector:NSSelectorFromString(key)]) {
                 if (isNumber) {
-                    [obj setValue:[numberFormatter numberFromString:value] forKey:key];
+                    [obj setValue:[numberFormatter numberFromString:value_lc] forKey:key];
                 } else if (isBoolean) {
-                    [obj setValue:[NSNumber numberWithBool:[value isEqualToString:@"yes"]]
forKey:key];
+                    [obj setValue:[NSNumber numberWithBool:[value_lc isEqualToString:@"yes"]]
forKey:key];
                 } else {
                     [obj setValue:value forKey:key];
                 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVNotification.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVNotification.m b/lib/cordova-ios/CordovaLib/Classes/CDVNotification.m
index 821cb9f..464eb1f 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVNotification.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVNotification.m
@@ -31,10 +31,11 @@
  *  message       The alert view message.
  *  title         The alert view title.
  *  buttons       The array of customized strings for the buttons.
+ *  defaultText   The input text for the textbox (if textbox exists).
  *  callbackId    The commmand callback id.
  *  dialogType    The type of alert view [alert | prompt].
  */
-- (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons
callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType
+- (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons
defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType
 {
     CDVAlertView* alertView = [[CDVAlertView alloc]
         initWithTitle:title
@@ -53,6 +54,8 @@
 
     if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
         alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
+        UITextField* textField = [alertView textFieldAtIndex:0];
+        textField.text = defaultText;
     }
 
     [alertView show];
@@ -65,7 +68,7 @@
     NSString* title = [command argumentAtIndex:1];
     NSString* buttons = [command argumentAtIndex:2];
 
-    [self showDialogWithMessage:message title:title buttons:@[buttons] callbackId:callbackId
dialogType:DIALOG_TYPE_ALERT];
+    [self showDialogWithMessage:message title:title buttons:@[buttons] defaultText:nil callbackId:callbackId
dialogType:DIALOG_TYPE_ALERT];
 }
 
 - (void)confirm:(CDVInvokedUrlCommand*)command
@@ -75,7 +78,7 @@
     NSString* title = [command argumentAtIndex:1];
     NSArray* buttons = [command argumentAtIndex:2];
 
-    [self showDialogWithMessage:message title:title buttons:buttons callbackId:callbackId
dialogType:DIALOG_TYPE_ALERT];
+    [self showDialogWithMessage:message title:title buttons:buttons defaultText:nil callbackId:callbackId
dialogType:DIALOG_TYPE_ALERT];
 }
 
 - (void)prompt:(CDVInvokedUrlCommand*)command
@@ -84,8 +87,9 @@
     NSString* message = [command argumentAtIndex:0];
     NSString* title = [command argumentAtIndex:1];
     NSArray* buttons = [command argumentAtIndex:2];
+    NSString* defaultText = [command argumentAtIndex:3];
 
-    [self showDialogWithMessage:message title:title buttons:buttons callbackId:callbackId
dialogType:DIALOG_TYPE_PROMPT];
+    [self showDialogWithMessage:message title:title buttons:buttons defaultText:defaultText
callbackId:callbackId dialogType:DIALOG_TYPE_PROMPT];
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVSplashScreen.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVSplashScreen.m b/lib/cordova-ios/CordovaLib/Classes/CDVSplashScreen.m
index 45889a0..fdb79fa 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVSplashScreen.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVSplashScreen.m
@@ -152,7 +152,12 @@
         _curImageName = imageName;
     }
 
-    [self updateBounds];
+    // Check that splash screen's image exists before updating bounds
+    if (_imageView.image) {
+        [self updateBounds];
+    } else {
+        NSLog(@"WARNING: The splashscreen image named %@ was not found", imageName);
+    }
 }
 
 - (void)updateBounds

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.h b/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.h
index e339dd0..9165097 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.h
@@ -28,6 +28,7 @@ extern NSString* const kCDVDefaultWhitelistRejectionString;
 - (id)initWithArray:(NSArray*)array;
 - (BOOL)schemeIsAllowed:(NSString*)scheme;
 - (BOOL)URLIsAllowed:(NSURL*)url;
+- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure;
 - (NSString*)errorStringForURL:(NSURL*)url;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.m b/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.m
index db7aa32..e6807bd 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVWhitelist.m
@@ -124,7 +124,7 @@ NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
 
         // check for single wildcard '*', if found set allowAll to YES
         if ([host isEqualToString:@"*"]) {
-            [_expandedWhitelists setObject:[NSArray arrayWithObject:host] forKey:scheme];
+            [_expandedWhitelists setObject:[NSMutableArray arrayWithObject:host] forKey:scheme];
             continue;
         }
 
@@ -170,19 +170,27 @@ NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
 
 - (BOOL)URLIsAllowed:(NSURL*)url
 {
+    return [self URLIsAllowed:url logFailure:YES];
+}
+
+- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure
+{
     NSString* scheme = [url scheme];
 
     // http[s] and ftp[s] should also validate against the common set in the kCDVDefaultSchemeName
list
     if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme
isEqualToString:@"ftp"] || [scheme isEqualToString:@"ftps"]) {
         NSURL* newUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", kCDVDefaultSchemeName,
[url host]]];
         // If it is allowed, we are done.  If not, continue to check for the actual scheme-specific
list
-        if ([self URLIsAllowed:newUrl]) {
+        if ([self URLIsAllowed:newUrl logFailure:NO]) {
             return YES;
         }
     }
 
     // Check that the scheme is supported
     if (![self schemeIsAllowed:scheme]) {
+        if (logFailure) {
+            NSLog(@"%@", [self errorStringForURL:url]);
+        }
         return NO;
     }
 
@@ -204,13 +212,20 @@ NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
     while (regex = [enumerator nextObject]) {
         NSPredicate* regex_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
 
+        // if wildcard, break out and allow
+        if ([regex isEqualToString:@"*"]) {
+            return YES;
+        }
+
         if ([regex_test evaluateWithObject:urlHost] == YES) {
             // if it matches at least one rule, return
             return YES;
         }
     }
 
-    NSLog(@"%@", [self errorStringForURL:url]);
+    if (logFailure) {
+        NSLog(@"%@", [self errorStringForURL:url]);
+    }
     // if we got here, the url host is not in the white-list, do nothing
     return NO;
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/88ad654c/lib/cordova-ios/CordovaLib/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/VERSION b/lib/cordova-ios/CordovaLib/VERSION
index 24ba9a3..1277c83 100644
--- a/lib/cordova-ios/CordovaLib/VERSION
+++ b/lib/cordova-ios/CordovaLib/VERSION
@@ -1 +1 @@
-2.7.0
+2.8.0rc1


Mime
View raw message