2
0

Pearl update + search tip.

[ADDED]     A tip when searching for sites suggesting a site name
            format for sites and email accounts.
This commit is contained in:
Maarten Billemont 2012-05-15 23:27:05 +02:00
parent ada6d6b36a
commit 2020637f0e
7 changed files with 58 additions and 28 deletions

2
External/Pearl vendored

@ -1 +1 @@
Subproject commit 80c57a94fdcafb90cccd7371b175a5c56ac7571f
Subproject commit c07a0e24f061a4e4bb822c0763827c5b7f0efc21

View File

@ -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);

View File

@ -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

View File

@ -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
}

View File

@ -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;

View File

@ -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<MPSearchResultsDelegate> delegate;
@property (weak, nonatomic) IBOutlet UISearchDisplayController *searchDisplayController;

View File

@ -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];