Permalink
Browse files

Merge branch 'master' of git@github.com:phonegap/phonegap

  • Loading branch information...
2 parents 46078a4 + 30ff752 commit e51198748d61017de466ca19622ed7cf87412368 @filmaj filmaj committed Dec 1, 2009
@@ -98,7 +98,7 @@
1D3623250D0F684500981E51 /* ___PROJECTNAMEASIDENTIFIER___AppDelegate.m */,
);
path = Classes;
- sourceTree = "<group>";
+ sourceTree = SOURCE_ROOT;
};
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
@@ -114,6 +114,7 @@
301BF56E109A69640062928A /* www */,
301BF52D109A57CC0062928A /* PhoneGapLib.xcodeproj */,
080E96DDFE201D6D7F000001 /* Classes */,
+ 307C750510C5A3420062BCA9 /* Plugins */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
29B97317FDCFA39411CA2CEA /* Resources */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
@@ -167,6 +168,13 @@
name = Products;
sourceTree = "<group>";
};
+ 307C750510C5A3420062BCA9 /* Plugins */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ path = Plugins;
+ sourceTree = SOURCE_ROOT;
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -195,23 +195,9 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
When web application loads Add stuff to the DOM, mainly the user-defined settings from the Settings.plist file, and
the device's data such as device ID, platform version, etc.
*/
-- (void)webViewDidStartLoad:(UIWebView *)theWebView {
- NSDictionary *deviceProperties = [[self getCommandInstance:@"Device"] deviceProperties];
- NSMutableString *result = [[NSMutableString alloc] initWithFormat:@"DeviceInfo = %@;", [deviceProperties JSONFragment]];
-
- /* Settings.plist
- * Read the optional Settings.plist file and push these user-defined settings down into the web application.
- * This can be useful for supplying build-time configuration variables down to the app to change its behaviour,
- * such as specifying Full / Lite version, or localization (English vs German, for instance).
- */
- NSDictionary *temp = [PhoneGapDelegate getBundlePlist:@"Settings"];
- if ([temp respondsToSelector:@selector(JSONFragment)]) {
- [result appendFormat:@"\nwindow.Settings = %@;", [temp JSONFragment]];
- }
+- (void)webViewDidStartLoad:(UIWebView *)theWebView
+{
- NSLog(@"Device initialization: %@", result);
- [theWebView stringByEvaluatingJavaScriptFromString:result];
- [result release];
// Play any default movie
if(![[[UIDevice currentDevice] model] isEqualToString:@"iPhone Simulator"]) {
@@ -303,6 +289,25 @@ - (void)webViewDidFinishLoad:(UIWebView *)theWebView {
/*
* Hide the Top Activity THROBER in the Battery Bar
*/
+
+ NSDictionary *deviceProperties = [[self getCommandInstance:@"Device"] deviceProperties];
+ NSMutableString *result = [[NSMutableString alloc] initWithFormat:@"DeviceInfo = %@;", [deviceProperties JSONFragment]];
+
+ /* Settings.plist
+ * Read the optional Settings.plist file and push these user-defined settings down into the web application.
+ * This can be useful for supplying build-time configuration variables down to the app to change its behaviour,
+ * such as specifying Full / Lite version, or localization (English vs German, for instance).
+ */
+
+ NSDictionary *temp = [PhoneGapDelegate getBundlePlist:@"Settings"];
+ if ([temp respondsToSelector:@selector(JSONFragment)]) {
+ [result appendFormat:@"\nwindow.Settings = %@;", [temp JSONFragment]];
+ }
+
+ NSLog(@"Device initialization: %@", result);
+ [theWebView stringByEvaluatingJavaScriptFromString:result];
+ [result release];
+
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
activityView.hidden = YES;
@@ -3,31 +3,27 @@
* phone, etc.
* @constructor
*/
-function Device() {
- this.available = PhoneGap.available;
+function Device()
+{
this.platform = null;
this.version = null;
this.name = null;
this.gap = null;
this.uuid = null;
- try {
- if (window.DroidGap) {
- this.available = true;
- this.uuid = window.DroidGap.getUuid();
- this.version = window.DroidGap.getOSVersion();
- this.gapVersion = window.DroidGap.getVersion();
- this.platform = window.DroidGap.getPlatform();
- this.name = window.DroidGap.getProductName();
- } else {
- this.platform = DeviceInfo.platform;
- this.version = DeviceInfo.version;
- this.name = DeviceInfo.name;
- this.gap = DeviceInfo.gap;
- this.uuid = DeviceInfo.uuid;
- }
- } catch(e) {
- this.available = false;
+ try
+ {
+ this.platform = DeviceInfo.platform;
+ this.version = DeviceInfo.version;
+ this.name = DeviceInfo.name;
+ this.gap = DeviceInfo.gap;
+ this.uuid = DeviceInfo.uuid;
+
+ }
+ catch(e)
+ {
+ // TODO:
}
+ this.available = PhoneGap.available = this.uuid != null;
}
PhoneGap.addConstructor(function() {
@@ -17,7 +17,7 @@ PhoneGap = {
/**
* Boolean flag indicating if the PhoneGap API is available and initialized.
- */
+ */ // TODO: Remove this, it is unused here ... -jm
PhoneGap.available = DeviceInfo.uuid != undefined;
/**
@@ -27,28 +27,51 @@ PhoneGap.available = DeviceInfo.uuid != undefined;
*/
PhoneGap.addConstructor = function(func) {
var state = document.readyState;
- if (state != 'loaded' && state != 'complete')
- PhoneGap._constructors.push(func);
+ if ( ( state == 'loaded' || state == 'complete' ) && DeviceInfo.uuid != null )
+ {
+ func();
+ }
else
- func();
+ {
+ PhoneGap._constructors.push(func);
+ }
};
-(function() {
- var timer = setInterval(function() {
- var state = document.readyState;
- if (state != 'loaded' && state != 'complete')
- return;
- clearInterval(timer);
- while (PhoneGap._constructors.length > 0) {
- var constructor = PhoneGap._constructors.shift();
- try {
- constructor();
- } catch(e) {
- if (typeof(debug['log']) == 'function')
- debug.log("Failed to run constructor: " + debug.processMessage(e));
- else
- alert("Failed to run constructor: " + e.message);
+
+(function()
+ {
+ var timer = setInterval(function()
+ {
+
+ var state = document.readyState;
+
+ if ( ( state == 'loaded' || state == 'complete' ) && DeviceInfo.uuid != null )
+ {
+ clearInterval(timer); // stop looking
+ // run our constructors list
+ while (PhoneGap._constructors.length > 0)
+ {
+ var constructor = PhoneGap._constructors.shift();
+ try
+ {
+ constructor();
+ }
+ catch(e)
+ {
+ if (typeof(debug['log']) == 'function')
+ {
+ debug.log("Failed to run constructor: " + debug.processMessage(e));
+ }
+ else
+ {
+ alert("Failed to run constructor: " + e.message);
+ }
+ }
}
- }
+ // all constructors run, now fire the deviceready event
+ var e = document.createEvent('Events');
+ e.initEvent('deviceready');
+ document.dispatchEvent(e);
+ }
}, 1);
})();

0 comments on commit e511987

Please sign in to comment.