From 0e06627ba041f97197389e88ee2905908d1b5406 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 24 Jan 2014 09:53:52 -0800 Subject: [PATCH] Use separate layers to correct for notifications. --- LockScreen.mm | 52 +++++++++++++++++++++++-- PhotoExamplePlus.cydget/background.html | 22 ++++++++--- PhotoExamplePlus.cydget/foreground.html | 1 - 3 files changed, 65 insertions(+), 10 deletions(-) diff --git a/LockScreen.mm b/LockScreen.mm index 90da329..750ff7a 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -127,7 +127,12 @@ typedef uint16_t UChar; - (void) _setZoomScale:(float)scale duration:(double)duration; @end +@interface SBLockScreenView : UIView +- (BOOL) mediaControlsHidden; +@end + @interface SBLockScreenViewController : UIViewController +- (SBLockScreenView *) lockScreenView; - (BOOL) isShowingMediaControls; - (void) _setMediaControlsVisible:(BOOL)visible; @end @@ -485,6 +490,7 @@ MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) { @interface WebCycriptLockScreenController : SBAwayViewPluginController { NSDictionary *configuration_; WebCydgetLockScreenView *background_; + WebCydgetLockScreenView *foreground_; } @end @@ -1152,9 +1158,10 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW if (NSString *background = [configuration_ objectForKey:@"Background"]) background_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:background relativeToURL:base]]; - if (NSString *homepage = [configuration_ objectForKey:@"Homepage"]) - [self setView:[[[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:homepage relativeToURL:base]] autorelease]]; - else if (kCFCoreFoundationVersionNumber < 800 && background_ != nil) { + if (NSString *homepage = [configuration_ objectForKey:@"Homepage"]) { + foreground_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:homepage relativeToURL:base]]; + [self setView:foreground_]; + } else if (kCFCoreFoundationVersionNumber < 800 && background_ != nil) { [self setView:[background_ autorelease]]; background_ = nil; } @@ -1164,6 +1171,9 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW [background_ removeFromSuperview]; [background_ release]; background_ = nil; + [foreground_ removeFromSuperview]; + [foreground_ release]; + foreground_ = nil; [super purgeView]; } @@ -1175,24 +1185,55 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW return YES; } +- (BOOL) updateHidden { + if (foreground_ == nil) + return true; + SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]); + SBLockScreenView *view([controller lockScreenView]); + bool media(view != nil && ![view mediaControlsHidden]); + [foreground_ setHidden:media]; + return media; +} + - (BOOL) showDateView { - return [configuration_ objectForKey:@"Homepage"] == nil; + bool homepage([configuration_ objectForKey:@"Homepage"] != nil); + if (kCFCoreFoundationVersionNumber < 800) + return !homepage; + else if (!homepage) + return true; + return [self updateHidden]; +} + +- (BOOL) allowsLockScreenMediaControls { + if (kCFCoreFoundationVersionNumber < 800) + return true; + if (background_ == nil) + return false; + [self updateHidden]; + return true; } /*- (BOOL) showHeaderView { return YES; }*/ +// 1-3 - (NSUInteger) presentationStyle { return 1; } +// 1-5 - (NSUInteger) overlayStyle { if ([configuration_ objectForKey:@"Background"] == nil) return 1; return 4; } +// 1-[2/3?] +- (NSUInteger) notificationBehavior { + return 1; +} + - (BOOL) viewWantsFullscreenLayout { return kCFCoreFoundationVersionNumber >= 800; } @@ -1218,10 +1259,13 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW return YES; }*/ +// - (void) lockScreenMediaControlsShown:(BOOL)shown; + - (BOOL) handleMenuButtonDoubleTap { if (kCFCoreFoundationVersionNumber >= 800) { SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]); [controller _setMediaControlsVisible:![controller isShowingMediaControls]]; + [self updateHidden]; } return [super handleMenuButtonDoubleTap]; diff --git a/PhotoExamplePlus.cydget/background.html b/PhotoExamplePlus.cydget/background.html index 9af50a9..a4c6180 100644 --- a/PhotoExamplePlus.cydget/background.html +++ b/PhotoExamplePlus.cydget/background.html @@ -30,23 +30,33 @@ height: 100%; width: 100%; background: none; + background-color: black; } #content { height: 100%; width: 100%; - display: table-cell; - text-align: center; + } + + #content td { vertical-align: middle; } #content img { max-width: 100%; max-height: 100%; - vertical-align: middle; + } + + #shadow { + position: absolute; + width: 100%; + height: 164px; + top: 0px; + left: 0px; + background-color: rgba(87, 87, 87, 0.5); } -
+ + +
diff --git a/PhotoExamplePlus.cydget/foreground.html b/PhotoExamplePlus.cydget/foreground.html index 4d2a6e6..0933d72 100644 --- a/PhotoExamplePlus.cydget/foreground.html +++ b/PhotoExamplePlus.cydget/foreground.html @@ -33,7 +33,6 @@ #lcd { margin-top: 50px; - background-color: rgba(87, 87, 87, 0.5); } #lcd h1 { -- 2.45.2