From d4adafb44848a8256fc331517097e7fc1764c0ff Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Fri, 15 Jun 2012 11:16:02 +0200 Subject: [PATCH] Reset from unlock, FAQ improvements. [ADDED] Ability to reset a master password from the unlock screen. [FIXED] Manually retain objects that live next to a VC in a storyboard within the VC to avoid an OS bug. [FIXED] Visibility of the deleteTip. [ADDED] An index to the FAQ. [IMPROVED] Improved and expanded the FAQ a bit more. --- MasterPassword/MPAppDelegate_Key.m | 9 +- MasterPassword/iOS/MPAppDelegate.h | 2 +- MasterPassword/iOS/MPAppDelegate.m | 10 +- MasterPassword/iOS/MPMainViewController.h | 1 + MasterPassword/iOS/MPMainViewController.m | 2 + .../iOS/MPPreferencesViewController.m | 2 +- MasterPassword/iOS/MPUnlockViewController.h | 3 +- MasterPassword/iOS/MPUnlockViewController.m | 37 ++-- .../iOS/MainStoryboard_iPhone.storyboard | 14 +- Resources/help.html | 180 ++++++++++-------- 10 files changed, 145 insertions(+), 115 deletions(-) diff --git a/MasterPassword/MPAppDelegate_Key.m b/MasterPassword/MPAppDelegate_Key.m index 7631d752..a6b075f7 100644 --- a/MasterPassword/MPAppDelegate_Key.m +++ b/MasterPassword/MPAppDelegate_Key.m @@ -75,10 +75,13 @@ static NSDictionary *keyQuery(MPUserEntity *user) { - (void)signOut { - self.key = nil; - self.activeUser = nil; + if (self.key) + self.key = nil; - [[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationSignedOut object:self]; + if (self.activeUser) { + self.activeUser = nil; + [[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationSignedOut object:self]; + } } - (BOOL)signInAsUser:(MPUserEntity *)user usingMasterPassword:(NSString *)password { diff --git a/MasterPassword/iOS/MPAppDelegate.h b/MasterPassword/iOS/MPAppDelegate.h index 6e508949..5628d9ef 100644 --- a/MasterPassword/iOS/MPAppDelegate.h +++ b/MasterPassword/iOS/MPAppDelegate.h @@ -18,6 +18,6 @@ - (void)showGuide; - (void)export; -- (void)changeMP; +- (void)changeMasterPasswordFor:(MPUserEntity *)user; @end diff --git a/MasterPassword/iOS/MPAppDelegate.m b/MasterPassword/iOS/MPAppDelegate.m index e50837c9..a9dc204c 100644 --- a/MasterPassword/iOS/MPAppDelegate.m +++ b/MasterPassword/iOS/MPAppDelegate.m @@ -331,7 +331,7 @@ [TestFlight passCheckpoint:MPCheckpointDeactivated]; } -#pragma - mark Behavior +#pragma mark - Behavior - (void)checkConfig { @@ -452,7 +452,7 @@ [self.window.rootViewController presentModalViewController:composer animated:YES]; } -- (void)changeMP { +- (void)changeMasterPasswordFor:(MPUserEntity *)user { [PearlAlert showAlertWithTitle:@"Changing Master Password" message: @@ -464,9 +464,9 @@ if (buttonIndex == [alert cancelButtonIndex]) return; - inf(@"Unsetting master password for: %@.", self.activeUser.userID); - self.activeUser.keyID = nil; - [self forgetSavedKeyFor:self.activeUser]; + inf(@"Unsetting master password for: %@.", user.userID); + user.keyID = nil; + [self forgetSavedKeyFor:user]; [self signOut]; [TestFlight passCheckpoint:MPCheckpointChangeMP]; diff --git a/MasterPassword/iOS/MPMainViewController.h b/MasterPassword/iOS/MPMainViewController.h index 41c70f24..daf51db9 100644 --- a/MasterPassword/iOS/MPMainViewController.h +++ b/MasterPassword/iOS/MPMainViewController.h @@ -33,6 +33,7 @@ @property (weak, nonatomic) IBOutlet UIView *searchTipContainer; @property (weak, nonatomic) IBOutlet UIView *actionsTipContainer; @property (weak, nonatomic) IBOutlet UIView *typeTipContainer; +@property (strong, nonatomic) IBOutlet UILongPressGestureRecognizer *resetPasswordCounterGesture; @property (copy) void (^contentTipCleanup)(BOOL finished); diff --git a/MasterPassword/iOS/MPMainViewController.m b/MasterPassword/iOS/MPMainViewController.m index 75b29ccf..c671b2b7 100644 --- a/MasterPassword/iOS/MPMainViewController.m +++ b/MasterPassword/iOS/MPMainViewController.m @@ -43,6 +43,7 @@ @synthesize searchTipContainer = _searchTipContainer; @synthesize actionsTipContainer = _actionsTipContainer; @synthesize typeTipContainer = _typeTipContainer; +@synthesize resetPasswordCounterGesture = _resetPasswordCounterGesture; @synthesize contentField = _contentField; @synthesize contentTipCleanup; @@ -149,6 +150,7 @@ [self setSearchTipContainer:nil]; [self setActionsTipContainer:nil]; [self setTypeTipContainer:nil]; + [self setResetPasswordCounterGesture:nil]; [super viewDidUnload]; } diff --git a/MasterPassword/iOS/MPPreferencesViewController.m b/MasterPassword/iOS/MPPreferencesViewController.m index 59b36e04..040245bd 100644 --- a/MasterPassword/iOS/MPPreferencesViewController.m +++ b/MasterPassword/iOS/MPPreferencesViewController.m @@ -119,7 +119,7 @@ else if (cell == self.changeMPCell) - [[MPAppDelegate get] changeMP]; + [[MPAppDelegate get] changeMasterPasswordFor:[MPAppDelegate get].activeUser]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; } diff --git a/MasterPassword/iOS/MPUnlockViewController.h b/MasterPassword/iOS/MPUnlockViewController.h index 267cc621..23fd683a 100644 --- a/MasterPassword/iOS/MPUnlockViewController.h +++ b/MasterPassword/iOS/MPUnlockViewController.h @@ -20,9 +20,10 @@ @property (weak, nonatomic) IBOutlet UILabel *deleteTip; @property (weak, nonatomic) IBOutlet UIView *passwordTipView; @property (weak, nonatomic) IBOutlet UILabel *passwordTipLabel; +@property (strong, nonatomic) IBOutlet UILongPressGestureRecognizer *targetedUserActionGesture; @property (nonatomic, strong) UIColor *avatarShadowColor; -- (IBAction)deleteTargetedUser:(UILongPressGestureRecognizer *)sender; +- (IBAction)targetedUserAction:(UILongPressGestureRecognizer *)sender; @end diff --git a/MasterPassword/iOS/MPUnlockViewController.m b/MasterPassword/iOS/MPUnlockViewController.m index a3dfb33b..e6661343 100644 --- a/MasterPassword/iOS/MPUnlockViewController.m +++ b/MasterPassword/iOS/MPUnlockViewController.m @@ -32,6 +32,7 @@ @synthesize deleteTip; @synthesize passwordTipView; @synthesize passwordTipLabel; +@synthesize targetedUserActionGesture; @synthesize avatarShadowColor = _avatarShadowColor; @@ -137,6 +138,7 @@ [self setDeleteTip:nil]; [self setPasswordTipView:nil]; [self setPasswordTipLabel:nil]; + [self setTargetedUserActionGesture:nil]; [super viewDidUnload]; } @@ -356,7 +358,7 @@ self.nameLabel.backgroundColor = [UIColor clearColor]; self.oldNameLabel.center = self.nameLabel.center; self.avatarShadowColor = [UIColor lightGrayColor]; - self.deleteTip.alpha = [self.avatarToUser count] > 2? 1: 0; + self.deleteTip.alpha = 0.5; } MPUserEntity *targetedUser = self.selectedUser; @@ -590,13 +592,11 @@ *targetContentOffset = CGPointMake(middleAvatar.center.x - scrollView.bounds.size.width / 2, targetContentOffset->y); [self updateLayoutAnimated:NO allowScroll:NO completion:nil]; - // [self scrollToAvatar:middleAvatar animated:YES]; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self updateLayoutAnimated:YES allowScroll:YES completion:nil]; - // [self scrollToAvatar:middleAvatar animated:YES]; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { @@ -606,7 +606,7 @@ #pragma mark - IBActions -- (IBAction)deleteTargetedUser:(UILongPressGestureRecognizer *)sender { +- (IBAction)targetedUserAction:(UILongPressGestureRecognizer *)sender { if (sender.state != UIGestureRecognizerStateBegan) return; @@ -617,19 +617,24 @@ MPUserEntity *targetedUser = [self userForAvatar:[self findTargetedAvatar]]; if (!targetedUser) return; - - [PearlAlert showAlertWithTitle:@"Delete User" message: - PearlString(@"Do you want to delete all record of the following user?\n\n%@", - targetedUser.name) + + [PearlAlert showAlertWithTitle:@"Delete Or Reset User" + message: + PearlString(@"Do you want to reset the master password or delete all record of the following user?\n\n%@", + targetedUser.name) viewStyle:UIAlertViewStyleDefault initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { - if (buttonIndex == [alert cancelButtonIndex]) - return; - - [[MPAppDelegate get].managedObjectContext deleteObject:targetedUser]; - [[MPAppDelegate get] saveContext]; - - [self updateUsers]; - } cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Delete", nil]; + if (buttonIndex == [alert cancelButtonIndex]) + return; + + if (buttonIndex == [alert firstOtherButtonIndex]) { + [[MPAppDelegate get].managedObjectContext deleteObject:targetedUser]; + [[MPAppDelegate get] saveContext]; + [self updateUsers]; + } else if (buttonIndex == [alert firstOtherButtonIndex] + 1) { + [[MPAppDelegate get] changeMasterPasswordFor:targetedUser]; + } + + } cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Delete", @"Reset", nil]; } @end diff --git a/MasterPassword/iOS/MainStoryboard_iPhone.storyboard b/MasterPassword/iOS/MainStoryboard_iPhone.storyboard index 78f19fb4..1ec72c70 100644 --- a/MasterPassword/iOS/MainStoryboard_iPhone.storyboard +++ b/MasterPassword/iOS/MainStoryboard_iPhone.storyboard @@ -734,6 +734,7 @@ L4m3P4sSw0rD + @@ -919,9 +920,9 @@ L4m3P4sSw0rD -