Skip to content

Commit

Permalink
Merge branch 'hidden_status_bar'
Browse files Browse the repository at this point in the history
  • Loading branch information
cgm616 committed Aug 23, 2016
2 parents 7f7745d + 3defe96 commit 122e1f2
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 @@ -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<UIStatusBar *>([UIApplication sharedApplication], "_statusBar");
statusBarHidden = statusBar.hidden;
statusBar.hidden = YES;
startOrientation = [[UIApplication sharedApplication] statusBarOrientation];
}

vbar.color = color;
vbar.sliderColorEnabled = sliderColorEnabled;
vbar.minColor = minColor;
Expand All @@ -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<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 122e1f2

Please sign in to comment.