This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweak.x
80 lines (53 loc) · 1.82 KB
/
Tweak.x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#import "HBCZNowPlayingBulletinProvider.h"
#import "HBCZNowPlayingController.h"
#import "HBCZPreferences.h"
#import <BulletinBoard/BBLocalDataProviderStore.h>
#import <SpringBoard/SBMediaController.h>
#import <version.h>
@interface NCNotificationRequest : NSObject // UNKit
@property (nonatomic, copy, readonly) NSString *sectionIdentifier;
@end
#pragma mark - Variables
HBCZPreferences *preferences;
#pragma mark - Notification Center
%hook BBLocalDataProviderStore
- (void)loadAllDataProvidersAndPerformMigration:(BOOL)performMigration {
%orig;
// add ourself as a data provider
[self addDataProvider:[HBCZNowPlayingBulletinProvider sharedInstance] performMigration:YES];
}
%end
%group PhilSchiller
#pragma mark - Hide banner in foreground app
%hook SBApplication
- (BOOL)shouldSuppressAlertForSuppressionContexts:(id)suppressionContexts sectionIdentifier:(NSString *)sectionIdentifier {
// if this is a bulletin coming from our section, and we’re inside the now playing app, indicate
// to not show the alert (banner)
if ([sectionIdentifier isEqualToString:kHBCZAppIdentifier] && ((SBMediaController *)[%c(SBMediaController) sharedInstance]).nowPlayingApplication == self) {
return YES;
}
return %orig;
}
%end
#pragma mark - Hide now playing controls
%hook SBLockScreenNowPlayingController
- (void)_updateToState:(long long)state {
// TODO: work out the enum values
// but basically, anything over 2 is “enabled”, 0 and 1 are “disabled” in some way
%orig(preferences.hideLockMusicControls && state > 1 ? 0 : state);
}
%end
%end
#pragma mark - Constructor
%ctor {
// set up variables
preferences = [HBCZPreferences sharedInstance];
if (IN_SPRINGBOARD) {
// get the controller rolling
[HBCZNowPlayingController sharedInstance];
%init;
if (IS_IOS_OR_NEWER(iOS_10_0)) {
%init(PhilSchiller);
}
}
}