From 7641ec4aafae45db0b65d13d14c79298e1a4df4c Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Mon, 31 May 2010 15:59:56 -0700 Subject: [PATCH] added command to route the url to the ChildBrowserViewController, and added readme for a brief explaination of use. --- ChildBrowser/iPhone/ChildBrowserCommand.h | 21 + ChildBrowser/iPhone/ChildBrowserCommand.m | 27 ++ .../iPhone/ChildBrowserViewController.xib | 371 +++++++++++++++--- ChildBrowser/iPhone/README.txt | 21 + 4 files changed, 395 insertions(+), 45 deletions(-) create mode 100644 ChildBrowser/iPhone/ChildBrowserCommand.h create mode 100644 ChildBrowser/iPhone/ChildBrowserCommand.m create mode 100644 ChildBrowser/iPhone/README.txt diff --git a/ChildBrowser/iPhone/ChildBrowserCommand.h b/ChildBrowser/iPhone/ChildBrowserCommand.h new file mode 100644 index 00000000..75d81612 --- /dev/null +++ b/ChildBrowser/iPhone/ChildBrowserCommand.h @@ -0,0 +1,21 @@ +// +// PhoneGap ! ChildBrowserCommand +// +// +// Created by Jesse MacFadyen on 10-05-29. +// Copyright 2010 Nitobi. All rights reserved. +// + +#import +#import "PhoneGapCommand.h" + + +@interface ChildBrowserCommand : PhoneGapCommand { + + +} + +- (void) showWebPage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; + + +@end diff --git a/ChildBrowser/iPhone/ChildBrowserCommand.m b/ChildBrowser/iPhone/ChildBrowserCommand.m new file mode 100644 index 00000000..7fc64d4c --- /dev/null +++ b/ChildBrowser/iPhone/ChildBrowserCommand.m @@ -0,0 +1,27 @@ +// + +// +// +// Created by Jesse MacFadyen on 10-05-29. +// Copyright 2010 Nitobi. All rights reserved. +// + +#import "ChildBrowserCommand.h" +#import "ChildBrowserViewController.h" + + +@implementation ChildBrowserCommand + +- (void) showWebPage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options // args: url +{ + ChildBrowserViewController* childBrowser = [ [ ChildBrowserViewController alloc ] initWithScale:FALSE ]; + [ [ super appViewController ] presentModalViewController:childBrowser animated:YES ]; + + NSString *url = (NSString*) [arguments objectAtIndex:0]; + //stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + [childBrowser loadURL:url ]; + [childBrowser release]; +} + + +@end diff --git a/ChildBrowser/iPhone/ChildBrowserViewController.xib b/ChildBrowser/iPhone/ChildBrowserViewController.xib index e2a8748d..52d44f83 100644 --- a/ChildBrowser/iPhone/ChildBrowserViewController.xib +++ b/ChildBrowser/iPhone/ChildBrowserViewController.xib @@ -1,14 +1,18 @@ - + 768 - 9J61 - 677 - 949.43 - 353.00 + 10D573 + 762 + 1038.29 + 460.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 87 + YES - + YES @@ -16,7 +20,7 @@ YES - + YES @@ -27,9 +31,11 @@ YES IBFilesOwner + IBCocoaTouchFramework IBFirstResponder + IBCocoaTouchFramework @@ -47,6 +53,7 @@ YES YES + IBCocoaTouchFramework 1 YES @@ -57,55 +64,61 @@ NO NO + IBCocoaTouchFramework 1 YES + IBCocoaTouchFramework 1 0 + IBCocoaTouchFramework 5 + IBCocoaTouchFramework 13 + IBCocoaTouchFramework 5 - - NSImage - arrow_left.png - - 3.200000e+01 + IBCocoaTouchFramework + 32 + 19 + + + IBCocoaTouchFramework + + 5 - - NSImage - arrow_right.png - - 3.200000e+01 + IBCocoaTouchFramework + 32 + 20 + IBCocoaTouchFramework 5 - - NSImage - 71-compass.png - - 3.200000e+01 + IBCocoaTouchFramework + 32 + 9 + IBCocoaTouchFramework 5 @@ -123,10 +136,11 @@ NO YES NO + IBCocoaTouchFramework Loading... Helvetica - 1.300000e+01 + 13 16 @@ -139,7 +153,7 @@ 1 NO - 1.000000e+01 + 10 @@ -149,6 +163,7 @@ NO NO NO + IBCocoaTouchFramework {320, 460} @@ -159,6 +174,7 @@ + IBCocoaTouchFramework @@ -266,9 +282,7 @@ YES 0 - - YES - + @@ -282,18 +296,18 @@ - + -1 - - RmlsZSdzIE93bmVyA + + File's Owner -2 - + 4 @@ -314,6 +328,7 @@ + @@ -372,11 +387,16 @@ + + 39 + + + YES - + YES -1.CustomClassName -2.CustomClassName @@ -390,6 +410,7 @@ 32.IBPluginDependency 37.IBPluginDependency 38.IBPluginDependency + 39.IBPluginDependency 4.IBPluginDependency 6.IBPluginDependency 7.IBPluginDependency @@ -400,7 +421,8 @@ YES ChildBrowserViewController UIResponder - {{145, 107}, {320, 480}} + {{403, 107}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -419,9 +441,7 @@ YES - - YES - + YES @@ -429,15 +449,13 @@ YES - - YES - + YES - 38 + 39 @@ -447,7 +465,7 @@ UIViewController YES - + YES onDoneButtonPress: onSafariButtonPress: @@ -460,7 +478,7 @@ YES - + YES addressLabel backBtn @@ -485,14 +503,277 @@ IBProjectSource - Classes/ChildBrowserViewController.h + ../../../../CodeRepos/GitHub/gitPhoneGapPlugins/ChildBrowser/iPhone/ChildBrowserViewController.h + + + + NSObject + + IBProjectSource + Classes/AsyncSocket.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSNetServices.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPort.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSStream.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSXMLParser.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIActivityIndicatorView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIActivityIndicatorView.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIToolbar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIToolbar.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + UIWebView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIWebView.h 0 - ../PhoneGap.xcodeproj + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + ../../../../../Users/jesse/Documents/PGSockets/PGSockets.xcodeproj 3 - 3.0 + 87 diff --git a/ChildBrowser/iPhone/README.txt b/ChildBrowser/iPhone/README.txt new file mode 100644 index 00000000..9cb8621a --- /dev/null +++ b/ChildBrowser/iPhone/README.txt @@ -0,0 +1,21 @@ + + + + +The child browser allows you to display external webpages within your PhoneGap application. + +A simple use case would be: + +- Users can post links, and you don't want your users to exit your app to view the link. + +This command creates a popup browser that is shown in front of your app, when the user presses the done button they are simply returned to your app ( actually they never left ) + +The ChildBrowser has buttons for refreshing, navigating back + forwards, as well as the option to open in Safari. + +Note, because this is open source, I could not include the graphics I usually use for the back/forward and safari buttons. I have changed the XIB file to use system buttons ( rewind / fast-forward + action ) Ideally you should modify the XIB to use your own look. + +Here is a sample command to open google in a childbrowser : + +PhoneGap.exec("ChildBrowserCommand.showWebPage", "http://www.google.com"); + +