From: Jay Freeman (saurik) Date: Tue, 4 Feb 2014 21:39:59 +0000 (-0800) Subject: Use notification observers to update media style. X-Git-Tag: v0.9.4011~3 X-Git-Url: https://git.saurik.com/cydget.git/commitdiff_plain/ef2f1af2826d54205de781e79cb4c62486a5039f Use notification observers to update media style. --- diff --git a/LockScreen.mm b/LockScreen.mm index dd44657..953ab60 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -380,6 +380,7 @@ MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) { //#include "UICaboodle/UCInternal.h" - (void) dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; [webview_ setDelegate:nil]; [webview_ release]; [super dealloc]; @@ -494,9 +495,27 @@ MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) { [scroller_ setScrollingEnabled:[[configuration objectForKey:@"Scrollable"] boolValue]]; [self loadURL:url]; + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(mediaControlsDidSomething:) + name:@"SBLockScreenViewControllerMediaControlsDidShow" + object:nil + ]; + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(mediaControlsDidSomething:) + name:@"SBLockScreenViewControllerMediaControlsDidHide" + object:nil + ]; } return self; } +- (void) mediaControlsDidSomething:(NSNotification *)notification { + [self updateStyles]; +} + - (void) webView:(WebView *)webview didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { if (cycript_ != nil) if (NSString *href = [[[[frame dataSource] request] URL] absoluteString]) @@ -1368,7 +1387,6 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW if (kCFCoreFoundationVersionNumber >= 800) { SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]); [controller _setMediaControlsVisible:![controller isShowingMediaControls]]; - [self updateStyles]; } return [super handleMenuButtonDoubleTap];