}
}
+@interface SBLockScreenNowPlayingPluginController : NSObject
+- (BOOL) isNowPlayingPluginActive;
+@end
+
@interface SBLockScreenViewController : UIViewController
+- (SBLockScreenView *) lockScreenView;
+- (BOOL) isShowingMediaControls;
- (void) _toggleMediaControls;
@end
+@interface SBLockScreenManager : NSObject
++ (SBLockScreenManager *) sharedInstance;
+- (SBLockScreenViewController *) lockScreenViewController;
+@end
+
static bool menu_;
static _H<NSDictionary> settings_;
static _H<NSMutableArray> cydgets_;
static size_t active_;
static unsigned online_;
+static bool nowplaying_;
+
+static bool NowPlaying() {
+ if (kCFCoreFoundationVersionNumber < 800)
+ return false;
+ if (!nowplaying_)
+ return false;
+
+ SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]);
+ if (controller != nil) {
+ SBLockScreenNowPlayingPluginController *now(MSHookIvar<SBLockScreenNowPlayingPluginController *>(controller, "_nowPlayingController"));
+ if (now != nil && [now isNowPlayingPluginActive])
+ return true;
+ }
+
+ return false;
+}
@interface CydgetController : NSObject {
}
media_ = false;
if (!value && menu_) {
- [[cydgets_ objectAtIndex:active_] disableCydget];
+ if (active_ != _not(size_t))
+ [[cydgets_ objectAtIndex:active_] disableCydget];
active_ = (active_ + 1) % [cydgets_ count];
[[cydgets_ objectAtIndex:active_] enableCydget];
// XXX: or siri doesn't disappear correctly
void Activate_() {
menu_ = false;
- [[cydgets_ objectAtIndex:active_] enableCydget];
+ if (NowPlaying()) {
+ for (active_ = 0; active_ != [cydgets_ count]; ++active_)
+ if ([[[cydgets_ objectAtIndex:active_] objectForKey:@"CYName"] isEqualToString:@"AwayView"])
+ break;
+ if (active_ == [cydgets_ count])
+ active_ = _not(size_t);
+ }
+ if (active_ != _not(size_t))
+ [[cydgets_ objectAtIndex:active_] enableCydget];
}
static void Undim_(SBAwayController *self) {
}
static void Deactivate_() {
- [[cydgets_ objectAtIndex:active_] disableCydget];
+ if (active_ != _not(size_t))
+ [[cydgets_ objectAtIndex:active_] disableCydget];
active_ = 0;
}
MSOldCall(dim);
}
+MSInstanceMessageHook0(void, SpringBoard, _menuButtonWasHeld) {
+ menu_ = false;
+ MSOldCall();
+}
+
MSInstanceMessageHook1(void, SpringBoard, _menuButtonDown, GSEventRef, event) {
menu_ = true;
MSOldCall(event);
NSString *plist([NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.Cydget.plist", NSHomeDirectory()]);
settings_ = [NSMutableDictionary dictionaryWithContentsOfFile:plist] ?: [NSMutableDictionary dictionary];
+ nowplaying_ = [[settings_ objectForKey:@"NowPlaying"] boolValue];
+
NSArray *cydgets([settings_ objectForKey:@"LockCydgets"] ?: [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
@"Welcome", @"Name", [NSNumber numberWithBool:YES], @"Active", nil
], [NSDictionary dictionaryWithObjectsAndKeys:
cydgets_ = [NSMutableArray arrayWithCapacity:4];
for (NSDictionary *cydget in cydgets)
if ([[cydget objectForKey:@"Active"] boolValue]) {
- NSString *path([NSString stringWithFormat:@"%@/%@.cydget/Info.plist", Cydgets_, [cydget objectForKey:@"Name"]]);
+ NSString *name([cydget objectForKey:@"Name"]);
+ NSString *path([NSString stringWithFormat:@"%@/%@.cydget/Info.plist", Cydgets_, name]);
if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:path]) {
+ [info setObject:name forKey:@"CYName"];
[info setObject:path forKey:@"CYPath"];
[cydgets_ addObject:info];
}
MSInstanceMessageHook1(id, SBLockScreenView, initWithFrame, CGRect, frame) {
self = MSOldCall(frame);
CydgetSetup();
- [[cydgets_ objectAtIndex:active_] enableCydget];
+ Activate_();
return self;
}