From 3defe96d9e203fbfc8da157753431695ff3f3ce9 Mon Sep 17 00:00:00 2001 From: cgm616 Date: Tue, 23 Aug 2016 14:07:45 -0500 Subject: [PATCH] Hide the status bar when volume bar is showing This required the addition of a subtweak to hook into applications, because iOS handles the status bar in a really really weird way. Also added is the ability to receive current orientation from apps, to be used later to init the volume bar. The same IPC system used to do this will be used to make the bar orient correctly in all apps. --- Makefile | 3 ++- Tweak.h | 3 +++ Tweak.xm | 23 +++++++++++++++++++++++ control | 2 +- vb9appkit/Makefile | 10 ++++++++++ vb9appkit/Tweak.h | 12 ++++++++++++ vb9appkit/Tweak.xm | 39 +++++++++++++++++++++++++++++++++++++++ vb9appkit/VB9AppKit.plist | 1 + 8 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 vb9appkit/Makefile create mode 100644 vb9appkit/Tweak.h create mode 100644 vb9appkit/Tweak.xm create mode 100644 vb9appkit/VB9AppKit.plist diff --git a/Makefile b/Makefile index 33bcb3d..0bc28b9 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,12 @@ include $(THEOS)/makefiles/common.mk TWEAK_NAME = VolumeBar9 VolumeBar9_FILES = $(wildcard *.xm) VolumeBar9_FRAMEWORKS = Foundation -VolumeBar9_LIBRARIES = colorpicker +VolumeBar9_LIBRARIES = colorpicker objcipc include $(THEOS_MAKE_PATH)/tweak.mk after-install:: install.exec "killall -9 SpringBoard" SUBPROJECTS += prefs +SUBPROJECTS += vb9appkit include $(THEOS_MAKE_PATH)/aggregate.mk diff --git a/Tweak.h b/Tweak.h index 028ce19..6c02323 100644 --- a/Tweak.h +++ b/Tweak.h @@ -9,6 +9,9 @@ #import #import #import +#import +#import +#import #import "VolumeBar.h" typedef void(^CompletionBlock)(void); diff --git a/Tweak.xm b/Tweak.xm index 60e6a60..c5b7155 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -104,6 +104,23 @@ static void preferenceUpdate(CFNotificationCenterRef center, void *observer, CFS // TODO: pass in prefs as dictionary and handle defaults some other way if(!active) { active = true; + + NSString *appID = [(SpringBoard *)[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; + + BOOL statusBarHidden; + UIInterfaceOrientation startOrientation; + + if(appID) { + NSDictionary *reply = [OBJCIPC sendMessageToAppWithIdentifier:appID messageName:@"me.cgm616.volumebar9.showing" dictionary:nil]; + statusBarHidden = [reply[@"statusBarHidden"] boolValue]; + startOrientation = [reply[@"currentOrientation"] longLongValue]; + } else { + UIStatusBar *statusBar = MSHookIvar([UIApplication sharedApplication], "_statusBar"); + statusBarHidden = statusBar.hidden; + statusBar.hidden = YES; + startOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + } + VolumeBar *vbar = [[VolumeBar alloc] init]; vbar.color = color; vbar.sliderColorEnabled = sliderColorEnabled; @@ -124,6 +141,12 @@ static void preferenceUpdate(CFNotificationCenterRef center, void *observer, CFS vbar.completion = ^{ HBLogDebug(@"Completion block called"); [vbar release]; + if(appID) { + [OBJCIPC sendMessageToAppWithIdentifier:appID messageName:@"me.cgm616.volumebar9.hiding" dictionary:@{ @"statusBarHidden": [NSNumber numberWithBool:statusBarHidden] } replyHandler:^(NSDictionary *response) {}]; + } else { + UIStatusBar *statusBar = MSHookIvar([UIApplication sharedApplication], "_statusBar"); + statusBar.hidden = statusBarHidden; + } active = false; }; [vbar loadHUDWithView:view]; diff --git a/control b/control index 136494b..04f895d 100644 --- a/control +++ b/control @@ -1,6 +1,6 @@ Package: me.cgm616.volumebar9 Name: VolumeBar9 -Depends: mobilesubstrate, org.thebigboss.libcolorpicker +Depends: mobilesubstrate, org.thebigboss.libcolorpicker, cc.tweak.libobjcipc Version: 0.1.1-beta Architecture: iphoneos-arm Description: Changes the ugly volume HUD to a nice bar. diff --git a/vb9appkit/Makefile b/vb9appkit/Makefile new file mode 100644 index 0000000..4d903e1 --- /dev/null +++ b/vb9appkit/Makefile @@ -0,0 +1,10 @@ +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = VB9AppKit +VB9AppKit_FILES = Tweak.xm +VB9AppKit_LIBRARIES = objcipc + +include $(THEOS_MAKE_PATH)/tweak.mk + +after-install:: + install.exec "killall -9 SpringBoard" diff --git a/vb9appkit/Tweak.h b/vb9appkit/Tweak.h new file mode 100644 index 0000000..c69af11 --- /dev/null +++ b/vb9appkit/Tweak.h @@ -0,0 +1,12 @@ +/* + * vb9appkit/Tweak.h + * VolumeBar9 + * + * Created by cgm616 + * Copyright (c) 2016 cgm616. All rights reserved. + */ + +#import +// #import +#import +#import diff --git a/vb9appkit/Tweak.xm b/vb9appkit/Tweak.xm new file mode 100644 index 0000000..bb1d466 --- /dev/null +++ b/vb9appkit/Tweak.xm @@ -0,0 +1,39 @@ +/* + * vb9appkit/Tweak.xm + * VolumeBar9 + * + * Created by cgm616 + * Copyright (c) 2016 cgm616. All rights reserved. + */ + +#import "Tweak.h" + +%hook UIApplication + +-(id)init { + [OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:@"me.cgm616.volumebar9.showing" handler:^NSDictionary *(NSDictionary *message) { + UIStatusBar *statusBar = MSHookIvar([UIApplication sharedApplication], "_statusBar"); + BOOL status = statusBar.hidden; + statusBar.hidden = YES; + + NSDictionary *return_message = @{ + @"statusBarHidden" : [NSNumber numberWithBool:status], + @"currentOrientation" : [NSNumber numberWithLongLong:[[UIApplication sharedApplication] statusBarOrientation]], + }; + + return return_message; + }]; + + [OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:@"me.cgm616.volumebar9.hiding" handler:^NSDictionary *(NSDictionary *message) { + BOOL previousStatus = [message[@"statusBarHidden"] boolValue]; + + UIStatusBar *statusBar = MSHookIvar([UIApplication sharedApplication], "_statusBar"); + statusBar.hidden = previousStatus; + + return nil; + }]; + + return %orig; +} + +%end diff --git a/vb9appkit/VB9AppKit.plist b/vb9appkit/VB9AppKit.plist new file mode 100644 index 0000000..e5c60ee --- /dev/null +++ b/vb9appkit/VB9AppKit.plist @@ -0,0 +1 @@ +{ Filter = { Bundles = ( "com.apple.UIKit" ); }; }