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 4fa0f4a..407b719 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -107,6 +107,23 @@ static void preferenceUpdate(CFNotificationCenterRef center, void *observer, CFS if(!active) { active = true; vbar = [[VolumeBar alloc] init]; + + 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]; + } + vbar.color = color; vbar.sliderColorEnabled = sliderColorEnabled; vbar.minColor = minColor; @@ -127,6 +144,12 @@ static void preferenceUpdate(CFNotificationCenterRef center, void *observer, CFS HBLogDebug(@"Completion block called"); [vbar release]; vbar = nil; + 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" ); }; }