Browse files

Merge pull request #21 from vermiculus/feature/auto-capture-mode

Auto-Capture Mode
  • Loading branch information...
2 parents 533f0bf + a8b8a21 commit 5bda921e0d4a0d644af0ce53e5584adb4176c3fc @webframp webframp committed Feb 24, 2013
View
12 Classes/MobileOrgAppDelegate.m
@@ -34,6 +34,7 @@
#import "DataUtils.h"
#import "Reachability.h"
#import "SessionManager.h"
+#import "Settings.h"
@interface MobileOrgAppDelegate(private)
- (void)updateInterfaceWithReachability:(Reachability*)curReach;
@@ -79,6 +80,17 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
[window makeKeyAndVisible];
}
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ if ([[Settings instance] launchTab] == LaunchTabCapture) {
+ // TODO Add some sort of minimum time-lapse to activate
+ // that is, don't create a new capture if the button was hit accidentally
+ // (Allow maybe a minute or two before this setting 'sctivates' again)
+ // (this can be done by storing the time and doing a difference.)
+ [[self tabBarController] setSelectedIndex:1]; // Capture!!
+ [[self noteListController] addNote];
+ }
+}
+
/**
applicationWillTerminate: saves changes in the application's managed object context before the application terminates.
*/
View
8 Classes/Settings/Settings.h
@@ -34,6 +34,11 @@ typedef enum {
ServerModeDropbox
} ServerMode;
+typedef enum {
+ LaunchTabOutline = 0,
+ LaunchTabCapture,
+} LaunchTab;
+
@interface Settings : NSObject {
NSURL *indexUrl;
@@ -51,6 +56,8 @@ typedef enum {
AppBadgeMode appBadgeMode;
ServerMode serverMode;
+
+ LaunchTab launchTab;
NSString *dropboxIndex;
@@ -68,6 +75,7 @@ typedef enum {
@property (nonatomic, copy) NSMutableArray *priorities;
@property (nonatomic) AppBadgeMode appBadgeMode;
@property (nonatomic) ServerMode serverMode;
+@property (nonatomic) LaunchTab launchTab;
@property (nonatomic, copy) NSString *dropboxIndex;
@property (nonatomic, copy) NSString *encryptionPassword;
View
13 Classes/Settings/Settings.m
@@ -46,6 +46,7 @@
static NSString *kPrioritiesKey = @"Priorities";
static NSString *kAppBadgeModeKey = @"AppBadgeMode";
static NSString *kServerModeKey = @"ServerMode";
+static NSString *kLaunchTabKey = @"LaunchTab";
static NSString *kDropboxIndexKey = @"DropboxIndex";
static NSString *kEncryptionPassKey = @"EncryptionPassword";
@@ -62,6 +63,7 @@ @implementation Settings
@synthesize priorities;
@synthesize appBadgeMode;
@synthesize serverMode;
+@synthesize launchTab;
@synthesize dropboxIndex;
@synthesize encryptionPassword;
@@ -131,6 +133,11 @@ - (id)init {
if (!serverMode) {
self.serverMode = ServerModeWebDav;
}
+
+ launchTab = [[NSUserDefaults standardUserDefaults] integerForKey:kLaunchTabKey];
+ if (!serverMode) {
+ self.launchTab = LaunchTabOutline;
+ }
dropboxIndex = [[NSUserDefaults standardUserDefaults] objectForKey:kDropboxIndexKey];
[dropboxIndex retain];
@@ -309,6 +316,12 @@ - (void)setServerMode:(ServerMode)newServerMode {
[[NSUserDefaults standardUserDefaults] synchronize];
}
+- (void)setLaunchTab:(LaunchTab)newLaunchTab {
+ launchTab = newLaunchTab;
+ [[NSUserDefaults standardUserDefaults] setInteger:launchTab forKey:kLaunchTabKey];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+}
+
- (void)setDropboxIndex:(NSString*)anIndex {
[dropboxIndex release];
dropboxIndex = [anIndex copy];
View
36 Classes/Settings/SettingsController.m
@@ -142,7 +142,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
return 2;
break;
case SettingsGroup:
- return 1;
+ return 2;
break;
case EncryptionGroup:
return 1;
@@ -399,6 +399,31 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
return cell;
}
+ case 1:
+ {
+ static NSString *CellIdentifier = @"SettingsLaunchTabCell";
+
+ UISwitch *launchTabSwitch = nil;
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ if (IsIpad())
+ launchTabSwitch = [[[UISwitch alloc] initWithFrame:CGRectMake(620,10,200,25)] autorelease];
+ else
+ launchTabSwitch = [[[UISwitch alloc] initWithFrame:CGRectMake(200,10,200,25)] autorelease];
+ [cell addSubview:launchTabSwitch];
+ [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
+ [[cell textLabel] setFont:[UIFont boldSystemFontOfSize:15.0]];
+ } else {
+ launchTabSwitch = (UISwitch*)[cell.contentView viewWithTag:1];
+ }
+
+ [launchTabSwitch addTarget:self action:@selector(launchTabSwitchChanged:) forControlEvents:UIControlEventValueChanged];
+ [[cell textLabel] setText:@"AutoCapture Mode"];
+ [launchTabSwitch setOn:([[Settings instance] launchTab] == LaunchTabCapture)];
+
+ return cell;
+ }
default:
break;
}
@@ -610,6 +635,15 @@ - (void)modeSwitchChanged:(id)sender {
[[self tableView] setNeedsDisplay];
}
+- (void)launchTabSwitchChanged:(id)sender {
+ UISwitch *launchTabSwitch = (UISwitch*)sender;
+ if ([launchTabSwitch isOn]) {
+ [[Settings instance] setLaunchTab:LaunchTabCapture];
+ } else {
+ [[Settings instance] setLaunchTab:LaunchTabOutline];
+ }
+}
+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 46;
}

0 comments on commit 5bda921

Please sign in to comment.