From f1d8c95336945de0fd126cfce98708870ecfc357 Mon Sep 17 00:00:00 2001 From: Simone Manganelli Date: Wed, 22 Jul 2009 17:04:44 -0700 Subject: [PATCH] badge text now includes an ellipsis if it's still checking for H.264 variants; extra contextual items now appear if H.264 is confirmed but HD H.264 is still being checked --- Plugin/Plugin.h | 1 + Plugin/Plugin.m | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Plugin/Plugin.h b/Plugin/Plugin.h index 02006337..c3c8752d 100755 --- a/Plugin/Plugin.h +++ b/Plugin/Plugin.h @@ -54,6 +54,7 @@ THE SOFTWARE. NSString *_launchedAppBundleIdentifier; BOOL _contextMenuIsVisible; + BOOL _receivedAllResponses; NSURLConnection *connections[2]; unsigned expectedResponses; NSTimer *_delayingTimer; diff --git a/Plugin/Plugin.m b/Plugin/Plugin.m index 3111e785..474c21e0 100755 --- a/Plugin/Plugin.m +++ b/Plugin/Plugin.m @@ -751,21 +751,30 @@ - (void) _loadInvisibleContentForWindow: (NSNotification*) notification - (NSString*) badgeLabelText { - if( [ self _useHDH264Version ] && [self _hasHDH264Version]) + if( [ self _useHDH264Version ] && [self _hasHDH264Version]) { return NSLocalizedString( @"HD H.264", @"HD H.264 badge text" ); - if( [ self _useH264Version ] && [self _hasH264Version]) - return NSLocalizedString( @"H.264", @"H.264 badge text" ); - else if( _fromYouTube && _videoId) + } else if( [ self _useH264Version ] && [self _hasH264Version]) { + if (_receivedAllResponses) { + return NSLocalizedString( @"H.264", @"H.264 badge text" ); + } else { + return NSLocalizedString( @"H.264…", @"H.264 badge waiting text" ); + } + } else if( _fromYouTube && _videoId) { // we check the video ID too because if it's a flash ad on YouTube.com, // we don't want to identify it as an actual YouTube video -- but if // the flash object actually has a video ID parameter, it means its // a bona fide YouTube video - return NSLocalizedString( @"YouTube", @"YouTube badge text" ); - else if( _badgeText ) + if (_receivedAllResponses) { + return NSLocalizedString( @"YouTube", @"YouTube badge text" ); + } else { + return NSLocalizedString( @"YouTube…", @"YouTube badge waiting text" ); + } + } else if( _badgeText ) { return _badgeText; - else + } else { return NSLocalizedString( @"Flash", @"Flash badge text" ); + } } - (void) _drawBadgeWithPressed: (BOOL) pressed @@ -1158,12 +1167,13 @@ - (void)_checkForH264VideoVariants } expectedResponses = 2; + _receivedAllResponses = NO; } } - (void)finishedWithConnection:(NSURLConnection *)connection { - BOOL receivedAllResponses = YES; + BOOL didReceiveAllResponses = YES; for (int i = 0; i < 2; ++i) { if (connection == connections[i]) { @@ -1171,11 +1181,13 @@ - (void)finishedWithConnection:(NSURLConnection *)connection [connection release]; connections[i] = nil; } else if (connections[i]) - receivedAllResponses = NO; + didReceiveAllResponses = NO; } - if (receivedAllResponses) - [self setUpExtraMenuItems]; + if (didReceiveAllResponses) _receivedAllResponses = YES; + + [self setUpExtraMenuItems]; + [self setNeedsDisplay:YES]; } - (void)connection:(NSURLConnection *)connection