2
0

Fix some UI issues, mostly with alerts.

[FIXED]     Schedule all UI-changing methods on the main thread.  Fixes
            some UI bugs.
[FIXED]     Attempt to calculate password for deleted element.
[FIXED]     MP-6: Close open alert when switching sites.
[FIXED]     MP-7: Remind user to change site's password when creating a
            new site.
This commit is contained in:
Maarten Billemont 2012-03-11 11:14:28 +01:00
parent fa3680f9c4
commit 0c536ef640
5 changed files with 95 additions and 78 deletions

View File

@ -57,6 +57,11 @@
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction

View File

@ -19,6 +19,6 @@
@property (nonatomic, assign) NSTimeInterval lastUsed;
@property (nonatomic, retain, readonly) id content;
- (void)use;
- (int16_t)use;
@end

View File

@ -17,10 +17,10 @@
@dynamic uses;
@dynamic lastUsed;
- (void)use {
- (int16_t)use {
++self.uses;
self.lastUsed = [[NSDate date] timeIntervalSinceReferenceDate];
return ++self.uses;
}
- (id)content {

View File

@ -27,7 +27,7 @@
[MPiOSConfig get];
#ifdef DEBUG
[PearlLogger get].autoprintLevel = PearlLogLevelTrace;
[PearlLogger get].autoprintLevel = PearlLogLevelDebug;
[NSClassFromString(@"WebView") performSelector:@selector(_enableRemoteInspector)];
#endif
}

View File

@ -109,17 +109,7 @@
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
if (![MPAppDelegate get].key) {
self.activeElement = nil;
[self updateAnimated:NO];
}
}];
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
if (![MPAppDelegate get].key) {
self.activeElement = nil;
[self updateAnimated:NO];
}
}];
self.alertBody.text = nil;
@ -154,12 +144,14 @@
[[MPAppDelegate get] saveContext];
dispatch_async(dispatch_get_main_queue(), ^{
if (animated)
[UIView animateWithDuration:0.3f animations:^{
[self updateWasAnimated:animated];
}];
else
[self updateWasAnimated:animated];
});
}
- (void)updateWasAnimated:(BOOL)animated {
@ -180,6 +172,8 @@
if ([self.activeElement isKindOfClass:[MPElementGeneratedEntity class]])
self.passwordCounter.text = [NSString stringWithFormat:@"%u", ((MPElementGeneratedEntity *) self.activeElement).counter];
self.contentField.text = @"";
if (self.activeElement.name && ![self.activeElement isDeleted])
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSString *description = [self.activeElement description];
@ -201,6 +195,7 @@
- (void)setHelpHidden:(BOOL)hidden animated:(BOOL)animated {
dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
if (hidden) {
self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, self.view.bounds.size.height - 44);
@ -212,6 +207,7 @@
[MPiOSConfig get].helpHidden = [NSNumber numberWithBool:NO];
}
}];
});
}
- (void)setHelpChapter:(NSString *)chapter {
@ -220,6 +216,7 @@
[TestFlight passCheckpoint:[NSString stringWithFormat:MPTestFlightCheckpointHelpChapter, chapter]];
#endif
dispatch_async(dispatch_get_main_queue(), ^{
[self.helpView loadRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:[NSString stringWithFormat:@"#%@", chapter] relativeToURL:
@ -229,10 +226,12 @@
ClassNameFromMPElementType(self.activeElement.type)]];
if (error.length)
err(@"setClass: %@", error);
});
}
- (void)showContentTip:(NSString *)message withIcon:(UIImageView *)icon {
dispatch_async(dispatch_get_main_queue(), ^{
self.contentTipBody.text = message;
icon.hidden = NO;
@ -251,10 +250,12 @@
});
}
}];
});
}
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message {
dispatch_async(dispatch_get_main_queue(), ^{
self.alertTitle.text = title;
NSRange scrollRange = NSMakeRange(self.alertBody.text.length, message.length);
if ([self.alertBody.text length])
@ -266,6 +267,7 @@
[UIView animateWithDuration:0.2f animations:^{
self.alertContainer.alpha = 1;
}];
});
}
#pragma mark - Protocols
@ -333,6 +335,7 @@
[UIView animateWithDuration:0.3f animations:^{
self.alertContainer.alpha = 0;
} completion:^(BOOL finished) {
if (finished)
self.alertBody.text = nil;
}];
@ -429,9 +432,18 @@
- (void)didSelectElement:(MPElementEntity *)element {
[self closeAlert];
if (element) {
self.activeElement = element;
[self.activeElement use];
if ([self.activeElement use] == 1)
[self showAlertWithTitle:@"New Site" message:
l(@"You've just created a password for %@.\n\n"
@"IMPORTANT:\n"
@"Don't forget to set or change the password for your account at %@ to the password above. "
@"It's best to do this right away. If you forget it, may get confusing later on "
@"to remember what password you need to use for logging into the site.",
self.activeElement.name, self.activeElement.name)];
[self.searchDisplayController setActive:NO animated:YES];
self.searchDisplayController.searchBar.text = self.activeElement.name;