Skip to content

Commit 8155838

Browse files
committed
add compatibilty for iOS 14
1 parent 078d1a5 commit 8155838

14 files changed

+54
-58
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include $(THEOS)/makefiles/common.mk
22

33
ARCHS = arm64 arm64e
44
TWEAK_NAME = NotiBlock
5+
TARGET = iphone::13.0
56
NotiBlock_FILES = Tweak.xm notiblockpref/NBPNotificationFilter.m notiblockpref/NBPAppInfo.m
67
NotiBlock_LIBRARIES = applist
78
NotiBlock_EXTRA_FRAMEWORKS += Cephei

Tweak.xm

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ NSMutableDictionary *filters;
4949
returns whether a message should be filtered based on some boolean logic of filters
5050
**/
5151
+ (BOOL)doesMessageMatchFilterType:(BOOL)titleMatches arg2:(BOOL)subtitleMatches arg3:(BOOL)messageMatches arg4:(int)filterType {
52-
HBLogDebug(@"NOTIBLOCK - checking matched: title: %@, subtitle: %@, message: %@, filterType: %d",(titleMatches ? @"true" : @"false"), (subtitleMatches ? @"true" : @"false"), (messageMatches ? @"true" : @"false"), filterType);
52+
NSLog(@"NOTIBLOCK - checking matched: title: %@, subtitle: %@, message: %@, filterType: %d",(titleMatches ? @"true" : @"false"), (subtitleMatches ? @"true" : @"false"), (messageMatches ? @"true" : @"false"), filterType);
5353
if (filterType == 0) {
5454
return titleMatches || titleMatches || messageMatches;
5555
} else if (filterType == 1) {
@@ -66,42 +66,42 @@ returns whether a message should be filtered based on some boolean logic of filt
6666
returns whether we are currently inbetween the start time and and time and on a weekday set to true in an array of bools
6767
**/
6868
+(BOOL)areWeCurrentlyInSchedule:(NSDate *)startTime arg2:(NSDate *)endTime arg3:(NSArray *)weekdays {
69-
HBLogDebug(@"NOTIBLOCK - checking schedule");
69+
NSLog(@"NOTIBLOCK - checking schedule");
7070

7171
NSDate *curTime = [NSDate date];
7272

7373

7474
NSCalendar *calendar = [NSCalendar currentCalendar];
7575

7676
NSDateComponents *startComponents = [calendar components:(NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:startTime];
77-
NSCalendar *newStartCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
77+
NSCalendar *newStartCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
7878
NSDate *newStartTime = [newStartCalendar dateBySettingHour:[startComponents hour] minute:[startComponents minute] second:0 ofDate:curTime options:0];
7979

8080
NSDateComponents *endComponents = [calendar components:(NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:endTime];
81-
NSCalendar *newEndCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
81+
NSCalendar *newEndCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
8282
NSDate *newEndTime = [newEndCalendar dateBySettingHour:[endComponents hour] minute:[endComponents minute] second:0 ofDate:curTime options:0];
8383

8484

8585
NSInteger curWeekday = [[NSCalendar currentCalendar] component:NSCalendarUnitWeekday
8686
fromDate:curTime] - 1;
8787
//day of week is not selected
8888
if (![((NSNumber *)weekdays[curWeekday]) boolValue]) {
89-
HBLogDebug(@"NOTIBLOCK - day is not active. skipping filter");
89+
NSLog(@"NOTIBLOCK - day is not active. skipping filter");
9090
return false;
9191
}
9292

9393
if ([[newStartTime earlierDate:newEndTime] isEqualToDate:newEndTime]) { //backwards (start time before end time)
94-
HBLogDebug(@"NOTIBLOCK - backwards schedule mode");
94+
NSLog(@"NOTIBLOCK - backwards schedule mode");
9595
return [[newStartTime earlierDate:curTime] isEqualToDate:newStartTime] || [[newEndTime earlierDate:curTime] isEqualToDate:curTime];
9696
} else { //regular, check for in between
9797

98-
HBLogDebug(@"NOTIBLOCK - regular schedule mode");
99-
HBLogDebug(@"NOTIBLOCK - curTime: %f", [curTime timeIntervalSince1970]);
100-
HBLogDebug(@"NOTIBLOCK - newStartTime: %f", [newStartTime timeIntervalSince1970]);
101-
HBLogDebug(@"NOTIBLOCK - newEndTime: %f", [newEndTime timeIntervalSince1970]);
98+
NSLog(@"NOTIBLOCK - regular schedule mode");
99+
NSLog(@"NOTIBLOCK - curTime: %f", [curTime timeIntervalSince1970]);
100+
NSLog(@"NOTIBLOCK - newStartTime: %f", [newStartTime timeIntervalSince1970]);
101+
NSLog(@"NOTIBLOCK - newEndTime: %f", [newEndTime timeIntervalSince1970]);
102102

103-
HBLogDebug(@"NOTIBLOCK - is after start - %@",([[newStartTime earlierDate:curTime] isEqualToDate:newStartTime] ? @"true" : @"false"));
104-
HBLogDebug(@"NOTIBLOCK - is before end - %@",([[newEndTime earlierDate:curTime] isEqualToDate:curTime] ? @"true" : @"false"));
103+
NSLog(@"NOTIBLOCK - is after start - %@",([[newStartTime earlierDate:curTime] isEqualToDate:newStartTime] ? @"true" : @"false"));
104+
NSLog(@"NOTIBLOCK - is before end - %@",([[newEndTime earlierDate:curTime] isEqualToDate:curTime] ? @"true" : @"false"));
105105
return [[newEndTime earlierDate:curTime] isEqualToDate:curTime] && [[newStartTime earlierDate:curTime] isEqualToDate:newStartTime];
106106
}
107107
}
@@ -118,17 +118,17 @@ returns whether we are currently inbetween the start time and and time and on a
118118
//NSString *bulletinID = bulletin.bulletinID;
119119
NSString *sectionId = bulletin.sectionID;
120120

121-
// HBLogDebug(@"NOTIBLOCK - Entered publish bulletin for %@ with ID: %@ ", sectionId, bulletinID);
122-
//HBLogDebug(@"NOTIBLOCK - BulletinID:%@ Title: %@ Subtitle: %@ Message: %@", bulletinID, title, subtitle, message );
121+
// NSLog(@"NOTIBLOCK - Entered publish bulletin for %@ with ID: %@ ", sectionId, bulletinID);
122+
//NSLog(@"NOTIBLOCK - BulletinID:%@ Title: %@ Subtitle: %@ Message: %@", bulletinID, title, subtitle, message );
123123

124124
BOOL filtered = NO;
125125

126126
if (filters == nil) {
127-
HBLogDebug(@"NOTIBLOCK - No filters. returning");
127+
NSLog(@"NOTIBLOCK - No filters. returning");
128128
return 0;
129129
}
130130

131-
HBLogDebug(@"NOTIBLOCK - loading all filters: %lu", (unsigned long)[filters count]);
131+
NSLog(@"NOTIBLOCK - loading all filters: %lu", (unsigned long)[filters count]);
132132

133133
NSMutableArray *allFilters = [filters objectForKey:@""];
134134
NSMutableArray *appFilters = [filters objectForKey:sectionId];
@@ -141,7 +141,7 @@ returns whether we are currently inbetween the start time and and time and on a
141141
allFilters = [[allFilters arrayByAddingObjectsFromArray:appFilters] mutableCopy];
142142
}
143143

144-
HBLogDebug(@"NOTIBLOCK - loading relevant filters for --%@--: %lu",sectionId, (unsigned long)[allFilters count]);
144+
NSLog(@"NOTIBLOCK - loading relevant filters for --%@--: %lu",sectionId, (unsigned long)[allFilters count]);
145145

146146
if (title == nil) {
147147
title = @"";
@@ -161,7 +161,7 @@ returns whether we are currently inbetween the start time and and time and on a
161161
//check for schedule and skip if not inside
162162
if (filter.onSchedule && ![self areWeCurrentlyInSchedule:filter.startTime arg2:filter.endTime arg3:filter.weekDays]) {
163163
//not inside schedule, skip
164-
HBLogDebug(@"NOTIBLOCK - schedule was on, but we determined it is not currently active. skipping filter");
164+
NSLog(@"NOTIBLOCK - schedule was on, but we determined it is not currently active. skipping filter");
165165
continue;
166166
}
167167

@@ -172,43 +172,43 @@ returns whether we are currently inbetween the start time and and time and on a
172172

173173
//do filtering
174174
if (filter.blockType == 0) { //starts with
175-
HBLogDebug(@"NOTIBLOCK - checking if string starts with text");
175+
NSLog(@"NOTIBLOCK - checking if string starts with text");
176176
titleMatches = [title hasPrefix:filterText];
177177
subtitleMatches = [subtitle hasPrefix:filterText];
178178
messageMatches = [message hasPrefix:filterText];
179179
} else if (filter.blockType == 1) { //ends with
180-
HBLogDebug(@"NOTIBLOCK - checking if string end with text");
180+
NSLog(@"NOTIBLOCK - checking if string end with text");
181181
titleMatches = [title hasSuffix:filterText];
182182
subtitleMatches = [subtitle hasSuffix:filterText];
183183
messageMatches = [message hasSuffix:filterText];
184184
} else if (filter.blockType == 2) { //contains
185-
HBLogDebug(@"NOTIBLOCK - checking if string contains text");
185+
NSLog(@"NOTIBLOCK - checking if string contains text");
186186
titleMatches = [title rangeOfString:filterText].location != NSNotFound;
187187
subtitleMatches = [subtitle rangeOfString:filterText].location != NSNotFound;
188188
messageMatches = [message rangeOfString:filterText].location != NSNotFound;
189189
} else if (filter.blockType == 3) { //exact text
190-
HBLogDebug(@"NOTIBLOCK - checking if string matches text");
190+
NSLog(@"NOTIBLOCK - checking if string matches text");
191191
titleMatches = [title isEqualToString:filterText];
192192
subtitleMatches = [subtitle isEqualToString:filterText];
193193
messageMatches = [message isEqualToString:filterText];
194194
} else if (filter.blockType == 4) { //regex
195-
HBLogDebug(@"NOTIBLOCK - checking if string matches regex");
195+
NSLog(@"NOTIBLOCK - checking if string matches regex");
196196
NSPredicate *notifTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", filterText];
197197
titleMatches = ![title isEqualToString:@""] && [notifTest evaluateWithObject: title];
198198
subtitleMatches = ![subtitle isEqualToString:@""] && [notifTest evaluateWithObject: subtitle];
199199
messageMatches = ![message isEqualToString:@""] && [notifTest evaluateWithObject: message];
200200
} else if (filter.blockType == 5) { //always
201-
HBLogDebug(@"NOTIBLOCK - app should always be filtered. filtering turned on");
201+
NSLog(@"NOTIBLOCK - app should always be filtered. filtering turned on");
202202
filtered = YES;
203203
}
204204

205205
if ([self doesMessageMatchFilterType:titleMatches arg2:subtitleMatches arg3:messageMatches arg4:filter.filterType]) {
206-
HBLogDebug(@"NOTIBLOCK - filtering was matched");
206+
NSLog(@"NOTIBLOCK - filtering was matched");
207207
filtered = YES;
208208
}
209209

210210
if (filter.whitelistMode) {
211-
HBLogDebug(@"NOTIBLOCK - whitelist Mode on");
211+
NSLog(@"NOTIBLOCK - whitelist Mode on");
212212
filtered = !filtered;
213213
}
214214

@@ -242,7 +242,7 @@ Loads filters into memory from disk when springboard is loaded
242242
-(void)applicationDidFinishLaunching:(id)application {
243243
%orig;
244244

245-
HBLogDebug(@"NOTIBLOCK - springboard launch");
245+
NSLog(@"NOTIBLOCK - springboard launch");
246246

247247
//do in background thread?
248248
HBPreferences *defaults = [[HBPreferences alloc] initWithIdentifier:@"com.shemeshapps.notiblock"];
@@ -252,11 +252,11 @@ Loads filters into memory from disk when springboard is loaded
252252
bool enabled = [([prefDefaults objectForKey:@"enabled"] ?: @(YES)) boolValue];
253253

254254
//for (NSString *key in [[prefDefaults dictionaryRepresentation] allKeys]) {
255-
// HBLogDebug(@"NOTIBLOCK - pref keys: %@", key);
255+
// NSLog(@"NOTIBLOCK - pref keys: %@", key);
256256
//}
257257

258258
if(!enabled) {
259-
HBLogDebug(@"NOTIBLOCK - tweak disabled. not loading filters");
259+
NSLog(@"NOTIBLOCK - tweak disabled. not loading filters");
260260
return;
261261
}
262262

@@ -278,10 +278,10 @@ Loads filters into memory from disk when springboard is loaded
278278
NSMutableArray *appIdfilters = [filters objectForKey:dictKey];
279279
[appIdfilters addObject:filter];
280280

281-
HBLogDebug(@"NOTIBLOCK - adding filter to dict for appkey: --%@--", dictKey);
281+
NSLog(@"NOTIBLOCK - adding filter to dict for appkey: --%@--", dictKey);
282282
}
283283
} else {
284-
HBLogDebug(@"NOTIBLOCK - springboard data load was nil");
284+
NSLog(@"NOTIBLOCK - springboard data load was nil");
285285
}
286286
}
287287

@@ -307,7 +307,7 @@ Code to hide the banner dropdown view
307307
- (void)viewWillAppear:(BOOL)animated {
308308
%orig;
309309
if(self.view.hidden) {
310-
HBLogDebug(@"NOTIBLOCK - NCNotificationShortLookViewController will appear - dismissing banner");
310+
NSLog(@"NOTIBLOCK - NCNotificationShortLookViewController will appear - dismissing banner");
311311
[self dismissViewControllerAnimated:NO completion:nil];
312312
}
313313
}

control

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: com.shemeshapps.notiblock
22
Name: NotiBlock
33
Depends: mobilesubstrate, ws.hbang.common, preferenceloader, applist
4-
Version: 0.0.2
4+
Version: 0.0.3
55
Architecture: iphoneos-arm
66
Description: NotiBlock - Block notifications and take control of your digital well-being
77
Push notifications are a gift and a curse, allowing you to get notified instantly of important information, but also opening a door into letting people and apps interrupt your life without your consent. The tools Apple gives us are not powerful enough to stop the spam of notifications, and required a more advanced tool set.
@@ -17,7 +17,7 @@ Description: NotiBlock - Block notifications and take control of your digital we
1717

1818
If you like this tweak and want to help support my development of free open source tweaks, feel free to donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YP44VSWZCTGE4&source=url
1919

20-
Comptible with iOS 11 - 13.5
20+
Comptible with iOS 13.0 - 14.4
2121
Maintainer: ShemeshApps
2222
Author: ShemeshApps
2323
Section: Tweaks

notiblockpref/NBPAppListTableViewCell.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1515
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1616
if (self) {
1717
self.appIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,0,0)];
18-
[self addSubview:self.appIcon];
18+
[self.contentView addSubview:self.appIcon];
1919

2020
self.appName = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];
2121
self.appName.numberOfLines = 1;
22-
[self addSubview:self.appName];
22+
[self.contentView addSubview:self.appName];
2323
}
2424
return self;
2525
}

notiblockpref/NBPButtonTableViewCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1717
self.buttonTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
1818
self.buttonTextLabel.text = @"Select App To Filter...";
1919
[self.buttonTextLabel setTextColor:[UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0]];
20-
[self addSubview:self.buttonTextLabel];
20+
[self.contentView addSubview:self.buttonTextLabel];
2121
}
2222
return self;
2323
}

notiblockpref/NBPDatePickerTableViewCell.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1515
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1616
if (self) {
1717
self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];
18-
[self addSubview:self.descriptionLabel];
18+
[self.contentView addSubview:self.descriptionLabel];
1919

2020
self.selectedTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2121
self.selectedTimeLabel.textAlignment = NSTextAlignmentRight;
22-
[self addSubview:self.selectedTimeLabel];
22+
[self.contentView addSubview:self.selectedTimeLabel];
2323

2424
self.datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2525
self.datePicker.datePickerMode = UIDatePickerModeTime;
2626
[self.datePicker addTarget:self action:@selector(dateIsChanged:) forControlEvents:UIControlEventValueChanged];
2727
self.datePicker.hidden = YES;
2828

29-
[self addSubview:self.datePicker];
29+
[self.contentView addSubview:self.datePicker];
3030
[self dateIsChanged:self.datePicker];
3131
}
3232
return self;

notiblockpref/NBPImageTableViewCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
2222
UIImage *myImage = [UIImage imageWithContentsOfFile:imagePath];
2323
self.cellImageView.contentMode = UIViewContentModeScaleAspectFit;
2424
self.cellImageView.image = myImage;
25-
[self addSubview:self.cellImageView];
25+
[self.contentView addSubview:self.cellImageView];
2626
}
2727
return self;
2828
}

notiblockpref/NBPPickerTableViewCell.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1616
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1717
if (self) {
1818
self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
19-
[self addSubview:self.descriptionLabel];
19+
[self.contentView addSubview:self.descriptionLabel];
2020

2121
self.selectedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2222
self.selectedLabel.textAlignment = NSTextAlignmentRight;
23-
[self addSubview:self.selectedLabel];
23+
[self.contentView addSubview:self.selectedLabel];
2424

2525
self.picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2626
self.picker.dataSource = self;
2727
self.picker.delegate = self;
2828
self.picker.hidden = NO;
2929
self.picker.tag = 1;
3030

31-
[self addSubview:self.picker];
31+
[self.contentView addSubview:self.picker];
3232
}
3333
return self;
3434
}

notiblockpref/NBPRootPreferenceController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ -(void)viewFilters {
2323
}
2424

2525
-(void)respringPhone {
26-
HBLogDebug(@"NOTIBLOCK - respring phone");
26+
NSLog(@"NOTIBLOCK - respring phone");
2727
[HBRespringController respring];
2828
}
2929

notiblockpref/NBPRootTableViewController.m

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
int __isOSVersionAtLeast(int major, int minor, int patch) { NSOperatingSystemVersion version; version.majorVersion = major; version.minorVersion = minor; version.patchVersion = patch; return [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:version]; }
2-
3-
41
#import "NBPRootTableViewController.h"
52
#import <Cephei/HBPreferences.h>
63

@@ -30,9 +27,8 @@ - (void)addButtonTapped:(id)sender {
3027
NBPAddViewController *one = [[NBPAddViewController alloc]init];
3128
one.delegate = self;
3229
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:one];
33-
if (@available(iOS 13, *)) {
34-
navController.modalInPresentation = YES;
35-
}
30+
navController.modalInPresentation = YES;
31+
3632
[self presentViewController:navController animated:YES completion:nil];
3733
}
3834

@@ -72,9 +68,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
7268
one.currentFilter = [self.filterList objectAtIndex:indexPath.row];
7369

7470
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:one];
75-
if (@available(iOS 13, *)) {
76-
navController.modalInPresentation = YES;
77-
}
71+
navController.modalInPresentation = YES;
72+
7873
[self presentViewController:navController animated:YES completion:nil];
7974
[tableView deselectRowAtIndexPath:indexPath animated:YES];
8075
}

0 commit comments

Comments
 (0)