From cefe8d144d3e67bcc268420c14c798a30847d5ae Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 11 May 2013 19:43:41 -0400 Subject: [PATCH] Import fix, password type change fix, fancier generator appearance. [FIXED] Import of ubiquity changes was using wrong delegate method and MOC. [FIXED] Password type change broken when password type causes a class change. [IMPROVED] Fancier animation of emergency generator appearance. --- External/Pearl | 2 +- External/UbiquityStoreManager | 2 +- MasterPassword/ObjC/MPAppDelegate_Store.m | 6 +++--- MasterPassword/ObjC/iOS/MPMainViewController.m | 10 ++++++++-- MasterPassword/ObjC/iOS/MPTypeViewController.m | 4 +++- .../ObjC/iOS/MPUnlockViewController.m | 18 ++++++++++++++++-- .../ObjC/iOS/MainStoryboard_iPhone.storyboard | 4 ++-- 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/External/Pearl b/External/Pearl index c2b07f9c..a2a43a63 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit c2b07f9c648fd6386aca0c982b44769bb36ac4b3 +Subproject commit a2a43a63e26a110ebd130c918b8a47b41b20ae99 diff --git a/External/UbiquityStoreManager b/External/UbiquityStoreManager index 389c8b78..8c7d9d62 160000 --- a/External/UbiquityStoreManager +++ b/External/UbiquityStoreManager @@ -1 +1 @@ -Subproject commit 389c8b78501331af77c363857f381a497cbf0060 +Subproject commit 8c7d9d629ef4f8ad26f1cd3f8012687f311a7c71 diff --git a/MasterPassword/ObjC/MPAppDelegate_Store.m b/MasterPassword/ObjC/MPAppDelegate_Store.m index 657006ae..71038350 100644 --- a/MasterPassword/ObjC/MPAppDelegate_Store.m +++ b/MasterPassword/ObjC/MPAppDelegate_Store.m @@ -316,9 +316,9 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext, #pragma mark - UbiquityStoreManagerDelegate -- (NSManagedObjectContext *)managedObjectContextForUbiquityStoreManager:(UbiquityStoreManager *)usm { +- (NSManagedObjectContext *)managedObjectContextForUbiquityChangesInManager:(UbiquityStoreManager *)manager { - return [self privateManagedObjectContextIfReady]; + return [self mainManagedObjectContextIfReady]; } - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager log:(NSString *)message { @@ -328,7 +328,7 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext, - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager willLoadStoreIsCloud:(BOOL)isCloudStore { - NSManagedObjectContext *moc = self.mainManagedObjectContextIfReady; + NSManagedObjectContext *moc = [self mainManagedObjectContextIfReady]; [moc performBlockAndWait:^{ [moc saveToStore]; diff --git a/MasterPassword/ObjC/iOS/MPMainViewController.m b/MasterPassword/ObjC/iOS/MPMainViewController.m index a08ae4d1..7c65215a 100644 --- a/MasterPassword/ObjC/iOS/MPMainViewController.m +++ b/MasterPassword/ObjC/iOS/MPMainViewController.m @@ -598,6 +598,8 @@ NSString *oldPassword = [activeElement.content description]; if (!task( activeElement, context )) return; + + activeElement = [self activeElementInContext:context]; NSString *newPassword = [activeElement.content description]; // Save. @@ -787,11 +789,15 @@ @"If you continue, the password for this site will change. " @"You will need to update your account's old password to the new one." do:^BOOL(MPElementEntity *activeElement, NSManagedObjectContext *context) { - if ([activeElement.algorithm classOfType:type] != activeElement.typeClass) { + if ([activeElement.algorithm classOfType:type] == activeElement.typeClass) + activeElement.type = type; + + else { // Type requires a different class of element. Recreate the element. MPElementEntity *newElement = [NSEntityDescription insertNewObjectForEntityForName:[activeElement.algorithm classNameOfType:type] inManagedObjectContext:context]; + newElement.type = type; newElement.name = activeElement.name; newElement.user = activeElement.user; newElement.uses = activeElement.uses; @@ -800,6 +806,7 @@ newElement.loginName = activeElement.loginName; [context deleteObject:activeElement]; + [context saveToStore]; NSError *error; if (![context obtainPermanentIDsForObjects:@[ newElement ] error:&error]) @@ -808,7 +815,6 @@ _activeElementOID = newElement.objectID; activeElement = newElement; } - activeElement.type = type; [[NSNotificationCenter defaultCenter] postNotificationName:MPElementUpdatedNotification object:activeElement.objectID]; diff --git a/MasterPassword/ObjC/iOS/MPTypeViewController.m b/MasterPassword/ObjC/iOS/MPTypeViewController.m index 0217b5a4..b7780462 100644 --- a/MasterPassword/ObjC/iOS/MPTypeViewController.m +++ b/MasterPassword/ObjC/iOS/MPTypeViewController.m @@ -77,7 +77,9 @@ [(UITextField *)[cell viewWithTag:2] setText:@"..."]; NSString *name = selectedElement.name; - NSUInteger counter = ((MPElementGeneratedEntity *)selectedElement).counter; + NSUInteger counter = 0; + if ([selectedElement isKindOfClass:[MPElementGeneratedEntity class]]) + counter = ((MPElementGeneratedEntity *)selectedElement).counter; dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0 ), ^{ NSString *typeContent = [MPAlgorithmDefault generateContentNamed:name ofType:cellType diff --git a/MasterPassword/ObjC/iOS/MPUnlockViewController.m b/MasterPassword/ObjC/iOS/MPUnlockViewController.m index 06509e4d..5ac1b379 100644 --- a/MasterPassword/ObjC/iOS/MPUnlockViewController.m +++ b/MasterPassword/ObjC/iOS/MPUnlockViewController.m @@ -8,6 +8,7 @@ #import #import +#import #import "MPUnlockViewController.h" #import "MPiOSAppDelegate.h" @@ -209,6 +210,8 @@ - (void)viewDidAppear:(BOOL)animated { + [self becomeFirstResponder]; + if (!animated && !self.navigationController.presentedViewController) [[self findTargetedAvatar] setSelected:YES]; else @@ -254,10 +257,21 @@ self.emergencyGeneratorContainer.alpha = 0; self.emergencyGeneratorContainer.hidden = NO; - [UIView animateWithDuration:0.5 animations:^{ + self.emergencyGeneratorContainer.frame = CGRectSetX( self.emergencyGeneratorContainer.frame, + self.emergencyGeneratorContainer.frame.origin.x - 100 ); + [UIView animateWithDuration:0.3 animations:^{ + self.emergencyGeneratorContainer.frame = CGRectSetX( self.emergencyGeneratorContainer.frame, + self.emergencyGeneratorContainer.frame.origin.x + 150 ); self.emergencyGeneratorContainer.alpha = 1; } completion:^(BOOL finished) { + if (!finished) + return; + [self.emergencyName becomeFirstResponder]; + [UIView animateWithDuration:0.2 animations:^{ + self.emergencyGeneratorContainer.frame = CGRectSetX( self.emergencyGeneratorContainer.frame, + self.emergencyGeneratorContainer.frame.origin.x - 50 ); + }]; }]; } } @@ -925,7 +939,7 @@ [[self.emergencyGeneratorContainer findFirstResponderInHierarchy] resignFirstResponder]; if (animated) { - [UIView animateWithDuration:0.5 animations:^{ + [UIView animateWithDuration:0.2 animations:^{ self.emergencyGeneratorContainer.alpha = 0; } completion:^(BOOL finished) { [self emergencyCloseAnimated:NO]; diff --git a/MasterPassword/ObjC/iOS/MainStoryboard_iPhone.storyboard b/MasterPassword/ObjC/iOS/MainStoryboard_iPhone.storyboard index f2e2ad39..0bf4acad 100644 --- a/MasterPassword/ObjC/iOS/MainStoryboard_iPhone.storyboard +++ b/MasterPassword/ObjC/iOS/MainStoryboard_iPhone.storyboard @@ -1549,11 +1549,11 @@ You could use the word wall for inspiration in finding a memorable master passw