incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [1/2] git commit: PGViewController - made wwwFolderName and startPage as properties to allow easy customization.
Date Wed, 18 Jan 2012 01:21:04 GMT
Updated Branches:
  refs/heads/master 3ae160d41 -> 7a936fc60


PGViewController - made wwwFolderName and startPage as properties to allow easy customization.


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/7a936fc6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/7a936fc6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/7a936fc6

Branch: refs/heads/master
Commit: 7a936fc600020979606e1b79588b1d5f0c4c3be3
Parents: d68571f
Author: shazron <shazron@gmail.com>
Authored: Tue Jan 17 17:17:58 2012 -0800
Committer: shazron <shazron@gmail.com>
Committed: Tue Jan 17 17:17:58 2012 -0800

----------------------------------------------------------------------
 PhoneGapLib/Classes/PGViewController.h |   16 ++-------
 PhoneGapLib/Classes/PGViewController.m |   43 +++++---------------------
 PhoneGapLib/Classes/Sound.m            |    2 +-
 3 files changed, 14 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/7a936fc6/PhoneGapLib/Classes/PGViewController.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.h b/PhoneGapLib/Classes/PGViewController.h
index 6ffef17..8322656 100644
--- a/PhoneGapLib/Classes/PGViewController.h
+++ b/PhoneGapLib/Classes/PGViewController.h
@@ -43,19 +43,19 @@
 @property (nonatomic, readonly, retain) UIImageView *imageView;
 @property (nonatomic, readwrite, assign) id<PGCommandDelegate> commandDelegate;
 
+@property (nonatomic, readwrite, copy) NSString* wwwFolderName;
+@property (nonatomic, readwrite, copy) NSString* startPage;
+
 + (NSDictionary*) getBundlePlist:(NSString*)plistName;
-+ (NSString*) wwwFolderName;
-+ (NSString*) pathForResource:(NSString*)resourcepath;
 + (NSString*) phoneGapVersion;
 + (NSString*) applicationDocumentsDirectory;
-- (NSString*) startPage;
-
 
 - (void) createGapView;
 
 - (int) executeQueuedCommands;
 - (void) flushCommandQueue;
 
+- (NSString*) pathForResource:(NSString*)resourcepath;
 - (id) getCommandInstance:(NSString*)pluginName;
 - (void) javascriptAlert:(NSString*)text;
 - (BOOL) execute:(InvokedUrlCommand*)command;
@@ -65,11 +65,3 @@
 - (NSArray*) parseInterfaceOrientations:(NSArray*)orientations;
 
 @end
-
-/* Category */
-
-@interface NSDictionary (LowercaseKeys)
-
-- (NSDictionary*) dictionaryWithLowercaseKeys;
-
-@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/7a936fc6/PhoneGapLib/Classes/PGViewController.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.m b/PhoneGapLib/Classes/PGViewController.m
index 4850a7c..96a4e28 100644
--- a/PhoneGapLib/Classes/PGViewController.m
+++ b/PhoneGapLib/Classes/PGViewController.m
@@ -9,6 +9,7 @@
 #import "PGPlugin.h"
 #import "Location.h"
 #import "Connection.h"
+#import "NSDictionary+LowercaseKeys.h"
 
 #define SYMBOL_TO_NSSTRING_HELPER(x) @#x
 #define SYMBOL_TO_NSSTRING(x) SYMBOL_TO_NSSTRING_HELPER(x)
@@ -27,7 +28,6 @@
 @property (nonatomic, readwrite, retain) IBOutlet UIActivityIndicatorView* activityView;
 @property (nonatomic, readwrite, retain) UIImageView* imageView;
 
-
 @end
 
 
@@ -37,6 +37,7 @@
 @synthesize pluginObjects, pluginsMap, whitelist;
 @synthesize settings, sessionKey, loadFromString;
 @synthesize imageView, activityView, useSplashScreen, commandDelegate;
+@synthesize wwwFolderName, startPage;
 
 - (id) init
 {
@@ -45,6 +46,8 @@
         [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedOrientationChange)
name:UIDeviceOrientationDidChangeNotification
                                                    object:nil];
+        self.wwwFolderName = @"www";
+        self.startPage = @"index.html";
     }
     return self; 
 }
@@ -88,12 +91,12 @@
     
     ///////////////////
     
-	NSString* startFilePath = [[self class] pathForResource:[self startPage]];
+	NSString* startFilePath = [self pathForResource:self.startPage];
 	NSURL* appURL  = nil;
     NSString* loadErr = nil;
     
     if (startFilePath == nil) {
-        loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.",
[[self class] wwwFolderName], [self startPage]];
+        loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.",
self.wwwFolderName, self.startPage];
         NSLog(@"%@", loadErr);
         self.loadFromString = YES;
         appURL = nil;
@@ -412,16 +415,6 @@
     [webView stringByEvaluatingJavaScriptFromString:jsString];
 }
 
-+ (NSString*) wwwFolderName
-{
-    return @"www";
-}
-
-- (NSString*) startPage
-{
-    return @"index.html";
-}
-
 + (BOOL) isIPad 
 {
 #ifdef UI_USER_INTERFACE_IDIOM
@@ -449,7 +442,7 @@
     return resource;
 }
 
-+ (NSString*) pathForResource:(NSString*)resourcepath
+- (NSString*) pathForResource:(NSString*)resourcepath
 {
     NSBundle * mainBundle = [NSBundle mainBundle];
     NSMutableArray *directoryParts = [NSMutableArray arrayWithArray:[resourcepath componentsSeparatedByString:@"/"]];
@@ -457,10 +450,10 @@
     [directoryParts removeLastObject];
     
     NSString* directoryPartsJoined =[directoryParts componentsJoinedByString:@"/"];
-    NSString* directoryStr = [self wwwFolderName];
+    NSString* directoryStr = self.wwwFolderName;
     
     if ([directoryPartsJoined length] > 0) {
-        directoryStr = [NSString stringWithFormat:@"%@/%@", [self wwwFolderName], [directoryParts
componentsJoinedByString:@"/"]];
+        directoryStr = [NSString stringWithFormat:@"%@/%@", self.wwwFolderName, [directoryParts
componentsJoinedByString:@"/"]];
     }
     
     return [mainBundle pathForResource:filename ofType:@"" inDirectory:directoryStr];
@@ -809,21 +802,3 @@ static NSString *gapVersion;
 }
 
 @end
-
-#pragma mark -
-
-@implementation NSDictionary (LowercaseKeys)
-
-- (NSDictionary*) dictionaryWithLowercaseKeys 
-{
-    NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:self.count];
-    NSString* key;
-    
-    for (key in self) {
-        [result setObject:[self objectForKey:key] forKey:[key lowercaseString]];
-    }
-    
-    return result;
-}
-
-@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/7a936fc6/PhoneGapLib/Classes/Sound.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Sound.m b/PhoneGapLib/Classes/Sound.m
index d3f54c2..ee4a5c6 100644
--- a/PhoneGapLib/Classes/Sound.m
+++ b/PhoneGapLib/Classes/Sound.m
@@ -35,7 +35,7 @@
        NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath,
filePath);
     } else {
         // attempt to find file path in www directory
-        filePath = [PGViewController pathForResource:resourcePath];
+        filePath = [(PGViewController*)self.viewController pathForResource:resourcePath];
         if (filePath != nil) {
             NSLog(@"Found resource '%@' in the web folder.", filePath);
         }else {


Mime
View raw message