Skip to content
Browse files

Merge branch 'master' of github.com:myellow/Less-2-Do

  • Loading branch information...
2 parents c2957a8 + b59acec commit 9355421f9da45b69345bdb8dfa1150df21649abf Gerhard Schraml committed Jan 18, 2010
View
3 Classes/EditTaskViewController.h
@@ -30,6 +30,9 @@ typedef enum _TaskControllerMode {
TaskControllerMode mode;
// footer view
UIView *footerView;
+
+ Folder *oldFolder;
+ Context *oldContext;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
View
13 Classes/EditTaskViewController.m
@@ -51,13 +51,17 @@ - (void)viewDidLoad {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
self.tempData = dict;
+
self.navigationItem.leftBarButtonItem = cancel;
self.navigationItem.rightBarButtonItem = save;
[save release];
[cancel release];
[dict release];
+ oldFolder = (Folder *)[self.task.folder retain];
+ oldContext = (Context *)[self.task.context retain];
+
[super viewDidLoad];
}
@@ -74,12 +78,18 @@ - (void)viewDidUnload {
self.task = nil;
self.tempData = nil;
self.textFieldBeingEdited = nil;
+ [oldFolder release];
+ oldFolder = nil;
+ [oldContext release];
+ oldContext = nil;
}
- (void)dealloc {
[task release];
[tempData release];
[textFieldBeingEdited release];
+ [oldFolder release];
+ [oldContext release];
[super dealloc];
}
@@ -544,6 +554,9 @@ -(void)actionSheet:(UIActionSheet*)actionSheet didDismissWithButtonIndex:(NSInte
if ([actionSheet.title isEqualToString:@"Really Cancel?"]) {
// if the user really wants to abort, delete the modal view and show the parent view again
if (buttonIndex != [actionSheet cancelButtonIndex]) {
+ self.task.folder = oldFolder;
+ self.task.context = oldContext;
+
if (self.mode == TaskControllerAddMode) {
Less2DoAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
delegate.currentEditedTask = nil;
View
4 Classes/SFHFKeychainUtils.m
@@ -32,15 +32,15 @@
static NSString *SFHFKeychainUtilsErrorDomain = @"SFHFKeychainUtilsErrorDomain";
-#if __IPHONE_OS_VERSION_MIN_REQUIRED < 30000 && TARGET_IPHONE_SIMULATOR
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 30000 && (TARGET_IPHONE_SIMULATOR || !TARGET_OS_IPHONE)
@interface SFHFKeychainUtils (PrivateMethods)
+ (SecKeychainItemRef) getKeychainItemReferenceForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;
@end
#endif
@implementation SFHFKeychainUtils
-#if __IPHONE_OS_VERSION_MIN_REQUIRED < 30000 && TARGET_IPHONE_SIMULATOR
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 30000 && (TARGET_IPHONE_SIMULATOR || !TARGET_OS_IPHONE)
+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error {
if (!username || !serviceName) {
View
32 Classes/SettingsSyncViewController.m
@@ -58,17 +58,36 @@ - (void)dealloc {
}
- (void)saveSettings {
- NSError *error;
+ NSError *error=nil;
if([self.settings.useTDSync intValue] == 1) {
[SFHFKeychainUtils deleteItemForUsername:self.settings.tdEmail andServiceName:@"Less2DoToodleDoAccount" error:&error];
}
+ if (error != nil) {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
+ message:@"Error with Keychain during delete"
+ delegate:self
+ cancelButtonTitle:@"Ok"
+ otherButtonTitles:nil];
+ [alert show];
+ [alert release];
+ }
+ error = nil;
if([self.eMail.text length]!=0) {
[SFHFKeychainUtils storeUsername:[self.eMail text]
andPassword:[self.password text]
forServiceName:@"Less2DoToodleDoAccount"
- updateExisting:YES
+ updateExisting:NO
error:&error];
+ if (error != nil) {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
+ message:@"Error with Keychain during save"
+ delegate:self
+ cancelButtonTitle:@"Ok"
+ otherButtonTitles:nil];
+ [alert show];
+ [alert release];
+ }
self.settings.tdEmail = [self.eMail text];
self.settings.useTDSync = [NSNumber numberWithInt:1];
self.settings.preferToodleDo = self.preferToodleDo.on == YES ? [NSNumber numberWithInt:1] : [NSNumber numberWithInt:0];
@@ -134,6 +153,15 @@ - (IBAction)forceRemoteToLocalSync:(id)sender {
- (IBAction)unlinkAccount:(id)sender {
NSError *error;
[SFHFKeychainUtils deleteItemForUsername:self.settings.tdEmail andServiceName:@"Less2DoToodleDoAccount" error:&error];
+ if (error != nil) {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
+ message:@"Error with Keychain during delete"
+ delegate:self
+ cancelButtonTitle:@"Ok"
+ otherButtonTitles:nil];
+ [alert show];
+ [alert release];
+ }
self.settings.useTDSync = [NSNumber numberWithInt:0];
self.eMail.text = @"";
self.password.text = @"";
View
103 Classes/TaskEditContextViewController.m
@@ -37,8 +37,11 @@ - (void)viewWillAppear:(BOOL)animated {
// pre-check row if task has context set
if (self.task.context != nil) {
NSUInteger idx = [contexts indexOfObject:self.task.context];
- lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:0];
+ lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:1];
+ } else {
+ lastIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
}
+
[super viewWillAppear:animated];
}
@@ -84,62 +87,98 @@ - (void)dealloc {
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
+ return 2;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ if (section == 0)
+ return 1;
+
return [contexts count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"ContextCellInTaskEdit";
- int row = [indexPath row];
-
- UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellID];
+ static NSString *cellIDNoContext = @"ContextCellInTaskEditNoContext";
+
+ UITableViewCell *cell = nil;
+
+ if (indexPath.section == 0) {
+ cell = [aTableView dequeueReusableCellWithIdentifier:cellIDNoContext];
+ } else {
+ cell = [aTableView dequeueReusableCellWithIdentifier:cellID];
+ }
+
+
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];
+ if (indexPath.section == 0) {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIDNoContext] autorelease];
+ } else {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];
+ }
+
cell.textLabel.font = [UIFont boldSystemFontOfSize:FONT_SIZE];
}
// Set up the cell...
- Context *context = (Context *)[contexts objectAtIndex:row];
- cell.textLabel.text = context.name;
- cell.imageView.image = [context hasGps] ? [UIImage imageNamed:@"context_gps.png"] : [UIImage imageNamed:@"context_no_gps.png"];
- cell.accessoryType = [indexPath isEqual:lastIndexPath] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+ if (indexPath.section == 0) {
+ cell.textLabel.text = @"No Context";
+ cell.imageView.image = [UIImage imageNamed:@"no_context.png"];
+ cell.accessoryType = [indexPath isEqual:lastIndexPath] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+ } else {
+ Context *context = (Context *)[contexts objectAtIndex:indexPath.row];
+ cell.textLabel.text = context.name;
+ cell.imageView.image = [context hasGps] ? [UIImage imageNamed:@"context_gps.png"] : [UIImage imageNamed:@"context_no_gps.png"];
+ cell.accessoryType = [indexPath isEqual:lastIndexPath] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+ }
return cell;
}
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- int row = [indexPath row];
- Context *c = (Context *)[contexts objectAtIndex:row];
-
- [addContextControl resignFirstResponder];
-
- if (![indexPath isEqual:lastIndexPath]) {
- UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
- newCell.accessoryType = UITableViewCellAccessoryCheckmark;
-
- UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
- oldCell.accessoryType = UITableViewCellAccessoryNone;
+ if (indexPath.section == 0) {
+ [addContextControl resignFirstResponder];
- lastIndexPath = indexPath;
- self.task.context = c;
-
- if(c.tasks == nil) {
- ALog ("Init new Set for Context-Task");
- [c addTasks:[NSSet setWithObject:self.task]];
+ if (![indexPath isEqual:lastIndexPath]) {
+ UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
+ newCell.accessoryType = UITableViewCellAccessoryCheckmark;
+
+ UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
+ oldCell.accessoryType = UITableViewCellAccessoryNone;
+
+ lastIndexPath = indexPath;
+ self.task.context = nil;
}
- else {
- ALog ("Set exists, added Task");
- [c addTasksObject:self.task];
+ } else {
+ Context *c = (Context *)[contexts objectAtIndex:indexPath.row];
+
+ [addContextControl resignFirstResponder];
+
+ if (![indexPath isEqual:lastIndexPath]) {
+ UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
+ newCell.accessoryType = UITableViewCellAccessoryCheckmark;
+
+ UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
+ oldCell.accessoryType = UITableViewCellAccessoryNone;
+
+ lastIndexPath = indexPath;
+ self.task.context = c;
+
+ if(c.tasks == nil) {
+ ALog ("Init new Set for Context-Task");
+ [c addTasks:[NSSet setWithObject:self.task]];
+ }
+ else {
+ ALog ("Set exists, added Task");
+ [c addTasksObject:self.task];
+ }
}
- }
+ }
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@@ -168,7 +207,7 @@ - (IBAction)addContext:(id)sender {
NSUInteger idx = [contexts indexOfObject:context];
- lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:0];
+ lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:1];
self.addContextControl.text = @"";
[self.tableView reloadData];
View
120 Classes/TaskEditFolderViewController.m
@@ -38,8 +38,11 @@ - (void)viewWillAppear:(BOOL)animated {
// pre-check row if task has folder set
if (self.task.folder != nil) {
NSUInteger idx = [folders indexOfObject:self.task.folder];
- lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:0];
+ lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:1];
+ } else {
+ lastIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
}
+
[super viewWillAppear:animated];
}
@@ -85,69 +88,106 @@ - (void)dealloc {
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
+ return 2;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ if (section == 0)
+ return 1;
+
return [folders count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"FolderCellInTaskEdit";
- int row = [indexPath row];
- Folder *folder = [folders objectAtIndex:row];
+ static NSString *cellIDNoFolder = @"FolderCellInTaskEditNoFolder";
+
+ Folder *folder = nil;
+ UITableViewCell *cell = nil;
- UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellID];
+ if (indexPath.section == 0) {
+ cell = [aTableView dequeueReusableCellWithIdentifier:cellIDNoFolder];
+ } else {
+ cell = [aTableView dequeueReusableCellWithIdentifier:cellID];
+ folder = [folders objectAtIndex:indexPath.row];
+ }
+
// create new cell
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];
-
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(12,12,22,22)];
- imageView.image = [UIImage imageNamed:@"smallWhiteBoarderedButton.png"];
- imageView.tag = TAG_COLOR;
- [cell.contentView addSubview:imageView];
- [imageView release];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(46,10,235,27)];
- label.tag = TAG_FOLDER;
- label.font = [UIFont boldSystemFontOfSize:FONT_SIZE];
- [cell.contentView addSubview:label];
- [label release];
+ if (indexPath.section == 0) {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIDNoFolder] autorelease];
+ } else {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];
+
+ UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(12,12,22,22)];
+ imageView.image = [UIImage imageNamed:@"smallWhiteBoarderedButton.png"];
+ imageView.tag = TAG_COLOR;
+ [cell.contentView addSubview:imageView];
+ [imageView release];
+
+ UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(46,10,235,27)];
+ label.tag = TAG_FOLDER;
+ label.font = [UIFont boldSystemFontOfSize:FONT_SIZE];
+ [cell.contentView addSubview:label];
+ [label release];
+ }
}
// Set up the cell...
- UIView *colorView = [cell.contentView viewWithTag:TAG_COLOR];
- colorView.backgroundColor = [folder color];
-
- UILabel *textLabel = (UILabel *)[cell.contentView viewWithTag:TAG_FOLDER];
- textLabel.text = folder.name;
- cell.accessoryType = [indexPath isEqual:lastIndexPath] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+ if (indexPath.section == 0) {
+ cell.textLabel.text = @"No Folder";
+ cell.imageView.image = [UIImage imageNamed:@"no_folder.png"];
+ cell.accessoryType = [indexPath isEqual:lastIndexPath] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+ } else {
+ UIView *colorView = [cell.contentView viewWithTag:TAG_COLOR];
+ colorView.backgroundColor = [folder color];
+
+ UILabel *textLabel = (UILabel *)[cell.contentView viewWithTag:TAG_FOLDER];
+ textLabel.text = folder.name;
+ cell.accessoryType = [indexPath isEqual:lastIndexPath] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+ }
return cell;
}
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- int row = [indexPath row];
- Folder *f = (Folder *)[folders objectAtIndex:row];
-
- ALog("Selected Folder: %@", f);
- [addFolderControl resignFirstResponder];
-
- if (![indexPath isEqual:lastIndexPath]) {
- UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
- newCell.accessoryType = UITableViewCellAccessoryCheckmark;
-
- UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
- oldCell.accessoryType = UITableViewCellAccessoryNone;
+ if (indexPath.section == 0) {
+ [addFolderControl resignFirstResponder];
- lastIndexPath = indexPath;
- self.task.folder = f;
- }
+ if (![indexPath isEqual:lastIndexPath]) {
+ UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
+ newCell.accessoryType = UITableViewCellAccessoryCheckmark;
+
+ UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
+ oldCell.accessoryType = UITableViewCellAccessoryNone;
+
+ lastIndexPath = indexPath;
+ self.task.folder = nil;
+ }
+
+ } else {
+ int row = [indexPath row];
+ Folder *f = (Folder *)[folders objectAtIndex:row];
+
+ ALog("Selected Folder: %@", f);
+ [addFolderControl resignFirstResponder];
+
+ if (![indexPath isEqual:lastIndexPath]) {
+ UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
+ newCell.accessoryType = UITableViewCellAccessoryCheckmark;
+
+ UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
+ oldCell.accessoryType = UITableViewCellAccessoryNone;
+
+ lastIndexPath = indexPath;
+ self.task.folder = f;
+ }
+ }
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@@ -174,7 +214,7 @@ - (IBAction)addFolder:(id)sender {
self.task.folder = folder;
NSUInteger idx = [folders indexOfObject:folder];
- lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:0];
+ lastIndexPath = [NSIndexPath indexPathForRow:idx inSection:1];
self.addFolderControl.text = @"";
[self.tableView reloadData];

0 comments on commit 9355421

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