Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Chr1sDev committed May 8, 2021
1 parent dc6a806 commit bc385b4
Show file tree
Hide file tree
Showing 21 changed files with 598 additions and 206 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.theos
/packages
/packages
.DS_Store
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ TWEAK_NAME = Vibin

Vibin_FILES = $(wildcard *.xm *.m)
$(TWEAK_NAME)_PRIVATE_FRAMEWORKS = MediaRemote
$(TWEAK_NAME)_EXTRA_FRAMEWORKS += Cephei
Vibin_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/tweak.mk
SUBPROJECTS += vibinprefs
include $(THEOS_MAKE_PATH)/aggregate.mk
156 changes: 0 additions & 156 deletions MediaRemote.h

This file was deleted.

45 changes: 45 additions & 0 deletions Tweak.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#import <Cephei/HBPreferences.h>
#import "SBMediaController.h"
#import <objc/runtime.h>

HBPreferences *preferences;
BOOL enabled;
BOOL enableDND;
BOOL enableHideNotifs;

@interface NCNotificationListView : UIScrollView
@end

@interface NCNotificationStructuredListViewController : UIViewController
@property (nonatomic, retain) NCNotificationListView *masterListView;
// %new
-(void)hideNotifs;
-(void)showNotifs;
@end

//Do Not Disturb
@class DNDModeAssertionLifetime;

@interface DNDModeAssertionDetails : NSObject
+ (id)userRequestedAssertionDetailsWithIdentifier:(NSString *)identifier modeIdentifier:(NSString *)modeIdentifier lifetime:(DNDModeAssertionLifetime *)lifetime;
- (BOOL)invalidateAllActiveModeAssertionsWithError:(NSError **)error;
- (id)takeModeAssertionWithDetails:(DNDModeAssertionDetails *)assertionDetails error:(NSError **)error;
@end

@interface DNDModeAssertionService : NSObject
+ (id)serviceForClientIdentifier:(NSString *)clientIdentifier;
- (BOOL)invalidateAllActiveModeAssertionsWithError:(NSError **)error;
- (id)takeModeAssertionWithDetails:(DNDModeAssertionDetails *)assertionDetails error:(NSError **)error;
@end

static BOOL DNDEnabled;
static DNDModeAssertionService *assertionService;

typedef struct {
BOOL active;
BOOL enabled;
BOOL sunSchedulePermitted;
int mode;
unsigned long long disableFlags;
BOOL available;
} Status;
77 changes: 29 additions & 48 deletions Tweak.xm
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
#import "MediaRemote.h"
#import "SBMediaController.h"
#import <objc/runtime.h>

@interface NCNotificationListView : UIScrollView
@end

@interface NCNotificationStructuredListViewController : UIViewController
@property (nonatomic, retain) NCNotificationListView *masterListView;
// %new
-(void)hideNotifs;
-(void)showNotifs;
@end
#import "Tweak.h"

%group VibinTweak
%hook NCNotificationStructuredListViewController
-(void)viewDidAppear:(BOOL)animated {
static dispatch_once_t onceToken;
Expand Down Expand Up @@ -53,43 +42,15 @@
}
%end

//Do Not Disturb
@class DNDModeAssertionLifetime;

@interface DNDModeAssertionDetails : NSObject
+ (id)userRequestedAssertionDetailsWithIdentifier:(NSString *)identifier modeIdentifier:(NSString *)modeIdentifier lifetime:(DNDModeAssertionLifetime *)lifetime;
- (BOOL)invalidateAllActiveModeAssertionsWithError:(NSError **)error;
- (id)takeModeAssertionWithDetails:(DNDModeAssertionDetails *)assertionDetails error:(NSError **)error;
@end

@interface DNDModeAssertionService : NSObject
+ (id)serviceForClientIdentifier:(NSString *)clientIdentifier;
- (BOOL)invalidateAllActiveModeAssertionsWithError:(NSError **)error;
- (id)takeModeAssertionWithDetails:(DNDModeAssertionDetails *)assertionDetails error:(NSError **)error;
@end

static BOOL DNDEnabled;
static DNDModeAssertionService *assertionService;

typedef struct {
BOOL active;
BOOL enabled;
BOOL sunSchedulePermitted;
int mode;
unsigned long long disableFlags;
BOOL available;
} Status;


void enableDND() {
void turnOnDND() {
if (!assertionService) {
assertionService = (DNDModeAssertionService *)[objc_getClass("DNDModeAssertionService") serviceForClientIdentifier:@"com.apple.donotdisturb.control-center.module"];
}
DNDModeAssertionDetails *newAssertion = [objc_getClass("DNDModeAssertionDetails") userRequestedAssertionDetailsWithIdentifier:@"com.apple.control-center.manual-toggle" modeIdentifier:@"com.apple.donotdisturb.mode.default" lifetime:nil];
[assertionService takeModeAssertionWithDetails:newAssertion error:NULL];
}

void disableDND() {
void turnOffDND() {
if (!assertionService) {
assertionService = (DNDModeAssertionService *)[objc_getClass("DNDModeAssertionService") serviceForClientIdentifier:@"com.apple.donotdisturb.control-center.module"];
}
Expand Down Expand Up @@ -120,11 +81,31 @@ SBMediaController *mediaController;
%new
- (void)currentSongChanged:(NSNotification *)notification {
if (mediaController.isPlaying) {
enableDND();
[[NSNotificationCenter defaultCenter] postNotificationName:@"hideNotificationsOnCS" object:self];
if (enableDND) {
turnOnDND();
}
if (enableHideNotifs) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"hideNotificationsOnCS" object:self];
}
} else {
disableDND();
[[NSNotificationCenter defaultCenter] postNotificationName:@"showNotificationsOnCS" object:self];
if (enableDND) {
turnOffDND();
}
if (enableHideNotifs) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"showNotificationsOnCS" object:self];
}
}
}
%end
%end

%end // %group VibinTweak

%ctor {
preferences = [[HBPreferences alloc] initWithIdentifier:@"com.chr1s.vibinprefs"];
[preferences registerBool:&enabled default:YES forKey:@"enabled"];
[preferences registerBool:&enableDND default:YES forKey:@"enableDND"];
[preferences registerBool:&enableHideNotifs default:YES forKey:@"enableHideNotifs"];
if (enabled) {
%init(VibinTweak);
}
}
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Description: Don't disrupt the vibe
Maintainer: Chr1s
Author: Chr1s
Section: Tweaks
Depends: mobilesubstrate (>= 0.9.5000)
Depends: mobilesubstrate (>= 0.9.5000), preferenceloader, ws.hbang.common (>= 1.15.1)
13 changes: 13 additions & 0 deletions vibinprefs/KRLinkCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "KRTableCell.h"

@interface KRLinkCell : KRTableCell

@property (nonatomic, readonly) BOOL isBig;

@property (nonatomic, retain, readonly) UIView *avatarView;

@property (nonatomic, retain, readonly) UIImageView *avatarImageView;

@property (nonatomic, retain) UIImage *avatarImage;

@end
Loading

0 comments on commit bc385b4

Please sign in to comment.