]> git.saurik.com Git - cydget.git/commitdiff
Re-implement iOS 6 media controls toggle on iOS 7.
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 24 Jan 2014 17:48:26 +0000 (09:48 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 24 Jan 2014 17:48:44 +0000 (09:48 -0800)
CydgetLoader.mm
LockScreen.mm

index a06d860d9ed950c79f0aad160068481f11685028..0ffa2c13511ff0d864c4a5deb2cff8f3ebea5599 100644 (file)
@@ -60,6 +60,10 @@ MSInitialize {
     }
 }
 
+@interface SBLockScreenViewController : UIViewController
+- (void) _toggleMediaControls;
+@end
+
 static bool menu_;
 
 static _H<NSDictionary> settings_;
@@ -163,14 +167,33 @@ MSInstanceMessageHook1(void, SpringBoard, handleKeyEvent, GSEventRef, event) {
     return MSSuperCall(event);
 }
 
+bool media_;
+
+MSInstanceMessageHook0(void, SBLockScreenViewController, _toggleMediaControls) {
+    if (!media_)
+        MSOldCall();
+}
+
+MSInstanceMessageHook0(BOOL, SBLockScreenViewController, handleMenuButtonDoubleTap) {
+    menu_ = false;
+    BOOL value(MSOldCall());
+    if (kCFCoreFoundationVersionNumber >= 800)
+        [self _toggleMediaControls];
+    return value;
+}
+
 MSInstanceMessageHook0(BOOL, SBLockScreenManager, handleMenuButtonTap) {
-    if (!MSOldCall() && menu_) {
+    media_ = true;
+    BOOL value(MSOldCall());
+    media_ = false;
+
+    if (!value && menu_) {
         [[cydgets_ objectAtIndex:active_] disableCydget];
         active_ = (active_ + 1) % [cydgets_ count];
         [[cydgets_ objectAtIndex:active_] enableCydget];
     }
 
-    return YES;
+    return value;
 }
 
 void Activate_() {
index 4c8f190a66fdb89ddf11aea0a544e3eb48daaea6..90da329a140886b396f75db98346e65f3a6d8714 100644 (file)
@@ -127,6 +127,16 @@ typedef uint16_t UChar;
 - (void) _setZoomScale:(float)scale duration:(double)duration;
 @end
 
+@interface SBLockScreenViewController : UIViewController
+- (BOOL) isShowingMediaControls;
+- (void) _setMediaControlsVisible:(BOOL)visible;
+@end
+
+@interface SBLockScreenManager : NSObject
++ (SBLockScreenManager *) sharedInstance;
+- (SBLockScreenViewController *) lockScreenViewController;
+@end
+
 @protocol CydgetController
 - (NSDictionary *) currentConfiguration;
 - (NSString *) currentPath;
@@ -282,6 +292,7 @@ static float CYScrollViewDecelerationRateNormal;
 @end
 
 MSClassHook(UIApplication)
+MSClassHook(SBLockScreenManager)
 
 MSInstanceMessageHook1(void, UIApplication, openURL, NSURL *, url) {
     [self applicationOpenURL:url];
@@ -1207,6 +1218,15 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW
     return YES;
 }*/
 
+- (BOOL) handleMenuButtonDoubleTap {
+    if (kCFCoreFoundationVersionNumber >= 800) {
+        SBLockScreenViewController *controller([[$SBLockScreenManager sharedInstance] lockScreenViewController]);
+        [controller _setMediaControlsVisible:![controller isShowingMediaControls]];
+    }
+
+    return [super handleMenuButtonDoubleTap];
+}
+
 @end
 
 MSClassHook(WebView)