|
| 1 | +#import "Headers/Batchomatic.h" |
1 | 2 | #import "Headers/BMHomeTableViewController.h" |
2 | 3 | #import "Headers/BMInstallTableViewController.h" |
3 | | -#import "Headers/Batchomatic.h" |
4 | | - |
5 | | -@implementation BMHomeTableViewController //The main "Batchomatic" screen where you choose what feature to use |
6 | | -- (instancetype)init { |
7 | | - self = [super init]; |
8 | | - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkDeb) name:UIApplicationWillEnterForegroundNotification object:nil]; //see "- (void)checkDeb" for an explanation about this |
9 | | - return self; |
10 | | -} |
| 4 | +#import "Headers/BMRepackTableViewController.h" |
11 | 5 |
|
| 6 | +@implementation BMHomeTableViewController //The main Batchomatic screen where you choose what feature to use |
12 | 7 | - (void)viewDidLoad { |
13 | 8 | [super viewDidLoad]; |
14 | | - [Batchomatic sharedInstance].bm_BMHomeTableViewController = self; |
| 9 | + Batchomatic *bm = [Batchomatic sharedInstance]; |
| 10 | + bm.bm_BMHomeTableViewController = self; |
| 11 | + |
| 12 | + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { //must use dispatch_async to prevent the UI from freezing |
| 13 | + [bm determineInfoAboutDeb]; |
| 14 | + }); |
| 15 | + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { |
| 16 | + [bm loadListOfCurrentlyInstalledTweaks]; |
| 17 | + }); |
| 18 | + |
15 | 19 | [self createNavBar]; |
16 | 20 | [self createTableView]; |
17 | | - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { //we need to check the .deb, but we don't want that to lag/delay opening the Batchomatic UI |
18 | | - [self checkDeb]; |
19 | | - }); |
20 | 21 | } |
21 | 22 |
|
22 | 23 | - (void)viewWillAppear:(BOOL)animated { |
|
30 | 31 | self.navigationItem.title = @"Batchomatic"; |
31 | 32 | UINavigationBar *navBar = self.navigationController.navigationBar; |
32 | 33 | navBar.prefersLargeTitles = YES; |
33 | | - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(didTapDismissButton)]; |
| 34 | + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(didTapBackButton)]; |
34 | 35 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Help" style:UIBarButtonItemStylePlain target:self action:@selector(didTapHelpButton)]; |
35 | 36 |
|
36 | 37 | NSBundle *bundle = [NSBundle bundleWithPath:@"/Library/Batchomatic/Icon.bundle"]; //custom view in UINavigationBarLargeTitleView for the icon |
|
55 | 56 | } |
56 | 57 |
|
57 | 58 | - (void)createTableView { |
58 | | - CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, 1/[UIScreen mainScreen].scale); |
59 | | - UITableView *tableView = [[UITableView alloc]initWithFrame:frame style:UITableViewStylePlain]; |
| 59 | + CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, [UIScreen mainScreen].bounds.size.height); |
| 60 | + UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain]; |
60 | 61 | [tableView registerClass:[UITableViewCell self] forCellReuseIdentifier:@"Cell"]; |
61 | 62 | tableView.dataSource = self; |
62 | 63 | tableView.delegate = self; |
63 | 64 | self.tableView = tableView; |
64 | 65 | } |
65 | 66 |
|
66 | 67 | - (void)addVersionNumberFooter { //Add the version number as footer of the UITableView |
| 68 | + Batchomatic *bm = [Batchomatic sharedInstance]; |
67 | 69 | UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 28)]; |
68 | 70 | UILabel *label = [[UILabel alloc] initWithFrame:footer.frame]; |
69 | | - label.text = @"v4.2.1"; |
| 71 | + label.text = @"v4.3"; |
70 | 72 | label.textAlignment = NSTextAlignmentCenter; |
71 | | - if ([Batchomatic sharedInstance].packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) { //Zebra has its own dark mode that doesn't follow the iOS 13 dark mode, so we need to manually set the text color when in Zebra's dark mode |
| 73 | + if (bm.packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) { //Zebra has its own dark mode that doesn't follow the iOS 13 dark mode, so we need to manually set the text color when in Zebra's dark mode |
72 | 74 | label.textColor = [UIColor whiteColor]; |
73 | 75 | } |
74 | 76 | [footer addSubview:label]; |
|
85 | 87 | return 3; |
86 | 88 | } |
87 | 89 | else if (section == 1) { |
88 | | - return 2; |
| 90 | + return 3; |
89 | 91 | } |
90 | 92 | else { |
91 | 93 | return 1; |
|
109 | 111 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
110 | 112 | static NSString *cellIdentifier = @"Cell"; |
111 | 113 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; |
112 | | - if (cell == nil) { |
| 114 | + if (!cell) { |
113 | 115 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; |
114 | 116 | } |
| 117 | + Batchomatic *bm = [Batchomatic sharedInstance]; |
115 | 118 |
|
116 | 119 | cell.textLabel.font = [UIFont boldSystemFontOfSize:22]; |
117 | 120 | cell.textLabel.textAlignment = NSTextAlignmentCenter; |
118 | | - if ([Batchomatic sharedInstance].packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) { |
| 121 | + if (bm.packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) { |
119 | 122 | cell.textLabel.textColor = [UIColor whiteColor]; |
120 | 123 | } |
121 | 124 |
|
|
124 | 127 | cell.textLabel.text = [cellTitles objectAtIndex:indexPath.row]; |
125 | 128 | } |
126 | 129 | else if (indexPath.section == 1) { //middle section |
127 | | - NSArray *cellTitles = @[@"Remove all repos", @"Remove all tweaks"]; |
| 130 | + NSArray *cellTitles = @[@"Repack tweak to .deb", @"Remove all repos", @"Remove all tweaks"]; |
128 | 131 | cell.textLabel.text = [cellTitles objectAtIndex:indexPath.row]; |
129 | 132 | } |
130 | 133 | else { //bottom section |
|
151 | 154 | } |
152 | 155 | else if (indexPath.section == 1) { |
153 | 156 | if (indexPath.row == 0) { |
154 | | - [self didTapEitherRemoveAllButton:1]; |
| 157 | + [self didTapRepackTweakButton]; |
155 | 158 | } |
156 | 159 | else if (indexPath.row == 1) { |
| 160 | + [self didTapEitherRemoveAllButton:1]; |
| 161 | + } |
| 162 | + else if (indexPath.row == 2) { |
157 | 163 | [self didTapEitherRemoveAllButton:2]; |
158 | 164 | } |
159 | 165 | } |
|
184 | 190 | } |
185 | 191 |
|
186 | 192 | - (void)didTapInstallDebButton { //Shows the Install options screen (BMInstallTableViewController) if your .deb is currently installed |
187 | | - if ([Batchomatic sharedInstance].debIsInstalled) { |
| 193 | + Batchomatic *bm = [Batchomatic sharedInstance]; |
| 194 | + if (bm.debIsInstalled) { |
188 | 195 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[BMInstallTableViewController alloc] init]]; |
189 | 196 | [self presentViewController:nav animated:YES completion:nil]; |
190 | 197 | } |
|
196 | 203 | } |
197 | 204 | } |
198 | 205 |
|
| 206 | +- (void)didTapRepackTweakButton { |
| 207 | + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[BMRepackTableViewController alloc] init]]; |
| 208 | + [self presentViewController:nav animated:YES completion:nil]; |
| 209 | +} |
| 210 | + |
199 | 211 | - (void)didTapEitherRemoveAllButton:(int)type { //Asks the user if they want to keep utiity repos and BigBoss when removing all repos. Also handles asking to keep package managers, Filza, and Batchomatic itself when removing all tweaks |
200 | 212 | Batchomatic *bm = [Batchomatic sharedInstance]; |
201 | 213 | bm.maxSteps = 1; |
|
235 | 247 | [[Batchomatic sharedInstance] endProcessingDialog:nil transition:false shouldOpenBMHomeViewControllerFirst:false]; |
236 | 248 | } |
237 | 249 |
|
238 | | -- (void)didTapDismissButton { |
| 250 | +- (void)didTapBackButton { |
239 | 251 | [self dismissViewControllerAnimated:YES completion:nil]; |
240 | 252 | } |
241 | 253 |
|
242 | 254 | - (void)didTapHelpButton { |
243 | 255 | NSDictionary *options = @{UIApplicationOpenURLOptionUniversalLinksOnly:@NO}; |
244 | | - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.reddit.com/r/jailbreak/comments/cqarr6/release_batchomatic_v30_on_bigboss_batch_install/"] options:options completionHandler:nil]; |
245 | | -} |
246 | | - |
247 | | -//-------------------------------------------------------------------------------------------------------------------------- |
248 | | -- (void)checkDeb { //Everytime the main Batchomatic screen enters the foreground, it checks if your .deb is installed and whether its online or offfline. Determining this info takes about 1 second, which causes 1 second of lag whenever you press the "Install .deb" or "Proceed" buttons/rows. This implementation with dispatch_async, NSNotificationCenter, and UIApplicationWillEnterForegroundNotification fixes that |
249 | | - Batchomatic *bm = [Batchomatic sharedInstance]; |
250 | | - if ([bm isDebInstalled]) { |
251 | | - bm.debIsInstalled = true; |
252 | | - } |
253 | | - else { |
254 | | - bm.debIsInstalled = false; |
255 | | - } |
256 | | - if ([bm isDebOnline]) { |
257 | | - bm.debIsOnline = true; |
258 | | - } |
259 | | - else { |
260 | | - bm.debIsOnline = false; |
261 | | - } |
| 256 | + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.reddit.com/r/jailbreak/comments/cqarr6/release_batchomatic_v30_on_bigboss_batch_install"] options:options completionHandler:nil]; |
262 | 257 | } |
263 | 258 |
|
264 | 259 | - (void)dealloc { |
265 | | - [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 260 | + [Batchomatic sharedInstance].currentlyInstalledTweaks = nil; |
266 | 261 | } |
267 | 262 | @end |
0 commit comments