forked from hongrich/Dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First public release of Dashboard for iPad
- Loading branch information
Showing
517 changed files
with
35,484 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// DashboardAppDelegate.h | ||
// Dashboard | ||
// | ||
// Copyright (c) 2010 Rich Hong | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class DashboardViewController; | ||
|
||
@interface DashboardAppDelegate : NSObject <UIApplicationDelegate> { | ||
UIWindow *window; | ||
DashboardViewController *viewController; | ||
} | ||
|
||
@property (nonatomic, retain) IBOutlet UIWindow *window; | ||
@property (nonatomic, retain) IBOutlet DashboardViewController *viewController; | ||
|
||
+ (NSString*)widgetPath; | ||
+ (NSString*)widgetResourcesPath; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// | ||
// DashboardAppDelegate.m | ||
// Dashboard | ||
// | ||
// Copyright (c) 2010 Rich Hong | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
#import "DashboardAppDelegate.h" | ||
#import "DashboardViewController.h" | ||
#import "DashboardWidget.h" | ||
|
||
static NSString *_widgetPath = nil; | ||
static NSString *_widgetResourcesPath = nil; | ||
|
||
@implementation DashboardAppDelegate | ||
|
||
@synthesize window; | ||
@synthesize viewController; | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); | ||
_widgetResourcesPath = [[[paths objectAtIndex:0] stringByAppendingPathComponent:@"WidgetResources"] retain]; | ||
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | ||
_widgetPath = [[paths objectAtIndex:0] retain]; | ||
|
||
// Override point for customization after app launch | ||
[window addSubview:viewController.view]; | ||
[window makeKeyAndVisible]; | ||
|
||
// Load dictionary of webViews back if there are any previously stored ones | ||
// Try / Catch for good luck | ||
@try { | ||
NSData *data; | ||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"doneWithDefaultWidgets"] == NO) { | ||
// Open default widgets | ||
data = [NSData dataWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"firstRun"]]; | ||
}else { | ||
// Load from NSUserDefaults | ||
data = [[NSUserDefaults standardUserDefaults] objectForKey:@"widgets"]; | ||
} | ||
|
||
if (data) { | ||
NSArray *widgets = [NSKeyedUnarchiver unarchiveObjectWithData:data]; | ||
for (DashboardWidget *widget in widgets) { | ||
if ([widget isKindOfClass:[DashboardWidget class]]) { | ||
// If this is a default widget, we have to fix some paths, re-initialize and hide closeButton | ||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"doneWithDefaultWidgets"] == NO) { | ||
widget.path = [[DashboardAppDelegate widgetPath] stringByAppendingPathComponent:[widget.path lastPathComponent]]; | ||
[widget initialize]; | ||
widget.closeButton.hidden = YES; | ||
} | ||
|
||
[self.viewController.containerView addSubview:widget]; | ||
} | ||
} | ||
} | ||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"doneWithDefaultWidgets"] == NO) { | ||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"doneWithDefaultWidgets"]; | ||
} | ||
} | ||
@catch (NSException * e) { | ||
NSLog(@"%@", e); | ||
} | ||
|
||
return YES; | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application { | ||
[[NSUserDefaults standardUserDefaults] setObject:self.viewController.widgetsView.paths forKey:@"widgetPaths"]; | ||
[[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:[self.viewController.containerView subviews]] forKey:@"widgets"]; | ||
|
||
/* | ||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[self.viewController.containerView subviews]]; | ||
[data writeToFile:@"/Users/rich/iPhone/Dashboard/firstRun" atomically:NO]; | ||
*/ | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application { | ||
[self.viewController.widgetsView reloadWidgets]; | ||
} | ||
|
||
- (void)dealloc { | ||
[_widgetPath release]; | ||
[_widgetResourcesPath release]; | ||
[viewController release]; | ||
[window release]; | ||
[super dealloc]; | ||
} | ||
|
||
+ (NSString*)widgetPath { | ||
return _widgetPath; | ||
} | ||
|
||
+ (NSString*)widgetResourcesPath { | ||
return _widgetResourcesPath; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// DashboardDownalodViewController.h | ||
// Dashboard | ||
// | ||
// Copyright (c) 2010 Rich Hong | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <QuartzCore/QuartzCore.h> | ||
#import "DashboardViewController.h" | ||
#import "DashboardWidgetsView.h" | ||
|
||
@interface DashboardDownalodViewController : UIViewController<UIWebViewDelegate> { | ||
UIWebView *webView; | ||
} | ||
|
||
- (IBAction)cancel; | ||
|
||
@property (nonatomic, retain) IBOutlet UIWebView *webView; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// | ||
// DashboardDownalodViewController.m | ||
// Dashboard | ||
// | ||
// Copyright (c) 2010 Rich Hong | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
#import "DashboardDownalodViewController.h" | ||
|
||
@implementation DashboardDownalodViewController | ||
|
||
@synthesize webView; | ||
|
||
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. | ||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { | ||
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { | ||
// Custom initialization | ||
} | ||
return self; | ||
} | ||
|
||
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. | ||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
NSURLRequest *URLReq = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/downloads/dashboard/categories.html"]]; | ||
[self.webView loadRequest:URLReq]; | ||
} | ||
|
||
|
||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | ||
// Overriden to allow any orientation. | ||
return YES; | ||
} | ||
|
||
|
||
- (void)didReceiveMemoryWarning { | ||
// Releases the view if it doesn't have a superview. | ||
[super didReceiveMemoryWarning]; | ||
|
||
// Release any cached data, images, etc that aren't in use. | ||
} | ||
|
||
|
||
- (void)viewDidUnload { | ||
[super viewDidUnload]; | ||
// Release any retained subviews of the main view. | ||
// e.g. self.myOutlet = nil; | ||
} | ||
|
||
|
||
- (void)dealloc { | ||
self.webView = nil; | ||
[super dealloc]; | ||
} | ||
|
||
# pragma mark - | ||
# pragma mark IBAction | ||
|
||
- (IBAction)cancel { | ||
[[self parentViewController] dismissModalViewControllerAnimated:YES]; | ||
} | ||
|
||
# pragma mark - | ||
# pragma mark UIWebViewDelegate | ||
|
||
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | ||
if ([[[request URL] path] hasSuffix:@".zip"] || [[[request URL] path] hasSuffix:@".widget"]) { | ||
if ([[self parentViewController] isKindOfClass:[DashboardViewController class]]) { | ||
DashboardViewController *viewController = (DashboardViewController*)[self parentViewController]; | ||
[viewController.widgetsView addItem:request]; | ||
} | ||
|
||
[[self parentViewController] dismissModalViewControllerAnimated:YES]; | ||
|
||
return NO; | ||
} | ||
|
||
return YES; | ||
} | ||
|
||
@end |
Oops, something went wrong.