forked from limneos/libbulletin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
60 lines (53 loc) · 1.9 KB
/
Tweak.xm
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
#import "imports.h"
#import "JBBulletinManager.h"
#import "JBBulletinManager+Private.h"
%hook BBBulletinRequest
- (id)composedAttachmentImageWithObserver:(id)observer {
// handle attachments for iOS 10
if (kCFCoreFoundationVersionNumber > 1300) {
return [[JBBulletinManager sharedInstance] popImageForBulletinRequest:self] ?: %orig;
}
return %orig;
}
- (id)composedAttachmentImageForKey:(id)aKey withObserver:(id)observer {
// handle attachments for older iOS with SBAwayController
id customImage = nil;
if (![[objc_getClass("SBAwayController") sharedAwayController] isLocked]) {
customImage = [[JBBulletinManager sharedInstance] popImageForBulletinRequest:self];
}
return customImage ?: %orig;
}
- (NSUInteger)messageNumberOfLines {
// for forcing max number of lines to 4
if ([[self publisherBulletinID] rangeOfString:@"-bulletin-manager"].location == 0) {
return 4;
}
return %orig;
}
- (UIImage *)sectionIconImageWithFormat:(int)format {
//for forcing custom bundle (icon) images
UIImage * customImage = nil;
if ([[self publisherBulletinID] rangeOfString:@"-bulletin-manager"].location == 0) {
customImage = [[JBBulletinManager sharedInstance] customImageForBulletinRequest:self];
}
return customImage ?: %orig;
}
- (BBSectionIcon *)sectionIcon {
//for forcing custom bundle (icon) images on iOS 10
if (kCFCoreFoundationVersionNumber < 1300) {
return %orig;
}
//for forcing custom bundle images
if ([[self publisherBulletinID] rangeOfString:@"-bulletin-manager"].location == 0) {
UIImage * customImage = [[JBBulletinManager sharedInstance] customImageForBulletinRequest:self];
if (customImage) {
BBSectionIconVariant * variant = [[objc_getClass("BBSectionIconVariant") alloc] init];
[variant setImageData:UIImagePNGRepresentation(customImage)];
BBSectionIcon * icon = [[objc_getClass("BBSectionIcon") alloc] init];
[icon addVariant:variant];
return icon;
}
}
return %orig;
}
%end