Skip to content

Commit

Permalink
Hide the status bar when volume bar is showing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cgm616 committed Aug 23, 2016
1 parent 95cc021 commit 3defe96
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions Tweak.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#import <SpringBoard/SBHUDView.h>
#import <libcolorpicker.h>
#import <UIKit/UIKit.h>
#import <SpringBoard/SpringBoard.h>
#import <SpringBoard/SBApplication.h>
#import <libobjcipc/objcipc.h>
#import "VolumeBar.h"

typedef void(^CompletionBlock)(void);
Expand Down
23 changes: 23 additions & 0 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -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<UIStatusBar *>([UIApplication sharedApplication], "_statusBar");
statusBarHidden = statusBar.hidden;
statusBar.hidden = YES;
startOrientation = [[UIApplication sharedApplication] statusBarOrientation];
}

VolumeBar *vbar = [[VolumeBar alloc] init];
vbar.color = color;
vbar.sliderColorEnabled = sliderColorEnabled;
Expand All @@ -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<UIStatusBar *>([UIApplication sharedApplication], "_statusBar");
statusBar.hidden = statusBarHidden;
}
active = false;
};
[vbar loadHUDWithView:view];
Expand Down
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 10 additions & 0 deletions vb9appkit/Makefile
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 12 additions & 0 deletions vb9appkit/Tweak.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* vb9appkit/Tweak.h
* VolumeBar9
*
* Created by cgm616
* Copyright (c) 2016 cgm616. All rights reserved.
*/

#import <libobjcipc/objcipc.h>
// #import <UIKit/UIApplication+Private.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIStatusBar.h>
39 changes: 39 additions & 0 deletions vb9appkit/Tweak.xm
Original file line number Diff line number Diff line change
@@ -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<UIStatusBar *>([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<UIStatusBar *>([UIApplication sharedApplication], "_statusBar");
statusBar.hidden = previousStatus;

return nil;
}];

return %orig;
}

%end
1 change: 1 addition & 0 deletions vb9appkit/VB9AppKit.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.UIKit" ); }; }

0 comments on commit 3defe96

Please sign in to comment.