From 2020637f0e2393191d37a8a255ca670ed7267caf Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Tue, 15 May 2012 23:27:05 +0200 Subject: [PATCH] Pearl update + search tip. [ADDED] A tip when searching for sites suggesting a site name format for sites and email accounts. --- External/Pearl | 2 +- MasterPassword/MPAppDelegate_Store.m | 2 +- MasterPassword/MPElementEntity.m | 6 ++-- MasterPassword/iOS/MPAppDelegate.m | 14 ++++---- MasterPassword/iOS/MPMainViewController.m | 22 ++++++------- MasterPassword/iOS/MPSearchDelegate.h | 1 + MasterPassword/iOS/MPSearchDelegate.m | 39 ++++++++++++++++++++--- 7 files changed, 58 insertions(+), 28 deletions(-) diff --git a/External/Pearl b/External/Pearl index 80c57a94..c07a0e24 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit 80c57a94fdcafb90cccd7371b175a5c56ac7571f +Subproject commit c07a0e24f061a4e4bb822c0763827c5b7f0efc21 diff --git a/MasterPassword/MPAppDelegate_Store.m b/MasterPassword/MPAppDelegate_Store.m index c0fd7dd1..70237366 100644 --- a/MasterPassword/MPAppDelegate_Store.m +++ b/MasterPassword/MPAppDelegate_Store.m @@ -195,7 +195,7 @@ static NSDateFormatter *rfc3339DateFormatter = nil; - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause context:(id)context { #ifdef TESTFLIGHT_SDK_VERSION - [TestFlight passCheckpoint:str(@"MPTestFlightCheckpointMPErrorUbiquity_%d", cause)]; + [TestFlight passCheckpoint:PearlString(@"MPTestFlightCheckpointMPErrorUbiquity_%d", cause)]; #endif err(@"StoreManager: cause=%d, context=%@, error=%@", cause, context, error); diff --git a/MasterPassword/MPElementEntity.m b/MasterPassword/MPElementEntity.m index 84349155..ce530ec4 100644 --- a/MasterPassword/MPElementEntity.m +++ b/MasterPassword/MPElementEntity.m @@ -39,13 +39,13 @@ - (NSString *)description { - return str(@"%@:%@", [self class], [self name]); + return PearlString(@"%@:%@", [self class], [self name]); } - (NSString *)debugDescription { - return str(@"{%@: name=%@, keyID=%@, type=%d, uses=%d, lastUsed=%@}", - NSStringFromClass([self class]), self.name, self.keyID, self.type, self.uses, self.lastUsed); + return PearlString(@"{%@: name=%@, keyID=%@, type=%d, uses=%d, lastUsed=%@}", + NSStringFromClass([self class]), self.name, self.keyID, self.type, self.uses, self.lastUsed); } @end diff --git a/MasterPassword/iOS/MPAppDelegate.m b/MasterPassword/iOS/MPAppDelegate.m index 3b5d446b..40389c00 100644 --- a/MasterPassword/iOS/MPAppDelegate.m +++ b/MasterPassword/iOS/MPAppDelegate.m @@ -299,7 +299,7 @@ dispatch_group_enter(confirmationGroup); dispatch_async(dispatch_get_main_queue(), ^{ [PearlAlert showAlertWithTitle:@"Import Sites?" - message:l(@"Import %d sites, overwriting %d existing sites?", importCount, deleteCount) + message:PearlLocalize(@"Import %d sites, overwriting %d existing sites?", importCount, deleteCount) viewStyle:UIAlertViewStyleDefault tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { if (buttonIndex != [alert cancelButtonIndex]) @@ -426,7 +426,7 @@ @"It is highly recommended you enable iCloud." viewStyle:UIAlertViewStyleDefault tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { [MPConfig get].iCloudDecided = [NSNumber numberWithBool:YES]; - + if (buttonIndex == [alert cancelButtonIndex]) return; @@ -471,7 +471,7 @@ - (NSString *)testFlightToken { - return NSNullToNil([[self testFlightInfo] valueForKeyPath:@"Team Token"]); + return NullToNil([[self testFlightInfo] valueForKeyPath:@"Team Token"]); } @@ -490,7 +490,7 @@ - (NSString *)crashlyticsAPIKey { - return NSNullToNil([[self crashlyticsInfo] valueForKeyPath:@"API Key"]); + return NullToNil([[self crashlyticsInfo] valueForKeyPath:@"API Key"]); } @@ -510,11 +510,11 @@ - (NSString *)localyticsKey { #ifdef DEBUG - return NSNullToNil([[self localyticsInfo] valueForKeyPath:@"Key.development"]); + return NullToNil([[self localyticsInfo] valueForKeyPath:@"Key.development"]); #elif defined(LITE) - return NSNullToNil([[self localyticsInfo] valueForKeyPath:@"Key.distribution.lite"]); + return NullToNil([[self localyticsInfo] valueForKeyPath:@"Key.distribution.lite"]); #else - return NSNullToNil([[self localyticsInfo] valueForKeyPath:@"Key.distribution"]); + return NullToNil([[self localyticsInfo] valueForKeyPath:@"Key.distribution"]); #endif } diff --git a/MasterPassword/iOS/MPMainViewController.m b/MasterPassword/iOS/MPMainViewController.m index 2dd97e18..9b813451 100644 --- a/MasterPassword/iOS/MPMainViewController.m +++ b/MasterPassword/iOS/MPMainViewController.m @@ -357,11 +357,11 @@ // Show new and old password. if ([oldPassword length] && ![oldPassword isEqualToString:newPassword]) - [self showAlertWithTitle:@"Password Changed!" message:l(@"The password for %@ has changed.\n\n" - @"IMPORTANT:\n" - @"Don't forget to update the site with your new password! " - @"Your old password was:\n" - @"%@", self.activeElement.name, oldPassword)]; + [self showAlertWithTitle:@"Password Changed!" message:PearlLocalize(@"The password for %@ has changed.\n\n" + @"IMPORTANT:\n" + @"Don't forget to update the site with your new password! " + @"Your old password was:\n" + @"%@", self.activeElement.name, oldPassword)]; } @@ -486,13 +486,13 @@ self.activeElement = element; if ([self.activeElement use] == 1) [self showAlertWithTitle:@"New Site" message: - l(@"You've just created a password for %@.\n\n" - @"IMPORTANT:\n" - @"Go to %@ and set or change the password for your account to the password above.\n" - @"Do this right away: if you forget, you may have trouble remembering which password to use to log into the site later on.", - self.activeElement.name, self.activeElement.name)]; + PearlLocalize(@"You've just created a password for %@.\n\n" + @"IMPORTANT:\n" + @"Go to %@ and set or change the password for your account to the password above.\n" + @"Do this right away: if you forget, you may have trouble remembering which password to use to log into the site later on.", + self.activeElement.name, self.activeElement.name)]; [[MPAppDelegate get] saveContext]; - + [self.searchDisplayController setActive:NO animated:YES]; self.searchDisplayController.searchBar.text = self.activeElement.name; diff --git a/MasterPassword/iOS/MPSearchDelegate.h b/MasterPassword/iOS/MPSearchDelegate.h index 059f8823..71725733 100644 --- a/MasterPassword/iOS/MPSearchDelegate.h +++ b/MasterPassword/iOS/MPSearchDelegate.h @@ -20,6 +20,7 @@ @property (strong, nonatomic) NSDateFormatter *dateFormatter; @property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController; @property (strong, nonatomic) NSString *query; +@property (strong, nonatomic) UILabel *tipView; @property (weak, nonatomic) IBOutlet id delegate; @property (weak, nonatomic) IBOutlet UISearchDisplayController *searchDisplayController; diff --git a/MasterPassword/iOS/MPSearchDelegate.m b/MasterPassword/iOS/MPSearchDelegate.m index 3643cbe5..842d2e79 100644 --- a/MasterPassword/iOS/MPSearchDelegate.m +++ b/MasterPassword/iOS/MPSearchDelegate.m @@ -19,6 +19,7 @@ @end @implementation MPSearchDelegate +@synthesize tipView; @synthesize query; @synthesize dateFormatter; @synthesize fetchedResultsController; @@ -38,10 +39,26 @@ NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])]; fetchRequest.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"uses" ascending:NO]]; self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest - managedObjectContext:[MPAppDelegate managedObjectContext] - sectionNameKeyPath:nil cacheName:nil]; + managedObjectContext:[MPAppDelegate managedObjectContext] + sectionNameKeyPath:nil cacheName:nil]; self.fetchedResultsController.delegate = self; + self.tipView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 170)]; + self.tipView.textAlignment = UITextAlignmentCenter; + self.tipView.backgroundColor = [UIColor clearColor]; + self.tipView.textColor = [UIColor lightTextColor]; + self.tipView.shadowColor = [UIColor blackColor]; + self.tipView.shadowOffset = CGSizeMake(0, -1); + self.tipView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin; + self.tipView.numberOfLines = 0; + self.tipView.font = [UIFont systemFontOfSize:14]; + self.tipView.text = + @"Tip:\n" + @"Name your sites by their domain name:\n" + @"apple.com, twitter.com\n\n" + @"For email accounts, use the address:\n" + @"john@apple.com, john@gmail.com"; + return self; } @@ -78,7 +95,7 @@ - (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { - controller.searchBar.prompt = @"Enter the site's name (eg. apple.com):"; + controller.searchBar.prompt = @"Enter the site's name:"; [UIView animateWithDuration:0.2f animations:^{ self.searchTipContainer.alpha = 0; @@ -123,6 +140,18 @@ if (![self.fetchedResultsController performFetch:&error]) err(@"Couldn't fetch elements: %@", error); [self.searchDisplayController.searchResultsTableView reloadData]; + + NSArray *subviews = self.searchDisplayController.searchBar.superview.subviews; + UIView *overlay = [subviews objectAtIndex:[subviews indexOfObject:self.searchDisplayController.searchBar] + 1]; + if (self.tipView.superview != overlay && overlay != self.searchDisplayController.searchResultsTableView) { + [self.tipView removeFromSuperview]; + [overlay addSubview:self.tipView]; + } + + //dbg(@"Superviews of superview:"); + //[self.searchDisplayController.searchBar.superview printSuperHierarchy]; + //dbg(@"Subviews of superview:"); + //[self.searchDisplayController.searchBar.superview printChildHierarchy]; } // See MP-14, also crashes easily on internal assertions etc.. @@ -181,7 +210,7 @@ - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { [self.searchDisplayController.searchResultsTableView reloadData]; -// [self.searchDisplayController.searchResultsTableView endUpdates]; + // [self.searchDisplayController.searchResultsTableView endUpdates]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { @@ -271,7 +300,7 @@ // "New" section. NSString *siteName = self.query; [PearlAlert showAlertWithTitle:@"New Site" - message:l(@"Do you want to create a new site named:\n%@", siteName) + message:PearlLocalize(@"Do you want to create a new site named:\n%@", siteName) viewStyle:UIAlertViewStyleDefault tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { [tableView deselectRowAtIndexPath:indexPath animated:YES];