From cf677acc802ea6f676866b04e44ed9e5fcf9cb03 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 24 Jan 2014 15:38:06 -0800 Subject: [PATCH] Use the new @media to rethink how legacy works. --- LockScreen.mm | 52 ++++++++++++++----------- PhotoExamplePlus.cydget/Info.plist | 2 + PhotoExamplePlus.cydget/foreground.html | 6 +++ Welcome.cydget/Info.plist | 2 + Welcome.cydget/Welcome.html | 22 ++++++++++- 5 files changed, 61 insertions(+), 23 deletions(-) diff --git a/LockScreen.mm b/LockScreen.mm index 5429de0..002b518 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -521,6 +521,9 @@ MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) { @interface WebCycriptLockScreenController : SBAwayViewPluginController { NSDictionary *configuration_; + bool legacy_; + bool media_; + bool items_; WebCydgetLockScreenView *background_; WebCydgetLockScreenView *foreground_; } @@ -1239,6 +1242,9 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW - (id) init { if ((self = [super init]) != nil) { configuration_ = [[$CydgetController currentConfiguration] retain]; + legacy_ = [configuration_ objectForKey:@"Background"] == nil; + media_ = [[configuration_ objectForKey:@"MediaControls"] boolValue]; + items_ = [[configuration_ objectForKey:@"NotificationList"] boolValue]; } return self; } @@ -1251,9 +1257,6 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW 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; } } @@ -1283,50 +1286,55 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW - (BOOL) updateHidden { if (foreground_ == nil) return true; - SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]); - SBLockScreenView *view([controller lockScreenView]); - bool media(view != nil && ![view mediaControlsHidden]); + bool media(CYHaveMediaControls()); [foreground_ setHidden:media]; return media; } - (BOOL) showDateView { - bool homepage([configuration_ objectForKey:@"Homepage"] != nil); if (kCFCoreFoundationVersionNumber < 800) - return !homepage; - else if (!homepage) + return false; + [self updateStyles]; + if (!legacy_ && foreground_ == nil) + return true; + if (!items_ && CYHaveNotificationList()) return true; - return [self updateHidden]; + return false; } - (BOOL) allowsLockScreenMediaControls { if (kCFCoreFoundationVersionNumber < 800) return true; - if (background_ == nil) - return false; - [self updateHidden]; - return true; + return media_; } /*- (BOOL) showHeaderView { return YES; }*/ -// 1-3 +// 0: view is rendered above head +// 1: view moves as one with head +// 2: view moves up and down only +// 3: view simply never does move - (NSUInteger) presentationStyle { return 1; } -// 1-5 +// 1: light blur +// 2: heavy blur +// 3: just black +// 4: legibility +// 5: no overlay - (NSUInteger) overlayStyle { - if ([configuration_ objectForKey:@"Background"] == nil) - return 1; - return 4; + return legacy_ ? 1 : 4; } -// 1-[2/3?] +// 1: blur -> view -> list +// 2: view -> blur -> list +// 3: view. unblur below?! +// 4: blur -> list -> view - (NSUInteger) notificationBehavior { - return 1; + return items_ ? 1 : 2; } - (BOOL) viewWantsFullscreenLayout { @@ -1360,7 +1368,7 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW if (kCFCoreFoundationVersionNumber >= 800) { SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]); [controller _setMediaControlsVisible:![controller isShowingMediaControls]]; - [self updateHidden]; + [self updateStyles]; } return [super handleMenuButtonDoubleTap]; diff --git a/PhotoExamplePlus.cydget/Info.plist b/PhotoExamplePlus.cydget/Info.plist index 18ad3e7..098f2af 100644 --- a/PhotoExamplePlus.cydget/Info.plist +++ b/PhotoExamplePlus.cydget/Info.plist @@ -11,4 +11,6 @@ CYConfiguration = { CycriptURLs = "^file:///System/Library/LockCydgets/PhotoExamplePlus\\.cydget/.*\\.html$"; Scrollable = "NO"; + MediaControls = YES; + NotificationList = YES; }; diff --git a/PhotoExamplePlus.cydget/foreground.html b/PhotoExamplePlus.cydget/foreground.html index 0933d72..bd9fdaa 100644 --- a/PhotoExamplePlus.cydget/foreground.html +++ b/PhotoExamplePlus.cydget/foreground.html @@ -99,6 +99,12 @@ top: -8px; } } + + @media (cydget-media-controls) { + #lcd { + opacity: 0; + } + }
-- 2.47.2