Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
refractor PhoneGapDelegate to allow teardown and reinit of web view
Browse files Browse the repository at this point in the history
  • Loading branch information
tstellanova-sfdc committed Nov 11, 2011
1 parent 9a55c8c commit 1c3a5b3
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 106 deletions.
79 changes: 75 additions & 4 deletions PhoneGapLib/Classes/PhoneGapDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,100 @@
@property (nonatomic, readonly, retain) NSDictionary *settings;
@property (nonatomic, readonly, retain) PGWhitelist* whitelist; // readonly for public


#pragma mark - App settings

+ (NSDictionary*)getBundlePlist:(NSString *)plistName;
+ (NSString*) wwwFolderName;
+ (NSString*) pathForResource:(NSString*)resourcepath;
+ (NSString*) phoneGapVersion;
+ (NSString*) applicationDocumentsDirectory;

/**
@return URL string for the first page that should be loaded in the web view: defaults to www/index.html
*/
+ (NSString*) startPage;

/**
@return NSString The first URL scheme supported by this app, if any registered with CFBundleURLSchemes in the app .plist
*/
- (NSString*) appURLScheme;

/**
@return NSDictionary A set of device and app properties
*/
- (NSDictionary*) deviceProperties;


#pragma mark - Command Queue

- (int)executeQueuedCommands;
- (void)flushCommandQueue;
- (BOOL) execute:(InvokedUrlCommand*)command;

#pragma mark - Plugin Management

/**
*/
- (void)reinitializePlugins;

/**
Get an instance of the named plugin. This method creates a new instance if
one does not already exist. If there is an existing instance, this method returns it.
Thus, plugins are essentially singletons.
@param pluginName Class name for plugin, eg "com.salesforce.com.foo"
@return Singleton instance of the named plugin
*/
- (id) getCommandInstance:(NSString*)pluginName;
- (void) javascriptAlert:(NSString*)text;
- (BOOL) execute:(InvokedUrlCommand*)command;
- (NSString*) appURLScheme;
- (NSDictionary*) deviceProperties;


#pragma mark - Embedded UIWebView management

/**
Tear down the existing web view.
@see reinitializeWebView
*/
- (void)teardownWebView;

/**
(re)Initialize the embedded web view.
@see teardownWebView
*/
- (void)reinitializeWebView;


/**
Configure the web view from self.settings.
@param aWebView The web view to configure;
*/
- (void)configureWebViewFromSettings:(UIWebView*)aWebView;


#pragma mark - Application state transitions
- (void)applicationDidEnterBackground:(UIApplication *)application;
- (void)applicationWillEnterForeground:(UIApplication *)application;
- (void)applicationWillResignActive:(UIApplication *)application;
- (void)applicationWillTerminate:(UIApplication *)application;


#pragma mark - Public


/**
Force a javascript alert to be shown in the embedded UIWebView
@param text Message to be shown in the web view in a javascript alert.
*/
- (void) javascriptAlert:(NSString*)text;




@end



@interface NSDictionary (LowercaseKeys)

- (NSDictionary*) dictionaryWithLowercaseKeys;
Expand Down
Loading

0 comments on commit 1c3a5b3

Please sign in to comment.