Skip to content
Browse files

Initial setup for responding to `brief://` and `briefcast://` urls pa…

…ssed from elsewhere in the device.
  • Loading branch information...
1 parent f24f418 commit 5621d724c52fc2348ddd1110a8c13a1ff8c8739d @capttaco committed Mar 15, 2010
Showing with 154 additions and 146 deletions.
  1. +12 −0 Briefs-Info.plist
  2. +29 −0 Classes/BFMainViewController.h
  3. +76 −27 Classes/BFMainViewController.m
  4. +36 −1 Classes/BriefsAppDelegate.m
  5. +1 −118 Classes/MainWindow.xib
View
12 Briefs-Info.plist
@@ -28,5 +28,17 @@
<string>MainWindow</string>
<key>UIPrerenderedIcon</key>
<true/>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>com.digitalarch.briefs</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>brief</string>
+ <string>briefcast</string>
+ </array>
+ </dict>
+ </array>
</dict>
</plist>
View
29 Classes/BFMainViewController.h
@@ -8,13 +8,42 @@
#import <UIKit/UIKit.h>
+// Display states for various start-up conditions
+typedef enum {
+ /** Start-up triggered by a brief:// or briefcast:// url */
+ BFMainViewOpenedByURL = -2100,
+
+ /** restarting the app, after it was interuppted while showing a brief */
+ BFMainViewClosedWhilePlayingBrief = -2101,
+
+ /** user has not entered any new briefs or briefcasts, encourage them */
+ BFMainViewNoDataToDisplay = -2102,
+
+ /** the default state, which presents recently opened briefs/briefcasts */
+ BFMainViewDefaultState = -2103,
+
+ /** first time the user opens the app, show welcome launch */
+ BFMainViewFirstTimeOpened = -2104,
+
+} BFMainViewState;
+
+
@interface BFMainViewController : UIViewController
{
IBOutlet UIView *openingView;
IBOutlet UIView *menuView;
+
+ BFMainViewState stateUponLaunch;
+
+ // optional context ivars
+ NSURL *urlLaunchWith;
}
+// Initialization
+- (id)initWithState:(BFMainViewState)state;
+- (id)initWithExternalURL:(NSURL *)url;
+
// Menu Actions
- (IBAction)browseYourBriefs;
- (IBAction)browseYourBriefcasts;
View
103 Classes/BFMainViewController.m
@@ -15,6 +15,7 @@
@interface BFMainViewController (private)
- (void)hideMenuWithAnimation;
+- (void)showMenuWithAnimation;
@end
@@ -25,45 +26,82 @@ @implementation BFMainViewController
#pragma mark -
#pragma mark NSObject Methods
-- (void)viewDidLoad
+- (id)initWithState:(BFMainViewState)state
{
- [super viewDidLoad];
- self.navigationController.navigationBar.tintColor = [BFColor tintColorForNavigationBar];
- self.title = @"Welcome";
+ self = [super initWithNibName:@"BFMainViewController" bundle:nil];
+ if (self != nil) {
+ stateUponLaunch = state;
+ }
+ return self;
}
-- (void)viewWillAppear:(BOOL)animated
+- (id)initWithExternalURL:(NSURL *)url
{
- // push down the menu view
- [UIView beginAnimations:@"MenuSlideUpTransition" context:nil];
- [UIView setAnimationDelegate:self];
- [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
- [UIView setAnimationDuration:0.3f];
-
- CGSize size = menuView.frame.size;
- menuView.frame = CGRectMake(0.0f, 280.0f, size.width, size.height);
+ self = [self initWithState:BFMainViewOpenedByURL];
+ if (self != nil) {
+ urlLaunchWith = url;
+ }
- [UIView commitAnimations];
+ return self;
}
-- (void)didReceiveMemoryWarning
+- (void)dealloc
{
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
-
- // Release any cached data, images, etc that aren't in use.
+ [super dealloc];
}
-- (void)viewDidUnload
+///////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+#pragma mark NSViewController Methods
+
+- (void)viewDidLoad
{
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
+ [super viewDidLoad];
+ self.navigationController.navigationBar.tintColor = [BFColor tintColorForNavigationBar];
+ self.title = @"Welcome";
}
+- (void)viewWillAppear:(BOOL)animated
+{
+ switch (stateUponLaunch) {
+ case BFMainViewOpenedByURL:
+
+ // TODO: Open brief or briefcast at URL
+
+ stateUponLaunch = BFMainViewDefaultState;
+ break;
+
+ case BFMainViewClosedWhilePlayingBrief:
+
+ // TODO: Offer to re-open brief that was disrupted
+
+ stateUponLaunch = BFMainViewDefaultState;
+ break;
+
+ case BFMainViewNoDataToDisplay:
+
+ // TODO: Explain how to find a briefcast
+ break;
+
+ case BFMainViewFirstTimeOpened:
+
+ // TODO: Display the welcome screens
+ break;
+
+ case BFMainViewDefaultState:
+ if (menuView.frame.origin.y <= 480.0f)
+ [self showMenuWithAnimation];
+
+ // TODO: Display recent briefs/briefcasts
+
+ break;
+ }
+}
-- (void)dealloc
+- (void)viewDidUnload
{
- [super dealloc];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
}
@@ -83,15 +121,26 @@ - (void)hideMenuWithAnimation
[UIView commitAnimations];
}
+- (void)showMenuWithAnimation
+{
+ // push up the menu view
+ [UIView beginAnimations:@"MenuSlideUpTransition" context:nil];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
+ [UIView setAnimationDuration:0.3f];
+
+ CGSize size = menuView.frame.size;
+ menuView.frame = CGRectMake(0.0f, 280.0f, size.width, size.height);
+
+ [UIView commitAnimations];
+}
+
- (IBAction)browseYourBriefs
{
[self hideMenuWithAnimation];
-
- // show browser view
[self.navigationController pushViewController:[[BFBrowseViewController alloc] init] animated:YES];
}
-
- (IBAction)browseYourBriefcasts
{
[self hideMenuWithAnimation];
View
37 Classes/BriefsAppDelegate.m
@@ -8,25 +8,60 @@
#import "BriefsAppDelegate.h"
#import "BFSceneViewController.h"
+#import "BFMainViewController.h"
#import "BFDataManager.h"
@implementation BriefsAppDelegate
@synthesize navigationController, window;
-- (void)applicationDidFinishLaunching:(UIApplication *)application
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[BFDataManager sharedBFDataManager] load];
+
+ BFMainViewController *controller = [BFMainViewController alloc];
+ if (launchOptions) {
+ NSURL *url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
+ controller = [controller initWithState:BFMainViewOpenedByURL];
+ }
+
+ else {
+ // no url sent, going to default for now
+ // TODO: Need to flesh out rest of the launch states.
+ controller = [controller initWithState:BFMainViewDefaultState];
+ }
+
+ self.navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
+ self.navigationController.delegate = self;
[window addSubview:[self.navigationController view]];
[window makeKeyAndVisible];
+ [controller release];
+
+ return YES;
}
- (void)applicationWillTerminate:(UIApplication *)application
{
[[BFDataManager sharedBFDataManager] save];
}
+//- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
+//{
+// if ([[url scheme] isEqualToString:@"brief"]) {
+// NSLog(@"Received the following URL for a brief: %@", url);
+//
+//
+//
+// return YES;
+// }
+// else if ([[url scheme] isEqualToString:@"brieflist"]) {
+// NSLog(@"Received the following URL for a briefcast: %@", url);
+// return YES;
+// }
+// return NO;
+//}
+
- (void)dealloc
{
[navigationController release];
View
119 Classes/MainWindow.xib
@@ -12,7 +12,6 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="7"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -36,12 +35,10 @@
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
</object>
<object class="IBUIWindow" id="380026005">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">1316</int>
<object class="NSPSMatrix" key="NSFrameMatrix"/>
<string key="NSFrameSize">{320, 480}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
@@ -50,26 +47,6 @@
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
</object>
- <object class="IBUINavigationController" id="896871812">
- <object class="IBUINavigationBar" key="IBUINavigationBar" id="42070853">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{0, 0}</string>
- <bool key="IBUIOpaque">NO</bool>
- <bool key="IBUIClipsSubviews">YES</bool>
- <bool key="IBUIMultipleTouchEnabled">YES</bool>
- </object>
- <object class="NSMutableArray" key="IBUIViewControllers">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBUIViewController" id="527492698">
- <object class="IBUINavigationItem" key="IBUINavigationItem" id="447367787">
- <reference key="IBUINavigationBar"/>
- <string key="IBUITitle">Root View Controller</string>
- </object>
- <reference key="IBUIParentViewController" ref="896871812"/>
- </object>
- </object>
- </object>
<object class="IBUICustomObject" id="778070753"/>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -85,28 +62,12 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">navigationController</string>
- <reference key="source" ref="778070753"/>
- <reference key="destination" ref="896871812"/>
- </object>
- <int key="connectionID">17</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="778070753"/>
<reference key="destination" ref="380026005"/>
</object>
<int key="connectionID">18</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="896871812"/>
- <reference key="destination" ref="778070753"/>
- </object>
- <int key="connectionID">19</int>
- </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -134,35 +95,6 @@
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">7</int>
- <reference key="object" ref="896871812"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="527492698"/>
- <reference ref="42070853"/>
- </object>
- <reference key="parent" ref="0"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">8</int>
- <reference key="object" ref="527492698"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="447367787"/>
- </object>
- <reference key="parent" ref="896871812"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">9</int>
- <reference key="object" ref="42070853"/>
- <reference key="parent" ref="896871812"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">10</int>
- <reference key="object" ref="447367787"/>
- <reference key="parent" ref="527492698"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="778070753"/>
<reference key="parent" ref="0"/>
@@ -175,24 +107,17 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
- <string>10.IBPluginDependency</string>
<string>15.CustomClassName</string>
<string>15.IBPluginDependency</string>
<string>2.IBAttributePlaceholdersKey</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>2.UIWindow.visibleAtLaunch</string>
- <string>7.IBEditorWindowLastContentRect</string>
- <string>7.IBPluginDependency</string>
- <string>8.CustomClassName</string>
- <string>8.IBPluginDependency</string>
- <string>9.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIApplication</string>
<string>UIResponder</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>BriefsAppDelegate</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSMutableDictionary">
@@ -205,11 +130,6 @@
<string>{{652, 71}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<integer value="1"/>
- <string>{{21, 231}, {320, 480}}</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string>BFMainViewController</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -234,14 +154,6 @@
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
- <string key="className">BFMainViewController</string>
- <string key="superclassName">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">Classes/BFMainViewController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">BriefsAppDelegate</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
@@ -400,30 +312,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">UIBarButtonItem</string>
- <string key="superclassName">UIBarItem</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIBarButtonItem.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIBarItem</string>
- <string key="superclassName">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIBarItem.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UINavigationBar</string>
- <string key="superclassName">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1003108189">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UINavigationBar.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">UINavigationController</string>
<string key="superclassName">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="970635798">
@@ -432,11 +320,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">UINavigationItem</string>
- <string key="superclassName">NSObject</string>
- <reference key="sourceIdentifier" ref="1003108189"/>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">UIResponder</string>
<string key="superclassName">NSObject</string>
<reference key="sourceIdentifier" ref="650194208"/>

0 comments on commit 5621d72

Please sign in to comment.
Something went wrong with that request. Please try again.