diff --git a/myLauncher/Classes/AppDelegate.h b/myLauncher/Classes/AppDelegate.h index ae3b870..4434024 100644 --- a/myLauncher/Classes/AppDelegate.h +++ b/myLauncher/Classes/AppDelegate.h @@ -28,8 +28,8 @@ UINavigationController *navigationController; } -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) UINavigationController *navigationController; +@property (nonatomic, strong) UIWindow *window; +@property (nonatomic, strong) UINavigationController *navigationController; @end diff --git a/myLauncher/Classes/AppDelegate.m b/myLauncher/Classes/AppDelegate.m index 0e8d075..3ea70e4 100644 --- a/myLauncher/Classes/AppDelegate.m +++ b/myLauncher/Classes/AppDelegate.m @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,9 +38,9 @@ - (void)applicationDidFinishLaunching:(UIApplication*)application [[RootViewController alloc] init]]; navigationController.navigationBar.tintColor = COLOR(2, 100, 162); - [window addSubview:navigationController.view]; + [window setRootViewController:navigationController]; [window makeKeyAndVisible]; - [window layoutSubviews]; + } @end \ No newline at end of file diff --git a/myLauncher/Classes/MyLauncher/CustomBadge.m b/myLauncher/Classes/MyLauncher/CustomBadge.m index 6771b17..7b8f240 100644 --- a/myLauncher/Classes/MyLauncher/CustomBadge.m +++ b/myLauncher/Classes/MyLauncher/CustomBadge.m @@ -111,10 +111,6 @@ + (CustomBadge*) customBadgeWithString:(NSString *)badgeString withStringColor:( return [[self alloc] initWithString:badgeString withStringColor:stringColor withInsetColor:insetColor withBadgeFrame:badgeFrameYesNo withBadgeFrameColor:frameColor withScale:scale withShining:shining]; } - - - - // Draws the Badge with Quartz -(void) drawRoundedRectWithContext:(CGContextRef)context withRect:(CGRect)rect { @@ -211,7 +207,6 @@ -(void) drawFrameWithContext:(CGContextRef)context withRect:(CGRect)rect CGContextStrokePath(context); } - - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); diff --git a/myLauncher/Classes/MyLauncher/MyLauncherGenericItem.h b/myLauncher/Classes/MyLauncher/MyLauncherGenericItem.h new file mode 100644 index 0000000..8dfb536 --- /dev/null +++ b/myLauncher/Classes/MyLauncher/MyLauncherGenericItem.h @@ -0,0 +1,28 @@ +// +// MyLauncherGenericItem.h +// +// Copyright 2012 Nicolas Desjardins +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "MyLauncherItem.h" +#import "MyLauncherGenericItemDelegate.h" + +@interface MyLauncherGenericItem : MyLauncherItem + +@property (nonatomic, strong) id genericDelegate; + +-(id)initWithTitle:(NSString*)title delegate:(id)genericDelegate deletable:(BOOL)deletable; + +@end diff --git a/myLauncher/Classes/MyLauncher/MyLauncherGenericItem.m b/myLauncher/Classes/MyLauncher/MyLauncherGenericItem.m new file mode 100644 index 0000000..7a31854 --- /dev/null +++ b/myLauncher/Classes/MyLauncher/MyLauncherGenericItem.m @@ -0,0 +1,53 @@ +// +// MyLauncherGenericItem.h +// +// Copyright 2012 Nicolas Desjardins +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "MyLauncherGenericItem.h" + +@implementation MyLauncherGenericItem + +@synthesize genericDelegate = _genericDelegate; + + +-(id)initWithTitle:(NSString*)title delegate:(id)genericDelegate deletable:(BOOL)deletable { + if((self = [super initWithTitle:title deletable:deletable])) + { + _genericDelegate = genericDelegate; + } + return self; +} + +-(void)selected:(MyLauncherViewController*)parent { + [_genericDelegate start]; +} + +-(UIImage*)icon { + return [_genericDelegate icon]; +} + +-(NSMutableDictionary*)itemToSave { + NSMutableDictionary *itemToSave = [super itemToSave]; + + NSData *data = [NSKeyedArchiver archivedDataWithRootObject:_genericDelegate]; + [itemToSave setObject:data forKey:@"genericDelegate"]; + + return itemToSave; +} + + + +@end diff --git a/myLauncher/Classes/MyLauncher/MyLauncherGenericItemDelegate.h b/myLauncher/Classes/MyLauncher/MyLauncherGenericItemDelegate.h new file mode 100644 index 0000000..fc1d4ae --- /dev/null +++ b/myLauncher/Classes/MyLauncher/MyLauncherGenericItemDelegate.h @@ -0,0 +1,18 @@ +// +// MyLauncherGenericItemDelegate.h +// MyLauncher +// +// Created by Nicolas Desjardins on 2012-07-04. +// +// + +#import + +@protocol MyLauncherGenericItemDelegate + +-(void)start; +-(UIImage*)icon; +-(int)itemId; +-(int)version; + +@end diff --git a/myLauncher/Classes/MyLauncher/MyLauncherItem.h b/myLauncher/Classes/MyLauncher/MyLauncherItem.h index 1cd406d..bc1c07d 100644 --- a/myLauncher/Classes/MyLauncher/MyLauncherItem.h +++ b/myLauncher/Classes/MyLauncher/MyLauncherItem.h @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,31 +19,33 @@ // limitations under the License. // -#import +#import +#import "CustomBadge.h" -@class CustomBadge; +@class MyLauncherViewController; @protocol MyLauncherItemDelegate -(void)didDeleteItem:(id)item; @end @interface MyLauncherItem : UIControl { - BOOL dragging; - BOOL deletable; - BOOL titleBoundToBottom; + BOOL _dragging; + BOOL _titleBoundToBottom; } -@property (nonatomic, assign) id delegate; -@property (nonatomic, retain) NSString *title; -@property (nonatomic, retain) NSString *image; -@property (nonatomic, retain) NSString *iPadImage; -@property (nonatomic, retain) NSString *controllerStr; -@property (nonatomic, retain) NSString *controllerTitle; -@property (nonatomic, retain) UIButton *closeButton; -@property (nonatomic, retain) CustomBadge *badge; - --(id)initWithTitle:(NSString *)title image:(NSString *)image target:(NSString *)targetControllerStr deletable:(BOOL)_deletable; --(id)initWithTitle:(NSString *)title iPhoneImage:(NSString *)image iPadImage:(NSString *)iPadImage target:(NSString *)targetControllerStr targetTitle:(NSString *)targetTitle deletable:(BOOL)_deletable; +@property (nonatomic, strong) NSString *title; +@property (nonatomic, unsafe_unretained) id delegate; +@property (nonatomic, strong) CustomBadge *badge; +@property (nonatomic, strong) UIButton *closeButton; +@property (nonatomic) BOOL deletable; + + +-(id)initWithTitle:(NSString*)title deletable:(BOOL)deletable; + +-(NSMutableDictionary*)itemToSave; + +-(void)selected:(MyLauncherViewController*)parent; + -(void)layoutItem; -(void)setDragging:(BOOL)flag; -(BOOL)dragging; diff --git a/myLauncher/Classes/MyLauncher/MyLauncherItem.m b/myLauncher/Classes/MyLauncher/MyLauncherItem.m index 5f4b624..93c3624 100644 --- a/myLauncher/Classes/MyLauncher/MyLauncherItem.m +++ b/myLauncher/Classes/MyLauncher/MyLauncherItem.m @@ -1,9 +1,10 @@ // -// MyLauncherItem.m +// MyLauncherItem.h // @rigoneri -// +// // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,65 +20,47 @@ // #import "MyLauncherItem.h" -#import "CustomBadge.h" @implementation MyLauncherItem -@synthesize delegate = _delegate; @synthesize title = _title; -@synthesize image = _image; -@synthesize iPadImage = _iPadImage; -@synthesize closeButton = _closeButton; -@synthesize controllerStr = _controllerStr; -@synthesize controllerTitle = _controllerTitle; +@synthesize delegate = _delegate; @synthesize badge = _badge; +@synthesize closeButton = _closeButton; -#pragma mark - Lifecycle - --(id)initWithTitle:(NSString *)title image:(NSString *)image target:(NSString *)targetControllerStr deletable:(BOOL)_deletable { - return [self initWithTitle:title - iPhoneImage:image - iPadImage:image - target:targetControllerStr - targetTitle:title - deletable:_deletable]; -} - --(id)initWithTitle:(NSString *)title iPhoneImage:(NSString *)image iPadImage:(NSString *)iPadImage target:(NSString *)targetControllerStr targetTitle:(NSString *)targetTitle deletable:(BOOL)_deletable { - +-(id)initWithTitle:(NSString*)title deletable:(BOOL)deletable { if((self = [super init])) { - dragging = NO; - deletable = _deletable; - - [self setTitle:title]; - [self setImage:image]; - [self setIPadImage:iPadImage]; - [self setControllerStr:targetControllerStr]; - [self setControllerTitle:targetTitle]; - + _dragging = NO; + _deletable = deletable; + _title = title; + [self setCloseButton:[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]]; self.closeButton.hidden = YES; } return self; } -#pragma mark - Layout +-(void)selected:(MyLauncherViewController*)parent {} + +-(NSMutableDictionary*)itemToSave { + NSMutableDictionary *itemToSave = [[NSMutableDictionary alloc] init]; + [itemToSave setObject:self.title forKey:@"title"]; + [itemToSave setObject:[NSString stringWithFormat:@"%d", _deletable] forKey:@"deletable"]; + [itemToSave setObject:[NSNumber numberWithInt:3] forKey:@"myLauncherViewItemVersion"]; + + return itemToSave; +} -(void)layoutItem { - if(!self.image) + UIImage *image = [self icon]; + if(!image) return; for(id subview in [self subviews]) [subview removeFromSuperview]; - UIImage *image = nil; - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [self iPadImage]) { - image = [UIImage imageNamed:self.iPadImage]; - } else { - image = [UIImage imageNamed:self.image]; - } UIImageView *itemImage = [[UIImageView alloc] initWithImage:image]; CGFloat itemImageX = (self.bounds.size.width/2) - (itemImage.bounds.size.width/2); @@ -85,14 +68,14 @@ -(void)layoutItem itemImage.frame = CGRectMake(itemImageX, itemImageY, itemImage.bounds.size.width, itemImage.bounds.size.height); [self addSubview:itemImage]; CGFloat itemImageWidth = itemImage.bounds.size.width; - + if(self.badge) { self.badge.frame = CGRectMake((itemImageX + itemImageWidth) - (self.badge.bounds.size.width - 6), itemImageY-6, self.badge.bounds.size.width, self.badge.bounds.size.height); [self addSubview:self.badge]; } - if(deletable) + if(_deletable) { self.closeButton.frame = CGRectMake(itemImageX-10, itemImageY-10, 30, 30); [self.closeButton setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal]; @@ -104,7 +87,7 @@ -(void)layoutItem CGFloat itemLabelY = itemImageY + itemImage.bounds.size.height; CGFloat itemLabelHeight = self.bounds.size.height - itemLabelY; - if (titleBoundToBottom) + if (_titleBoundToBottom) { itemLabelHeight = 34; itemLabelY = (self.bounds.size.height + 6) - itemLabelHeight; @@ -121,7 +104,9 @@ -(void)layoutItem [self addSubview:itemLabel]; } -#pragma mark - Touch +-(UIImage*)icon { + return nil; +} -(void)closeItem:(id)sender { @@ -164,16 +149,16 @@ -(void)setFrame:(CGRect)frame -(void)setDragging:(BOOL)flag { - if(dragging == flag) + if(_dragging == flag) return; - dragging = flag; + _dragging = flag; [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ - if(dragging) { + if(_dragging) { self.transform = CGAffineTransformMakeScale(1.4, 1.4); self.alpha = 0.7; } @@ -187,27 +172,27 @@ -(void)setDragging:(BOOL)flag -(BOOL)dragging { - return dragging; + return _dragging; } -(BOOL)deletable { - return deletable; + return _deletable; } -(BOOL)titleBoundToBottom { - return titleBoundToBottom; + return _titleBoundToBottom; } -(void)setTitleBoundToBottom:(BOOL)bind { - titleBoundToBottom = bind; + _titleBoundToBottom = bind; [self layoutItem]; } -(NSString *)badgeText { - return self.badge.badgeText; + return _badge.badgeText; } -(void)setBadgeText:(NSString *)text { @@ -224,4 +209,6 @@ -(void)setCustomBadge:(CustomBadge *)customBadge { [self layoutItem]; } + + @end diff --git a/myLauncher/Classes/MyLauncher/MyLauncherView.h b/myLauncher/Classes/MyLauncher/MyLauncherView.h index 1c5b99a..bbb575c 100644 --- a/myLauncher/Classes/MyLauncher/MyLauncherView.h +++ b/myLauncher/Classes/MyLauncher/MyLauncherView.h @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -66,5 +67,6 @@ -(void)layoutLauncherAnimated:(BOOL)animated; -(int)maxItemsPerPage; -(int)maxPages; +-(void)saveChanges; @end diff --git a/myLauncher/Classes/MyLauncher/MyLauncherView.m b/myLauncher/Classes/MyLauncher/MyLauncherView.m index 161d3c0..ddc7cc1 100644 --- a/myLauncher/Classes/MyLauncher/MyLauncherView.m +++ b/myLauncher/Classes/MyLauncher/MyLauncherView.m @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,6 +21,7 @@ #import "MyLauncherView.h" + struct NItemLocation { NSInteger page; NSInteger sindex; @@ -82,9 +84,9 @@ -(BOOL)itemMovable:(MyLauncherItem *)itemToSearch; -(void)savePages; -(void)saveToUserDefaults:(id)object key:(NSString *)key; -(UIDeviceOrientation)currentLayoutOrientation; -@property (nonatomic, retain) NSTimer *itemHoldTimer; -@property (nonatomic, retain) NSTimer *movePagesTimer; -@property (nonatomic, retain) MyLauncherItem *draggingItem; +@property (nonatomic, strong) NSTimer *itemHoldTimer; +@property (nonatomic, strong) NSTimer *movePagesTimer; +@property (nonatomic, strong) MyLauncherItem *draggingItem; @end @implementation MyLauncherView @@ -435,7 +437,7 @@ -(void)itemTouchedDown:(MyLauncherItem *)item { if (!self.draggingItem && [self itemMovable:item]) { - self.draggingItem = (MyLauncherItem*)item; + self.draggingItem = (MyLauncherItem*)item; [self.draggingItem setDragging:YES]; [self.pagesScrollView addSubview:self.draggingItem]; dragging = YES; @@ -677,7 +679,7 @@ -(void)endEditing } else { - for (MyLauncherItem* item in itemPage) + for (MyLauncherItem* item in itemPage) item.transform = CGAffineTransformIdentity; } } @@ -706,7 +708,7 @@ -(void)animateItems NSInteger animatingItems = 0; for (NSArray* itemPage in self.pages) { - for (MyLauncherItem* item in itemPage) + for (MyLauncherItem* item in itemPage) { item.closeButton.hidden = !editing; if (item != self.draggingItem && [self itemMovable:item]) @@ -787,6 +789,9 @@ -(BOOL)itemMovable:(MyLauncherItem *)itemToSearch } #pragma mark - myLauncher caching +-(void)saveChanges { + [self savePages]; +} -(void)savePages { @@ -798,16 +803,10 @@ -(void)savePages for(MyLauncherItem *item in page) { - NSMutableDictionary *itemToSave = [[NSMutableDictionary alloc] init]; - [itemToSave setObject:item.title forKey:@"title"]; - [itemToSave setObject:item.image forKey:@"image"]; - [itemToSave setObject:item.iPadImage forKey:@"iPadImage"]; - [itemToSave setObject:[NSString stringWithFormat:@"%d", [item deletable]] forKey:@"deletable"]; - [itemToSave setObject:item.controllerStr forKey:@"controller"]; - [itemToSave setObject:item.controllerTitle forKey:@"controllerTitle"]; - [itemToSave setObject:[NSNumber numberWithInt:2] forKey:@"myLauncherViewItemVersion"]; - - [pageToSave addObject:itemToSave]; + NSDictionary *itemToSave = [item itemToSave]; + if (itemToSave) { + [pageToSave addObject:itemToSave]; + } } [pagesToSave addObject:pageToSave]; } diff --git a/myLauncher/Classes/MyLauncher/MyLauncherViewController.h b/myLauncher/Classes/MyLauncher/MyLauncherViewController.h index d523d6b..27453ac 100644 --- a/myLauncher/Classes/MyLauncher/MyLauncherViewController.h +++ b/myLauncher/Classes/MyLauncher/MyLauncherViewController.h @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ #import #import "MyLauncherView.h" -#import "MyLauncherItem.h" +#import "MyLauncherViewControllerItem.h" @interface MyLauncherViewController : UIViewController { } @@ -32,7 +33,10 @@ -(BOOL)hasSavedLauncherItems; -(void)clearSavedLauncherItems; --(void)launcherViewItemSelected:(MyLauncherItem*)item; +-(void)launcherViewItemSelected:(MyLauncherView*)item; -(void)closeView; +-(void)launchSelectedItemViewController:(UIViewController*)itemViewController withTopTitle:(NSString*)title; + + @end diff --git a/myLauncher/Classes/MyLauncher/MyLauncherViewController.m b/myLauncher/Classes/MyLauncher/MyLauncherViewController.m index 6b1d649..539ba58 100644 --- a/myLauncher/Classes/MyLauncher/MyLauncherViewController.m +++ b/myLauncher/Classes/MyLauncher/MyLauncherViewController.m @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,6 +20,8 @@ // #import "MyLauncherViewController.h" +#import "MyLauncherItem.h" +#import "MyLauncherGenericItem.h" @interface MyLauncherViewController () -(NSMutableArray *)savedLauncherItems; @@ -120,14 +123,16 @@ -(BOOL)hasSavedLauncherItems { } -(void)launcherViewItemSelected:(MyLauncherItem*)item { + [item selected:self]; +} + +-(void)launchSelectedItemViewController:(UIViewController*)itemViewController withTopTitle:(NSString*)title { if (![self appControllers] || [self launcherNavigationController]) { return; } - Class viewCtrClass = [[self appControllers] objectForKey:[item controllerStr]]; - UIViewController *controller = [[viewCtrClass alloc] init]; - [self setLauncherNavigationController:[[UINavigationController alloc] initWithRootViewController:controller]]; - [[self.launcherNavigationController topViewController] setTitle:item.controllerTitle]; + [self setLauncherNavigationController:[[UINavigationController alloc] initWithRootViewController:itemViewController]]; + [[self.launcherNavigationController topViewController] setTitle:title]; [self.launcherNavigationController setDelegate:self]; if(self.view.frame.size.width == 480) @@ -135,12 +140,12 @@ -(void)launcherViewItemSelected:(MyLauncherItem*)item { if(self.view.frame.size.width == 1024) self.launcherNavigationController.view.frame = CGRectMake(0, 0, 1024, 768); - [controller.navigationItem setLeftBarButtonItem: + [itemViewController.navigationItem setLeftBarButtonItem: [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"launcher"] style:UIBarButtonItemStyleBordered target:self action:@selector(closeView)]]; - + UIView *viewToLaunch = [[self.launcherNavigationController topViewController] view]; [self.parentViewController.view addSubview:[self.launcherNavigationController view]]; @@ -235,6 +240,25 @@ -(void)navigationController:(UINavigationController *)navigationController didSh #pragma mark - myLauncher caching +- (void)processVersion3Item:(NSDictionary *)item savedPage:(NSMutableArray *)savedPage { + BOOL notGeneric = ![item objectForKey:@"genericDelegate"]; + if (notGeneric) { + [savedPage addObject:[[MyLauncherViewControllerItem alloc] + initWithTitle:[item objectForKey:@"title"] + iPhoneImage:[item objectForKey:@"image"] + iPadImage:[item objectForKey:@"iPadImage"] + target:[item objectForKey:@"controller"] + targetTitle:[item objectForKey:@"controllerTitle"] + deletable:[[item objectForKey:@"deletable"] boolValue]]]; + } else { + id delegate = [NSKeyedUnarchiver unarchiveObjectWithData:(NSData*)[item objectForKey:@"genericDelegate"]]; + [savedPage addObject:[[MyLauncherGenericItem alloc] + initWithTitle:[item objectForKey:@"title"] + delegate:delegate + deletable:[[item objectForKey:@"deletable"] boolValue]]]; + } +} + -(NSMutableArray *)savedLauncherItems { NSArray *savedPages = (NSArray *)[self retrieveFromUserDefaults:@"myLauncherView"]; @@ -250,16 +274,18 @@ -(NSMutableArray *)savedLauncherItems { NSNumber *version; if ((version = [item objectForKey:@"myLauncherViewItemVersion"])) { if ([version intValue] == 2) { - [savedPage addObject:[[MyLauncherItem alloc] + [savedPage addObject:[[MyLauncherViewControllerItem alloc] initWithTitle:[item objectForKey:@"title"] iPhoneImage:[item objectForKey:@"image"] iPadImage:[item objectForKey:@"iPadImage"] target:[item objectForKey:@"controller"] targetTitle:[item objectForKey:@"controllerTitle"] deletable:[[item objectForKey:@"deletable"] boolValue]]]; + } else if ([version intValue] == 3) { + [self processVersion3Item:item savedPage:savedPage]; } } else { - [savedPage addObject:[[MyLauncherItem alloc] + [savedPage addObject:[[MyLauncherViewControllerItem alloc] initWithTitle:[item objectForKey:@"title"] image:[item objectForKey:@"image"] target:[item objectForKey:@"controller"] @@ -284,8 +310,13 @@ -(void)clearSavedLauncherItems { -(id)retrieveFromUserDefaults:(NSString *)key { NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; - if (standardUserDefaults) - return [standardUserDefaults objectForKey:key]; + if (standardUserDefaults) { + NSDictionary *dic = [standardUserDefaults objectForKey:key]; + if (dic) { + return dic; + } + + } return nil; } diff --git a/myLauncher/Classes/MyLauncher/MyLauncherViewControllerItem.h b/myLauncher/Classes/MyLauncher/MyLauncherViewControllerItem.h new file mode 100644 index 0000000..956cbc7 --- /dev/null +++ b/myLauncher/Classes/MyLauncher/MyLauncherViewControllerItem.h @@ -0,0 +1,41 @@ +// +// MyLauncherViewControllerItem.h +// @rigoneri +// +// Copyright 2010 Rodrigo Neri +// Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import +#import "MyLauncherItem.h" +#import "MyLauncherViewController.h" + +@interface MyLauncherViewControllerItem : MyLauncherItem + + +@property (nonatomic, strong) NSString *image; +@property (nonatomic, strong) NSString *iPadImage; +@property (nonatomic, strong) NSString *controllerStr; +@property (nonatomic, strong) NSString *controllerTitle; + + + +-(id)initWithTitle:(NSString *)title image:(NSString *)image target:(NSString *)targetControllerStr deletable:(BOOL)_deletable; +-(id)initWithTitle:(NSString *)title iPhoneImage:(NSString *)image iPadImage:(NSString *)iPadImage target:(NSString *)targetControllerStr targetTitle:(NSString *)targetTitle deletable:(BOOL)_deletable; + + + +@end diff --git a/myLauncher/Classes/MyLauncher/MyLauncherViewControllerItem.m b/myLauncher/Classes/MyLauncher/MyLauncherViewControllerItem.m new file mode 100644 index 0000000..a3e3b55 --- /dev/null +++ b/myLauncher/Classes/MyLauncher/MyLauncherViewControllerItem.m @@ -0,0 +1,150 @@ +// +// MyLauncherViewControllerItem.m +// @rigoneri +// +// Copyright 2010 Rodrigo Neri +// Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "MyLauncherViewControllerItem.h" +#import "CustomBadge.h" + +@implementation MyLauncherViewControllerItem + + +@synthesize image = _image; +@synthesize iPadImage = _iPadImage; +@synthesize controllerStr = _controllerStr; +@synthesize controllerTitle = _controllerTitle; +@synthesize deletable = _deletable; + +#pragma mark - Lifecycle + +-(id)initWithTitle:(NSString *)title image:(NSString *)image target:(NSString *)targetControllerStr deletable:(BOOL)deletable { + return [self initWithTitle:title + iPhoneImage:image + iPadImage:image + target:targetControllerStr + targetTitle:title + deletable:deletable]; +} + +-(id)initWithTitle:(NSString *)title iPhoneImage:(NSString *)image iPadImage:(NSString *)iPadImage target:(NSString *)targetControllerStr targetTitle:(NSString *)targetTitle deletable:(BOOL)deletable { + + if((self = [super initWithTitle:title deletable:deletable])) + { + [self setImage:image]; + [self setIPadImage:iPadImage]; + [self setControllerStr:targetControllerStr]; + [self setControllerTitle:targetTitle]; + } + return self; +} + +-(UIImage*)icon { + UIImage *image = nil; + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [self iPadImage]) { + image = [UIImage imageNamed:self.iPadImage]; + } else { + image = [UIImage imageNamed:self.image]; + } + + return image; +} + +-(void)selected:(MyLauncherViewController*)parent { + + Class viewCtrClass = [[parent appControllers] objectForKey:_controllerStr]; + UIViewController *controller = [[viewCtrClass alloc] init]; + + [parent launchSelectedItemViewController:controller withTopTitle:_controllerTitle]; +} + +-(NSMutableDictionary*)itemToSave { + NSMutableDictionary *itemToSave = [super itemToSave]; + + [itemToSave setObject:_image forKey:@"image"]; + [itemToSave setObject:_iPadImage forKey:@"iPadImage"]; + [itemToSave setObject:_controllerStr forKey:@"controller"]; + [itemToSave setObject:_controllerTitle forKey:@"controllerTitle"]; + + return itemToSave; +} + +#pragma mark - Layout + +-(void)layoutItem +{ + if(!self.image) + return; + + for(id subview in [self subviews]) + [subview removeFromSuperview]; + + UIImage *image = nil; + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [self iPadImage]) { + image = [UIImage imageNamed:self.iPadImage]; + } else { + image = [UIImage imageNamed:self.image]; + } + + UIImageView *itemImage = [[UIImageView alloc] initWithImage:image]; + CGFloat itemImageX = (self.bounds.size.width/2) - (itemImage.bounds.size.width/2); + CGFloat itemImageY = (self.bounds.size.height/2) - (itemImage.bounds.size.height/2); + itemImage.frame = CGRectMake(itemImageX, itemImageY, itemImage.bounds.size.width, itemImage.bounds.size.height); + [self addSubview:itemImage]; + CGFloat itemImageWidth = itemImage.bounds.size.width; + + if(self.badge) { + self.badge.frame = CGRectMake((itemImageX + itemImageWidth) - (self.badge.bounds.size.width - 6), + itemImageY-6, self.badge.bounds.size.width, self.badge.bounds.size.height); + [self addSubview:self.badge]; + } + + if(_deletable) + { + self.closeButton.frame = CGRectMake(itemImageX-10, itemImageY-10, 30, 30); + [self.closeButton setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal]; + self.closeButton.backgroundColor = [UIColor clearColor]; + [self.closeButton addTarget:self action:@selector(closeItem:) forControlEvents:UIControlEventTouchUpInside]; + [self addSubview:self.closeButton]; + } + + CGFloat itemLabelY = itemImageY + itemImage.bounds.size.height; + CGFloat itemLabelHeight = self.bounds.size.height - itemLabelY; + + if (_titleBoundToBottom) + { + itemLabelHeight = 34; + itemLabelY = (self.bounds.size.height + 6) - itemLabelHeight; + } + + UILabel *itemLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, itemLabelY, self.bounds.size.width, itemLabelHeight)]; + itemLabel.backgroundColor = [UIColor clearColor]; + itemLabel.font = [UIFont boldSystemFontOfSize:11]; + itemLabel.textColor = COLOR(46, 46, 46); + itemLabel.textAlignment = UITextAlignmentCenter; + itemLabel.lineBreakMode = UILineBreakModeTailTruncation; + itemLabel.text = self.title; + itemLabel.numberOfLines = 2; + [self addSubview:itemLabel]; +} + +#pragma mark - Touch + + + +@end diff --git a/myLauncher/Classes/OpenWebURLItem.h b/myLauncher/Classes/OpenWebURLItem.h new file mode 100644 index 0000000..bf5bc91 --- /dev/null +++ b/myLauncher/Classes/OpenWebURLItem.h @@ -0,0 +1,29 @@ +// +// MyLauncherGenericItem.h +// +// Copyright 2012 Nicolas Desjardins +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import +#import "MyLauncherGenericItem.h" + +@interface OpenWebURLItem : NSObject + +@property(strong, nonatomic) NSString *url; +@property(strong, nonatomic) UIImage *icon; + +-(id) initWithURL:(NSString*)url andIcon:(UIImage*)icon; + +@end diff --git a/myLauncher/Classes/OpenWebURLItem.m b/myLauncher/Classes/OpenWebURLItem.m new file mode 100644 index 0000000..b43a51d --- /dev/null +++ b/myLauncher/Classes/OpenWebURLItem.m @@ -0,0 +1,58 @@ +// +// MyLauncherGenericItem.m +// +// Copyright 2012 Nicolas Desjardins +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "OpenWebURLItem.h" + +@implementation OpenWebURLItem + +@synthesize url = _url; +@synthesize icon = _icon; + +-(id)initWithURL:(NSString*)url andIcon:(UIImage*)icon { + if (self = [super init]) { + _url = url; + _icon = icon; + } + return self; +} + +-(void)start { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_url]]; +} + +-(UIImage*)icon { + return _icon; +} + +- (id)initWithCoder:(NSCoder*)coder { + _url = [coder decodeObjectForKey:@"URL"]; + UIImage *tmpicon = [UIImage imageWithData:[coder decodeObjectForKey:@"icon"]]; + _icon = [UIImage imageWithCGImage:[tmpicon CGImage] scale:[coder decodeFloatForKey:@"scale"] orientation:UIImageOrientationUp]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder*)coder { + [coder encodeObject:_url forKey:@"URL"]; + + NSData *data = UIImagePNGRepresentation(_icon); + [coder encodeObject:data forKey:@"icon"]; + + [coder encodeFloat:[_icon scale] forKey:@"scale"]; +} +@end diff --git a/myLauncher/Classes/RootViewController.h b/myLauncher/Classes/RootViewController.h index 1c79a0c..6681c39 100644 --- a/myLauncher/Classes/RootViewController.h +++ b/myLauncher/Classes/RootViewController.h @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/myLauncher/Classes/RootViewController.m b/myLauncher/Classes/RootViewController.m index b6e97fe..e2cdca2 100644 --- a/myLauncher/Classes/RootViewController.m +++ b/myLauncher/Classes/RootViewController.m @@ -4,6 +4,7 @@ // // Copyright 2010 Rodrigo Neri // Copyright 2011 David Jarrett +// Copyright 2012 Nicolas Desjardins // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +20,9 @@ // #import "RootViewController.h" -#import "MyLauncherItem.h" +#import "MyLauncherViewControllerItem.h" +#import "MyLauncherGenericItem.h" +#import "OpenWebURLItem.h" #import "CustomBadge.h" #import "ItemViewController.h" @@ -39,45 +42,50 @@ -(void)loadView if(![self hasSavedLauncherItems]) { - [self.launcherView setPages:[NSMutableArray arrayWithObjects: + OpenWebURLItem *urlItem = [[OpenWebURLItem alloc] initWithURL:@"http://google.com" andIcon:[UIImage imageNamed:@"Google-icon.png"]]; + + [self.launcherView setPages:[NSMutableArray arrayWithObjects: [NSMutableArray arrayWithObjects: - [[MyLauncherItem alloc] initWithTitle:@"Item 1" - iPhoneImage:@"itemImage" - iPadImage:@"itemImage-iPad" - target:@"ItemViewController" - targetTitle:@"Item 1 View" - deletable:NO], - [[MyLauncherItem alloc] initWithTitle:@"Item 2" + [[MyLauncherGenericItem alloc] initWithTitle:@"google" + delegate:urlItem + deletable:NO], + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 2" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" targetTitle:@"Item 2 View" deletable:NO], - [[MyLauncherItem alloc] initWithTitle:@"Item 3" + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 3" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" targetTitle:@"Item 3 View" deletable:YES], - [[MyLauncherItem alloc] initWithTitle:@"Item 4" + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 4" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" targetTitle:@"Item 4 View" deletable:NO], - [[MyLauncherItem alloc] initWithTitle:@"Item 5" + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 5" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" targetTitle:@"Item 5 View" deletable:YES], - [[MyLauncherItem alloc] initWithTitle:@"Item 6" + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 6" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" targetTitle:@"Item 6 View" deletable:NO], - [[MyLauncherItem alloc] initWithTitle:@"Item 7" + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 7" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" @@ -85,19 +93,21 @@ -(void)loadView deletable:NO], nil], [NSMutableArray arrayWithObjects: - [[MyLauncherItem alloc] initWithTitle:@"Item 8" + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 8" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" targetTitle:@"Item 8 View" deletable:NO], - [[MyLauncherItem alloc] initWithTitle:@"Item 9" + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 9" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" targetTitle:@"Item 9 View" deletable:YES], - [[MyLauncherItem alloc] initWithTitle:@"Item 10" + + [[MyLauncherViewControllerItem alloc] initWithTitle:@"Item 10" iPhoneImage:@"itemImage" iPadImage:@"itemImage-iPad" target:@"ItemViewController" @@ -116,11 +126,11 @@ -(void)loadView } // Set badge text for a MyLauncherItem using it's setBadgeText: method - [(MyLauncherItem *)[[[self.launcherView pages] objectAtIndex:0] objectAtIndex:0] setBadgeText:@"4"]; + [(MyLauncherViewControllerItem *)[[[self.launcherView pages] objectAtIndex:0] objectAtIndex:0] setBadgeText:@"4"]; // Alternatively, you can import CustomBadge.h as above and setCustomBadge: as below. // This will allow you to change colors, set scale, and remove the shine and/or frame. - [(MyLauncherItem *)[[[self.launcherView pages] objectAtIndex:0] objectAtIndex:1] setCustomBadge:[CustomBadge customBadgeWithString:@"2" withStringColor:[UIColor blackColor] withInsetColor:[UIColor whiteColor] withBadgeFrame:YES withBadgeFrameColor:[UIColor blackColor] withScale:0.8 withShining:NO]]; + [(MyLauncherViewControllerItem *)[[[self.launcherView pages] objectAtIndex:0] objectAtIndex:1] setCustomBadge:[CustomBadge customBadgeWithString:@"2" withStringColor:[UIColor blackColor] withInsetColor:[UIColor whiteColor] withBadgeFrame:YES withBadgeFrameColor:[UIColor blackColor] withScale:0.8 withShining:NO]]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation diff --git a/myLauncher/Google-icon-iPad.png b/myLauncher/Google-icon-iPad.png new file mode 100644 index 0000000..1f940f4 Binary files /dev/null and b/myLauncher/Google-icon-iPad.png differ diff --git a/myLauncher/Google-icon.png b/myLauncher/Google-icon.png new file mode 100644 index 0000000..6189cc1 Binary files /dev/null and b/myLauncher/Google-icon.png differ diff --git a/myLauncher/Google-icon@2x.png b/myLauncher/Google-icon@2x.png new file mode 100644 index 0000000..f832f9b Binary files /dev/null and b/myLauncher/Google-icon@2x.png differ diff --git a/myLauncher/MyLauncher.xcodeproj/project.pbxproj b/myLauncher/MyLauncher.xcodeproj/project.pbxproj index e97119d..a84cf79 100755 --- a/myLauncher/MyLauncher.xcodeproj/project.pbxproj +++ b/myLauncher/MyLauncher.xcodeproj/project.pbxproj @@ -13,7 +13,7 @@ 0F2C05881207A88D009D2ED9 /* launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = 0F2C05871207A88D009D2ED9 /* launcher.png */; }; 0F93B7E71213AE4500BA0DB9 /* close.png in Resources */ = {isa = PBXBuildFile; fileRef = 0F93B7E61213AE4500BA0DB9 /* close.png */; }; 0F975C2E122B0E8300F678EB /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C2D122B0E8300F678EB /* RootViewController.m */; }; - 0F975C99122B4FAE00F678EB /* MyLauncherItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C90122B4FAE00F678EB /* MyLauncherItem.m */; }; + 0F975C99122B4FAE00F678EB /* MyLauncherViewControllerItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C90122B4FAE00F678EB /* MyLauncherViewControllerItem.m */; }; 0F975C9A122B4FAE00F678EB /* MyLauncherPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C92122B4FAE00F678EB /* MyLauncherPageControl.m */; }; 0F975C9B122B4FAE00F678EB /* MyLauncherScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C94122B4FAE00F678EB /* MyLauncherScrollView.m */; }; 0F975C9C122B4FAE00F678EB /* MyLauncherView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C96122B4FAE00F678EB /* MyLauncherView.m */; }; @@ -28,6 +28,35 @@ 7DA45DCD1316B0C700D5FA85 /* itemImage-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DA45DCB1316B0C700D5FA85 /* itemImage-iPad.png */; }; 7DC0590F1397988B00E0EAA9 /* CustomBadge.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC0590E1397988B00E0EAA9 /* CustomBadge.m */; }; 7DF382DA13326D0100738192 /* Icon-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DF382D913326D0100738192 /* Icon-iPad.png */; }; + E305A4CE15A5B6ED009B71E6 /* OpenWebURLItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E305A4CC15A5B6ED009B71E6 /* OpenWebURLItem.m */; }; + E305A4CF15A5B71A009B71E6 /* OpenWebURLItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E305A4CC15A5B6ED009B71E6 /* OpenWebURLItem.m */; }; + E30AA30F15A4993100B6078B /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E30AA30715A4993100B6078B /* libOCMock.a */; }; + E30AA31115A4AFC400B6078B /* Icon-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DF382D913326D0100738192 /* Icon-iPad.png */; }; + E30AA31215A4AFC400B6078B /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0F975CCD122B524500F678EB /* Icon@2x.png */; }; + E30AA31315A4AFC400B6078B /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 0F975CCC122B524500F678EB /* Icon.png */; }; + E30AA31615A4BB3300B6078B /* MyLauncherGenericItemTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E30AA31515A4BB3300B6078B /* MyLauncherGenericItemTest.m */; }; + E30C172E1599E5EB0073DA67 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E30C172D1599E5EB0073DA67 /* SenTestingKit.framework */; }; + E30C172F1599E5EB0073DA67 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; + E30C17301599E5EB0073DA67 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; + E30C17361599E5EB0073DA67 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E30C17341599E5EB0073DA67 /* InfoPlist.strings */; }; + E30C17391599E5EB0073DA67 /* OpenWebURLItemTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E30C17381599E5EB0073DA67 /* OpenWebURLItemTest.m */; }; + E30C1756159A33C20073DA67 /* Google-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = E30C1755159A33C20073DA67 /* Google-icon.png */; }; + E30C1757159A33C20073DA67 /* Google-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = E30C1755159A33C20073DA67 /* Google-icon.png */; }; + E30C1759159A33C80073DA67 /* Google-icon-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = E30C1758159A33C80073DA67 /* Google-icon-iPad.png */; }; + E30C175A159A33C80073DA67 /* Google-icon-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = E30C1758159A33C80073DA67 /* Google-icon-iPad.png */; }; + E30C175C159A33D20073DA67 /* Google-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E30C175B159A33D20073DA67 /* Google-icon@2x.png */; }; + E30C175D159A33D20073DA67 /* Google-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E30C175B159A33D20073DA67 /* Google-icon@2x.png */; }; + E3A83CC7159E2F6C006CCA39 /* MyLauncherItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E3A83CC6159E2F6C006CCA39 /* MyLauncherItem.m */; }; + E3CCD6A215A31E3E005FC746 /* MyLauncherGenericItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E3CCD68415A31C92005FC746 /* MyLauncherGenericItem.m */; }; + E3D4A9F415A4C0F20001541B /* MyLauncherGenericItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E3CCD68415A31C92005FC746 /* MyLauncherGenericItem.m */; }; + E3D4A9F715A4C1EC0001541B /* MyLauncherItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E3A83CC6159E2F6C006CCA39 /* MyLauncherItem.m */; }; + E3D4A9F815A4C2270001541B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; + E3D4A9F915A4C2360001541B /* CustomBadge.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC0590E1397988B00E0EAA9 /* CustomBadge.m */; }; + E3D4A9FA15A4C2390001541B /* MyLauncherViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C98122B4FAE00F678EB /* MyLauncherViewController.m */; }; + E3D4A9FB15A4C23B0001541B /* MyLauncherView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C96122B4FAE00F678EB /* MyLauncherView.m */; }; + E3D4A9FC15A4C23E0001541B /* MyLauncherViewControllerItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C90122B4FAE00F678EB /* MyLauncherViewControllerItem.m */; }; + E3D4A9FD15A4C2410001541B /* MyLauncherScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C94122B4FAE00F678EB /* MyLauncherScrollView.m */; }; + E3D4A9FE15A4C2440001541B /* MyLauncherPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F975C92122B4FAE00F678EB /* MyLauncherPageControl.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -39,8 +68,8 @@ 0F93B7E61213AE4500BA0DB9 /* close.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = close.png; path = imgs/close.png; sourceTree = ""; }; 0F975C2C122B0E8300F678EB /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 0F975C2D122B0E8300F678EB /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; }; - 0F975C8F122B4FAE00F678EB /* MyLauncherItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLauncherItem.h; path = MyLauncher/MyLauncherItem.h; sourceTree = ""; }; - 0F975C90122B4FAE00F678EB /* MyLauncherItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = MyLauncherItem.m; path = MyLauncher/MyLauncherItem.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 0F975C8F122B4FAE00F678EB /* MyLauncherViewControllerItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLauncherViewControllerItem.h; path = MyLauncher/MyLauncherViewControllerItem.h; sourceTree = ""; }; + 0F975C90122B4FAE00F678EB /* MyLauncherViewControllerItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = MyLauncherViewControllerItem.m; path = MyLauncher/MyLauncherViewControllerItem.m; sourceTree = ""; }; 0F975C91122B4FAE00F678EB /* MyLauncherPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLauncherPageControl.h; path = MyLauncher/MyLauncherPageControl.h; sourceTree = ""; }; 0F975C92122B4FAE00F678EB /* MyLauncherPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyLauncherPageControl.m; path = MyLauncher/MyLauncherPageControl.m; sourceTree = ""; }; 0F975C93122B4FAE00F678EB /* MyLauncherScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLauncherScrollView.h; path = MyLauncher/MyLauncherScrollView.h; sourceTree = ""; }; @@ -64,6 +93,32 @@ 7DC0590E1397988B00E0EAA9 /* CustomBadge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CustomBadge.m; path = MyLauncher/CustomBadge.m; sourceTree = ""; }; 7DF382D913326D0100738192 /* Icon-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-iPad.png"; path = "imgs/Icon-iPad.png"; sourceTree = ""; }; 8D1107310486CEB800E47090 /* MyLauncher-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "MyLauncher-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; + E305A4C915A5B582009B71E6 /* MyLauncherGenericItemDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLauncherGenericItemDelegate.h; path = MyLauncher/MyLauncherGenericItemDelegate.h; sourceTree = ""; }; + E305A4CC15A5B6ED009B71E6 /* OpenWebURLItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenWebURLItem.m; sourceTree = ""; }; + E305A4CD15A5B6ED009B71E6 /* OpenWebURLItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenWebURLItem.h; sourceTree = ""; }; + E30AA30715A4993100B6078B /* libOCMock.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libOCMock.a; sourceTree = ""; }; + E30AA30915A4993100B6078B /* NSNotificationCenter+OCMAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+OCMAdditions.h"; sourceTree = ""; }; + E30AA30A15A4993100B6078B /* OCMArg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMArg.h; sourceTree = ""; }; + E30AA30B15A4993100B6078B /* OCMConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMConstraint.h; sourceTree = ""; }; + E30AA30C15A4993100B6078B /* OCMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMock.h; sourceTree = ""; }; + E30AA30D15A4993100B6078B /* OCMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMockObject.h; sourceTree = ""; }; + E30AA30E15A4993100B6078B /* OCMockRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMockRecorder.h; sourceTree = ""; }; + E30AA31415A4BB3300B6078B /* MyLauncherGenericItemTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyLauncherGenericItemTest.h; sourceTree = ""; }; + E30AA31515A4BB3300B6078B /* MyLauncherGenericItemTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyLauncherGenericItemTest.m; sourceTree = ""; }; + E30C172C1599E5EB0073DA67 /* MyLauncherTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MyLauncherTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + E30C172D1599E5EB0073DA67 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + E30C17331599E5EB0073DA67 /* MyLauncherTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MyLauncherTests-Info.plist"; sourceTree = ""; }; + E30C17351599E5EB0073DA67 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + E30C17371599E5EB0073DA67 /* OpenWebURLItemTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenWebURLItemTest.h; sourceTree = ""; }; + E30C17381599E5EB0073DA67 /* OpenWebURLItemTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OpenWebURLItemTest.m; sourceTree = ""; }; + E30C173A1599E5EB0073DA67 /* MyLauncherTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MyLauncherTests-Prefix.pch"; sourceTree = ""; }; + E30C1755159A33C20073DA67 /* Google-icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Google-icon.png"; sourceTree = ""; }; + E30C1758159A33C80073DA67 /* Google-icon-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Google-icon-iPad.png"; sourceTree = ""; }; + E30C175B159A33D20073DA67 /* Google-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Google-icon@2x.png"; sourceTree = ""; }; + E3A83CC5159E2F6C006CCA39 /* MyLauncherItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLauncherItem.h; path = MyLauncher/MyLauncherItem.h; sourceTree = ""; }; + E3A83CC6159E2F6C006CCA39 /* MyLauncherItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyLauncherItem.m; path = MyLauncher/MyLauncherItem.m; sourceTree = ""; }; + E3CCD68415A31C92005FC746 /* MyLauncherGenericItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyLauncherGenericItem.m; path = MyLauncher/MyLauncherGenericItem.m; sourceTree = ""; }; + E3CCD6C815A32447005FC746 /* MyLauncherGenericItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLauncherGenericItem.h; path = MyLauncher/MyLauncherGenericItem.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -77,6 +132,18 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E30C17281599E5EB0073DA67 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E3D4A9F815A4C2270001541B /* CoreGraphics.framework in Frameworks */, + E30C172E1599E5EB0073DA67 /* SenTestingKit.framework in Frameworks */, + E30C172F1599E5EB0073DA67 /* UIKit.framework in Frameworks */, + E30C17301599E5EB0073DA67 /* Foundation.framework in Frameworks */, + E30AA30F15A4993100B6078B /* libOCMock.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -86,6 +153,8 @@ 0F975B02122AFC3B00F678EB /* MyLauncher */, 1D3623240D0F684500981E51 /* AppDelegate.h */, 1D3623250D0F684500981E51 /* AppDelegate.m */, + E305A4CD15A5B6ED009B71E6 /* OpenWebURLItem.h */, + E305A4CC15A5B6ED009B71E6 /* OpenWebURLItem.m */, 0F975C2C122B0E8300F678EB /* RootViewController.h */, 0F975C2D122B0E8300F678EB /* RootViewController.m */, 0F1328EC120637BC00C7C87C /* ItemViewController.h */, @@ -97,6 +166,7 @@ 0F1328E91206371D00C7C87C /* Images@1x */ = { isa = PBXGroup; children = ( + E30C1755159A33C20073DA67 /* Google-icon.png */, 0F975CCC122B524500F678EB /* Icon.png */, 0F1328EA1206374800C7C87C /* itemImage.png */, ); @@ -106,6 +176,7 @@ 0F2C053E12068241009D2ED9 /* Images@2x */ = { isa = PBXGroup; children = ( + E30C175B159A33D20073DA67 /* Google-icon@2x.png */, 0F975CCD122B524500F678EB /* Icon@2x.png */, 0F2C054712068283009D2ED9 /* itemImage@2x.png */, ); @@ -115,14 +186,19 @@ 0F975B02122AFC3B00F678EB /* MyLauncher */ = { isa = PBXGroup; children = ( + E305A4C915A5B582009B71E6 /* MyLauncherGenericItemDelegate.h */, + E3CCD6C815A32447005FC746 /* MyLauncherGenericItem.h */, + E3CCD68415A31C92005FC746 /* MyLauncherGenericItem.m */, + E3A83CC5159E2F6C006CCA39 /* MyLauncherItem.h */, + E3A83CC6159E2F6C006CCA39 /* MyLauncherItem.m */, 7DC0590D1397988B00E0EAA9 /* CustomBadge.h */, 7DC0590E1397988B00E0EAA9 /* CustomBadge.m */, 0F975C97122B4FAE00F678EB /* MyLauncherViewController.h */, 0F975C98122B4FAE00F678EB /* MyLauncherViewController.m */, 0F975C95122B4FAE00F678EB /* MyLauncherView.h */, 0F975C96122B4FAE00F678EB /* MyLauncherView.m */, - 0F975C8F122B4FAE00F678EB /* MyLauncherItem.h */, - 0F975C90122B4FAE00F678EB /* MyLauncherItem.m */, + 0F975C8F122B4FAE00F678EB /* MyLauncherViewControllerItem.h */, + 0F975C90122B4FAE00F678EB /* MyLauncherViewControllerItem.m */, 0F975C93122B4FAE00F678EB /* MyLauncherScrollView.h */, 0F975C94122B4FAE00F678EB /* MyLauncherScrollView.m */, 0F975C91122B4FAE00F678EB /* MyLauncherPageControl.h */, @@ -135,6 +211,7 @@ isa = PBXGroup; children = ( 1D6058910D05DD3D006BFB54 /* MyLauncher.app */, + E30C172C1599E5EB0073DA67 /* MyLauncherTests.octest */, ); name = Products; sourceTree = ""; @@ -145,6 +222,7 @@ 080E96DDFE201D6D7F000001 /* Classes */, 29B97315FDCFA39411CA2CEA /* Other Sources */, 29B97317FDCFA39411CA2CEA /* Resources */, + E30C17311599E5EB0073DA67 /* MyLauncherTests */, 29B97323FDCFA39411CA2CEA /* Frameworks */, 19C28FACFE9D520D11CA2CBB /* Products */, ); @@ -176,9 +254,12 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + E30AA30715A4993100B6078B /* libOCMock.a */, + E30AA30815A4993100B6078B /* OCMock */, 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 1D30AB110D05D00D00671497 /* Foundation.framework */, 288765FC0DF74451002DB57D /* CoreGraphics.framework */, + E30C172D1599E5EB0073DA67 /* SenTestingKit.framework */, ); name = Frameworks; sourceTree = ""; @@ -186,12 +267,48 @@ 7DA45DC81316AD6E00D5FA85 /* Images@iPad */ = { isa = PBXGroup; children = ( + E30C1758159A33C80073DA67 /* Google-icon-iPad.png */, 7DF382D913326D0100738192 /* Icon-iPad.png */, 7DA45DCB1316B0C700D5FA85 /* itemImage-iPad.png */, ); name = "Images@iPad"; sourceTree = ""; }; + E30AA30815A4993100B6078B /* OCMock */ = { + isa = PBXGroup; + children = ( + E30AA30915A4993100B6078B /* NSNotificationCenter+OCMAdditions.h */, + E30AA30A15A4993100B6078B /* OCMArg.h */, + E30AA30B15A4993100B6078B /* OCMConstraint.h */, + E30AA30C15A4993100B6078B /* OCMock.h */, + E30AA30D15A4993100B6078B /* OCMockObject.h */, + E30AA30E15A4993100B6078B /* OCMockRecorder.h */, + ); + path = OCMock; + sourceTree = ""; + }; + E30C17311599E5EB0073DA67 /* MyLauncherTests */ = { + isa = PBXGroup; + children = ( + E30C17371599E5EB0073DA67 /* OpenWebURLItemTest.h */, + E30C17381599E5EB0073DA67 /* OpenWebURLItemTest.m */, + E30AA31415A4BB3300B6078B /* MyLauncherGenericItemTest.h */, + E30AA31515A4BB3300B6078B /* MyLauncherGenericItemTest.m */, + E30C17321599E5EB0073DA67 /* Supporting Files */, + ); + path = MyLauncherTests; + sourceTree = ""; + }; + E30C17321599E5EB0073DA67 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + E30C17331599E5EB0073DA67 /* MyLauncherTests-Info.plist */, + E30C17341599E5EB0073DA67 /* InfoPlist.strings */, + E30C173A1599E5EB0073DA67 /* MyLauncherTests-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -212,6 +329,24 @@ productReference = 1D6058910D05DD3D006BFB54 /* MyLauncher.app */; productType = "com.apple.product-type.application"; }; + E30C172B1599E5EB0073DA67 /* MyLauncherTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = E30C173D1599E5EB0073DA67 /* Build configuration list for PBXNativeTarget "MyLauncherTests" */; + buildPhases = ( + E30C17271599E5EB0073DA67 /* Sources */, + E30C17281599E5EB0073DA67 /* Frameworks */, + E30C17291599E5EB0073DA67 /* Resources */, + E30C172A1599E5EB0073DA67 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MyLauncherTests; + productName = MyLauncherTests; + productReference = E30C172C1599E5EB0073DA67 /* MyLauncherTests.octest */; + productType = "com.apple.product-type.bundle"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -232,6 +367,7 @@ projectRoot = ""; targets = ( 1D6058900D05DD3D006BFB54 /* MyLauncher */, + E30C172B1599E5EB0073DA67 /* MyLauncherTests */, ); }; /* End PBXProject section */ @@ -249,11 +385,44 @@ 0F975CCF122B524500F678EB /* Icon@2x.png in Resources */, 7DA45DCD1316B0C700D5FA85 /* itemImage-iPad.png in Resources */, 7DF382DA13326D0100738192 /* Icon-iPad.png in Resources */, + E30C1756159A33C20073DA67 /* Google-icon.png in Resources */, + E30C1759159A33C80073DA67 /* Google-icon-iPad.png in Resources */, + E30C175C159A33D20073DA67 /* Google-icon@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E30C17291599E5EB0073DA67 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E30AA31115A4AFC400B6078B /* Icon-iPad.png in Resources */, + E30AA31215A4AFC400B6078B /* Icon@2x.png in Resources */, + E30AA31315A4AFC400B6078B /* Icon.png in Resources */, + E30C17361599E5EB0073DA67 /* InfoPlist.strings in Resources */, + E30C1757159A33C20073DA67 /* Google-icon.png in Resources */, + E30C175A159A33C80073DA67 /* Google-icon-iPad.png in Resources */, + E30C175D159A33D20073DA67 /* Google-icon@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + E30C172A1599E5EB0073DA67 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 1D60588E0D05DD3D006BFB54 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -263,29 +432,62 @@ 1D3623260D0F684500981E51 /* AppDelegate.m in Sources */, 0F1328EE120637BC00C7C87C /* ItemViewController.m in Sources */, 0F975C2E122B0E8300F678EB /* RootViewController.m in Sources */, - 0F975C99122B4FAE00F678EB /* MyLauncherItem.m in Sources */, + 0F975C99122B4FAE00F678EB /* MyLauncherViewControllerItem.m in Sources */, 0F975C9A122B4FAE00F678EB /* MyLauncherPageControl.m in Sources */, 0F975C9B122B4FAE00F678EB /* MyLauncherScrollView.m in Sources */, 0F975C9C122B4FAE00F678EB /* MyLauncherView.m in Sources */, 0F975C9D122B4FAE00F678EB /* MyLauncherViewController.m in Sources */, 7DC0590F1397988B00E0EAA9 /* CustomBadge.m in Sources */, + E3A83CC7159E2F6C006CCA39 /* MyLauncherItem.m in Sources */, + E3CCD6A215A31E3E005FC746 /* MyLauncherGenericItem.m in Sources */, + E305A4CF15A5B71A009B71E6 /* OpenWebURLItem.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E30C17271599E5EB0073DA67 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E30C17391599E5EB0073DA67 /* OpenWebURLItemTest.m in Sources */, + E30AA31615A4BB3300B6078B /* MyLauncherGenericItemTest.m in Sources */, + E3D4A9F415A4C0F20001541B /* MyLauncherGenericItem.m in Sources */, + E3D4A9F715A4C1EC0001541B /* MyLauncherItem.m in Sources */, + E3D4A9F915A4C2360001541B /* CustomBadge.m in Sources */, + E3D4A9FA15A4C2390001541B /* MyLauncherViewController.m in Sources */, + E3D4A9FB15A4C23B0001541B /* MyLauncherView.m in Sources */, + E3D4A9FC15A4C23E0001541B /* MyLauncherViewControllerItem.m in Sources */, + E3D4A9FD15A4C2410001541B /* MyLauncherScrollView.m in Sources */, + E3D4A9FE15A4C2440001541B /* MyLauncherPageControl.m in Sources */, + E305A4CE15A5B6ED009B71E6 /* OpenWebURLItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXVariantGroup section */ + E30C17341599E5EB0073DA67 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + E30C17351599E5EB0073DA67 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = MyLauncher_Prefix.pch; INFOPLIST_FILE = "MyLauncher-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 4.2; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; PRODUCT_NAME = MyLauncher; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -295,11 +497,12 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = MyLauncher_Prefix.pch; INFOPLIST_FILE = "MyLauncher-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 4.2; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; PRODUCT_NAME = MyLauncher; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -333,6 +536,84 @@ }; name = Release; }; + E30C173B1599E5EB0073DA67 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "MyLauncherTests/MyLauncherTests-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)\"", + ); + INFOPLIST_FILE = "MyLauncherTests/MyLauncherTests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)\"", + ); + OTHER_LDFLAGS = ( + "-force_load", + "\"$(SRCROOT)/libOCMock.a\"", + "-ObjC", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + E30C173C1599E5EB0073DA67 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "MyLauncherTests/MyLauncherTests-Prefix.pch"; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)\"", + ); + INFOPLIST_FILE = "MyLauncherTests/MyLauncherTests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)\"", + ); + OTHER_LDFLAGS = ( + "-force_load", + "\"$(SRCROOT)/libOCMock.a\"", + "-ObjC", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + VALIDATE_PRODUCT = YES; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -354,6 +635,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + E30C173D1599E5EB0073DA67 /* Build configuration list for PBXNativeTarget "MyLauncherTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E30C173B1599E5EB0073DA67 /* Debug */, + E30C173C1599E5EB0073DA67 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; diff --git a/myLauncher/MyLauncherTests/MyLauncherGenericItemTest.h b/myLauncher/MyLauncherTests/MyLauncherGenericItemTest.h new file mode 100644 index 0000000..39758ff --- /dev/null +++ b/myLauncher/MyLauncherTests/MyLauncherGenericItemTest.h @@ -0,0 +1,13 @@ +// +// MyLauncherGenericItemTest.h +// MyLauncher +// +// Created by Nicolas Desjardins on 2012-07-04. +// +// + +#import + +@interface MyLauncherGenericItemTest : SenTestCase + +@end diff --git a/myLauncher/MyLauncherTests/MyLauncherGenericItemTest.m b/myLauncher/MyLauncherTests/MyLauncherGenericItemTest.m new file mode 100644 index 0000000..815687b --- /dev/null +++ b/myLauncher/MyLauncherTests/MyLauncherGenericItemTest.m @@ -0,0 +1,59 @@ +// +// MyLauncherGenericItemTest.m +// MyLauncher +// +// Created by Nicolas Desjardins on 2012-07-04. +// +// + +#import "MyLauncherGenericItemDelegate.h" +#import "MyLauncherGenericItemTest.h" +#import "MyLauncherViewController.h" +#import "MyLauncherGenericItem.h" + +#import + +@implementation MyLauncherGenericItemTest + +- (void)setUp +{ + [super setUp]; + +} + +- (void)tearDown +{ + // Tear-down code here. + [super tearDown]; +} + +- (void)testSelected +{ + id mockGenericDelegate = [OCMockObject mockForProtocol:@protocol(MyLauncherGenericItemDelegate)]; + + [(id)[mockGenericDelegate expect] start]; + + MyLauncherGenericItem *genericItem = [[MyLauncherGenericItem alloc] initWithTitle:@"My Title" delegate:mockGenericDelegate deletable:YES]; + + id mockParentController = [OCMockObject mockForClass:[MyLauncherViewController class]]; + [genericItem selected:mockParentController]; + + [mockGenericDelegate verify]; +} + +-(void) testItemToSave +{ + id mockGenericDelegate = [OCMockObject mockForProtocol:@protocol(MyLauncherGenericItemDelegate)]; + + MyLauncherGenericItem *genericItem = [[MyLauncherGenericItem alloc] initWithTitle:@"My Title" delegate:mockGenericDelegate deletable:YES]; + + NSDictionary *itemsToSave = [genericItem itemToSave]; + + NSData* savedData = [itemsToSave objectForKey:@"genericDelegate"]; + + MyLauncherGenericItem *unarchived = [NSKeyedUnarchiver unarchiveObjectWithData:savedData]; + STAssertEqualObjects(mockGenericDelegate, unarchived, @""); + +} + +@end diff --git a/myLauncher/MyLauncherTests/MyLauncherTests-Info.plist b/myLauncher/MyLauncherTests/MyLauncherTests-Info.plist new file mode 100644 index 0000000..99bdd1a --- /dev/null +++ b/myLauncher/MyLauncherTests/MyLauncherTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.desjardins.mobile.lanceur.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/myLauncher/MyLauncherTests/MyLauncherTests-Prefix.pch b/myLauncher/MyLauncherTests/MyLauncherTests-Prefix.pch new file mode 100644 index 0000000..4ad3b90 --- /dev/null +++ b/myLauncher/MyLauncherTests/MyLauncherTests-Prefix.pch @@ -0,0 +1,10 @@ +// +// Prefix header for all source files of the 'MyLauncherTests' target in the 'MyLauncherTests' project +// + +#ifdef __OBJC__ + #import + #import +#endif + +#define COLOR(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1] \ No newline at end of file diff --git a/myLauncher/MyLauncherTests/OpenWebURLItemTest.h b/myLauncher/MyLauncherTests/OpenWebURLItemTest.h new file mode 100644 index 0000000..4222fe1 --- /dev/null +++ b/myLauncher/MyLauncherTests/OpenWebURLItemTest.h @@ -0,0 +1,13 @@ +// +// MyLauncherTests.h +// MyLauncherTests +// +// Created by Nicolas Desjardins on 2012-06-26. +// +// + +#import + +@interface OpenWebURLItemTest : SenTestCase + +@end diff --git a/myLauncher/MyLauncherTests/OpenWebURLItemTest.m b/myLauncher/MyLauncherTests/OpenWebURLItemTest.m new file mode 100644 index 0000000..de82f41 --- /dev/null +++ b/myLauncher/MyLauncherTests/OpenWebURLItemTest.m @@ -0,0 +1,63 @@ +// +// MyLauncherTests.m +// MyLauncherTests +// +// Created by Nicolas Desjardins on 2012-06-26. +// +// + +#import "OpenWebURLItemTest.h" +#import "OpenWebURLItem.h" +#import + + +@interface OpenWebURLItemTest(){ + UIImage *icon; + OpenWebURLItem *webItem; +} + +@end + +@implementation OpenWebURLItemTest + +- (void)setUp +{ + [super setUp]; + NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Icon" ofType:@"png"]; + icon = [UIImage imageWithContentsOfFile:path]; + webItem = [[OpenWebURLItem alloc] initWithURL:@"http://TestURL.org" andIcon:icon]; +} + +- (void)tearDown +{ + // Tear-down code here. + + [super tearDown]; +} + +- (void)testEncoding +{ + id mockCoder = [OCMockObject mockForClass:[NSCoder class]]; + [[mockCoder expect] encodeObject:@"http://TestURL.org" forKey:@"URL"]; + [[mockCoder expect] encodeObject:UIImagePNGRepresentation(icon) forKey:@"icon"]; + [webItem encodeWithCoder:mockCoder]; + + [mockCoder verify]; +} + +- (void)testDecoding +{ + id mockDecoder = [OCMockObject mockForClass:[NSCoder class]]; + + [[[mockDecoder stub] andReturn:@"http://TestURL.org"] decodeObjectForKey:@"URL"]; + [[[mockDecoder stub] andReturn:UIImagePNGRepresentation(icon)] decodeObjectForKey:@"icon"]; + + OpenWebURLItem *decodedWebItem = [webItem initWithCoder:mockDecoder]; + + STAssertEqualObjects([decodedWebItem url], @"http://TestURL.org", @"The URL"); + + STAssertNotNil([decodedWebItem icon], @"The icon not nil"); + STAssertEqualObjects([[decodedWebItem icon] class], [UIImage class], @"The icon not nil"); +} + +@end diff --git a/myLauncher/MyLauncherTests/en.lproj/InfoPlist.strings b/myLauncher/MyLauncherTests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/myLauncher/MyLauncherTests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/myLauncher/OCMock/NSNotificationCenter+OCMAdditions.h b/myLauncher/OCMock/NSNotificationCenter+OCMAdditions.h new file mode 100644 index 0000000..ab4832b --- /dev/null +++ b/myLauncher/OCMock/NSNotificationCenter+OCMAdditions.h @@ -0,0 +1,15 @@ +//--------------------------------------------------------------------------------------- +// $Id$ +// Copyright (c) 2009 by Mulle Kybernetik. See License file for details. +//--------------------------------------------------------------------------------------- + +#import + +@class OCMockObserver; + + +@interface NSNotificationCenter(OCMAdditions) + +- (void)addMockObserver:(OCMockObserver *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender; + +@end diff --git a/myLauncher/OCMock/OCMArg.h b/myLauncher/OCMock/OCMArg.h new file mode 100644 index 0000000..669c094 --- /dev/null +++ b/myLauncher/OCMock/OCMArg.h @@ -0,0 +1,33 @@ +//--------------------------------------------------------------------------------------- +// $Id$ +// Copyright (c) 2009-2010 by Mulle Kybernetik. See License file for details. +//--------------------------------------------------------------------------------------- + +#import + +@interface OCMArg : NSObject + +// constraining arguments + ++ (id)any; ++ (void *)anyPointer; ++ (id)isNil; ++ (id)isNotNil; ++ (id)isNotEqual:(id)value; ++ (id)checkWithSelector:(SEL)selector onObject:(id)anObject; +#if NS_BLOCKS_AVAILABLE ++ (id)checkWithBlock:(BOOL (^)(id))block; +#endif + +// manipulating arguments + ++ (id *)setTo:(id)value; + +// internal use only + ++ (id)resolveSpecialValues:(NSValue *)value; + +@end + +#define OCMOCK_ANY [OCMArg any] +#define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))] diff --git a/myLauncher/OCMock/OCMConstraint.h b/myLauncher/OCMock/OCMConstraint.h new file mode 100644 index 0000000..3ae1264 --- /dev/null +++ b/myLauncher/OCMock/OCMConstraint.h @@ -0,0 +1,64 @@ +//--------------------------------------------------------------------------------------- +// $Id$ +// Copyright (c) 2007-2010 by Mulle Kybernetik. See License file for details. +//--------------------------------------------------------------------------------------- + +#import + + +@interface OCMConstraint : NSObject + ++ (id)constraint; +- (BOOL)evaluate:(id)value; + +// if you are looking for any, isNil, etc, they have moved to OCMArg + +// try to use [OCMArg checkWith...] instead of the constraintWith... methods below + ++ (id)constraintWithSelector:(SEL)aSelector onObject:(id)anObject; ++ (id)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue; + + +@end + +@interface OCMAnyConstraint : OCMConstraint +@end + +@interface OCMIsNilConstraint : OCMConstraint +@end + +@interface OCMIsNotNilConstraint : OCMConstraint +@end + +@interface OCMIsNotEqualConstraint : OCMConstraint +{ + @public + id testValue; +} + +@end + +@interface OCMInvocationConstraint : OCMConstraint +{ + @public + NSInvocation *invocation; +} + +@end + +#if NS_BLOCKS_AVAILABLE + +@interface OCMBlockConstraint : OCMConstraint +{ + BOOL (^block)(id); +} + +- (id)initWithConstraintBlock:(BOOL (^)(id))block; + +@end + +#endif + + +#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self] +#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)] diff --git a/myLauncher/OCMock/OCMock.h b/myLauncher/OCMock/OCMock.h new file mode 100644 index 0000000..e18de58 --- /dev/null +++ b/myLauncher/OCMock/OCMock.h @@ -0,0 +1,10 @@ +//--------------------------------------------------------------------------------------- +// $Id$ +// Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details. +//--------------------------------------------------------------------------------------- + +#import +#import +#import +#import +#import diff --git a/myLauncher/OCMock/OCMockObject.h b/myLauncher/OCMock/OCMockObject.h new file mode 100644 index 0000000..ebd2ba3 --- /dev/null +++ b/myLauncher/OCMock/OCMockObject.h @@ -0,0 +1,43 @@ +//--------------------------------------------------------------------------------------- +// $Id$ +// Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details. +//--------------------------------------------------------------------------------------- + +#import + +@interface OCMockObject : NSProxy +{ + BOOL isNice; + BOOL expectationOrderMatters; + NSMutableArray *recorders; + NSMutableArray *expectations; + NSMutableArray *rejections; + NSMutableArray *exceptions; +} + ++ (id)mockForClass:(Class)aClass; ++ (id)mockForProtocol:(Protocol *)aProtocol; ++ (id)partialMockForObject:(NSObject *)anObject; + ++ (id)niceMockForClass:(Class)aClass; ++ (id)niceMockForProtocol:(Protocol *)aProtocol; + ++ (id)observerMock; + +- (id)init; + +- (void)setExpectationOrderMatters:(BOOL)flag; + +- (id)stub; +- (id)expect; +- (id)reject; + +- (void)verify; + +// internal use only + +- (id)getNewRecorder; +- (BOOL)handleInvocation:(NSInvocation *)anInvocation; +- (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation; + +@end diff --git a/myLauncher/OCMock/OCMockRecorder.h b/myLauncher/OCMock/OCMockRecorder.h new file mode 100644 index 0000000..b11a253 --- /dev/null +++ b/myLauncher/OCMock/OCMockRecorder.h @@ -0,0 +1,32 @@ +//--------------------------------------------------------------------------------------- +// $Id$ +// Copyright (c) 2004-2010 by Mulle Kybernetik. See License file for details. +//--------------------------------------------------------------------------------------- + +#import + +@interface OCMockRecorder : NSProxy +{ + id signatureResolver; + NSInvocation *recordedInvocation; + NSMutableArray *invocationHandlers; +} + +- (id)initWithSignatureResolver:(id)anObject; + +- (BOOL)matchesInvocation:(NSInvocation *)anInvocation; +- (void)releaseInvocation; + +- (id)andReturn:(id)anObject; +- (id)andReturnValue:(NSValue *)aValue; +- (id)andThrow:(NSException *)anException; +- (id)andPost:(NSNotification *)aNotification; +- (id)andCall:(SEL)selector onObject:(id)anObject; +#if NS_BLOCKS_AVAILABLE +- (id)andDo:(void (^)(NSInvocation *))block; +#endif +- (id)andForwardToRealObject; + +- (NSArray *)invocationHandlers; + +@end diff --git a/myLauncher/libOCMock.a b/myLauncher/libOCMock.a new file mode 100644 index 0000000..dae5ac1 Binary files /dev/null and b/myLauncher/libOCMock.a differ