Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 9c3a64a

Browse files
committed
v4.3
1 parent 9f2c265 commit 9c3a64a

15 files changed

Lines changed: 365 additions & 133 deletions

BMHomeTableViewController.xm

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
#import "Headers/Batchomatic.h"
12
#import "Headers/BMHomeTableViewController.h"
23
#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"
115

6+
@implementation BMHomeTableViewController //The main Batchomatic screen where you choose what feature to use
127
- (void)viewDidLoad {
138
[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+
1519
[self createNavBar];
1620
[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-
});
2021
}
2122

2223
- (void)viewWillAppear:(BOOL)animated {
@@ -30,7 +31,7 @@
3031
self.navigationItem.title = @"Batchomatic";
3132
UINavigationBar *navBar = self.navigationController.navigationBar;
3233
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)];
3435
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Help" style:UIBarButtonItemStylePlain target:self action:@selector(didTapHelpButton)];
3536

3637
NSBundle *bundle = [NSBundle bundleWithPath:@"/Library/Batchomatic/Icon.bundle"]; //custom view in UINavigationBarLargeTitleView for the icon
@@ -55,20 +56,21 @@
5556
}
5657

5758
- (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];
6061
[tableView registerClass:[UITableViewCell self] forCellReuseIdentifier:@"Cell"];
6162
tableView.dataSource = self;
6263
tableView.delegate = self;
6364
self.tableView = tableView;
6465
}
6566

6667
- (void)addVersionNumberFooter { //Add the version number as footer of the UITableView
68+
Batchomatic *bm = [Batchomatic sharedInstance];
6769
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 28)];
6870
UILabel *label = [[UILabel alloc] initWithFrame:footer.frame];
69-
label.text = @"v4.2.1";
71+
label.text = @"v4.3";
7072
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
7274
label.textColor = [UIColor whiteColor];
7375
}
7476
[footer addSubview:label];
@@ -85,7 +87,7 @@
8587
return 3;
8688
}
8789
else if (section == 1) {
88-
return 2;
90+
return 3;
8991
}
9092
else {
9193
return 1;
@@ -109,13 +111,14 @@
109111
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
110112
static NSString *cellIdentifier = @"Cell";
111113
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
112-
if (cell == nil) {
114+
if (!cell) {
113115
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
114116
}
117+
Batchomatic *bm = [Batchomatic sharedInstance];
115118

116119
cell.textLabel.font = [UIFont boldSystemFontOfSize:22];
117120
cell.textLabel.textAlignment = NSTextAlignmentCenter;
118-
if ([Batchomatic sharedInstance].packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) {
121+
if (bm.packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) {
119122
cell.textLabel.textColor = [UIColor whiteColor];
120123
}
121124

@@ -124,7 +127,7 @@
124127
cell.textLabel.text = [cellTitles objectAtIndex:indexPath.row];
125128
}
126129
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"];
128131
cell.textLabel.text = [cellTitles objectAtIndex:indexPath.row];
129132
}
130133
else { //bottom section
@@ -151,9 +154,12 @@
151154
}
152155
else if (indexPath.section == 1) {
153156
if (indexPath.row == 0) {
154-
[self didTapEitherRemoveAllButton:1];
157+
[self didTapRepackTweakButton];
155158
}
156159
else if (indexPath.row == 1) {
160+
[self didTapEitherRemoveAllButton:1];
161+
}
162+
else if (indexPath.row == 2) {
157163
[self didTapEitherRemoveAllButton:2];
158164
}
159165
}
@@ -184,7 +190,8 @@
184190
}
185191

186192
- (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) {
188195
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[BMInstallTableViewController alloc] init]];
189196
[self presentViewController:nav animated:YES completion:nil];
190197
}
@@ -196,6 +203,11 @@
196203
}
197204
}
198205

206+
- (void)didTapRepackTweakButton {
207+
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[BMRepackTableViewController alloc] init]];
208+
[self presentViewController:nav animated:YES completion:nil];
209+
}
210+
199211
- (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
200212
Batchomatic *bm = [Batchomatic sharedInstance];
201213
bm.maxSteps = 1;
@@ -235,33 +247,16 @@
235247
[[Batchomatic sharedInstance] endProcessingDialog:nil transition:false shouldOpenBMHomeViewControllerFirst:false];
236248
}
237249

238-
- (void)didTapDismissButton {
250+
- (void)didTapBackButton {
239251
[self dismissViewControllerAnimated:YES completion:nil];
240252
}
241253

242254
- (void)didTapHelpButton {
243255
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];
262257
}
263258

264259
- (void)dealloc {
265-
[[NSNotificationCenter defaultCenter] removeObserver:self];
260+
[Batchomatic sharedInstance].currentlyInstalledTweaks = nil;
266261
}
267262
@end

BMInstallTableViewController.xm

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
#import "Headers/BMInstallTableViewController.h"
21
#import "Headers/Batchomatic.h"
2+
#import "Headers/BMInstallTableViewController.h"
33

44
@implementation BMInstallTableViewController //The installation options screen
55
- (void)viewDidLoad {
66
[super viewDidLoad];
7-
[Batchomatic sharedInstance].bm_BMInstallTableViewController = self;
8-
[self createTableView];
7+
Batchomatic *bm = [Batchomatic sharedInstance];
8+
bm.bm_BMInstallTableViewController = self;
9+
910
self.navigationItem.title = @"Batchomatic";
10-
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(didTapDismissButton)];
11+
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(didTapBackButton)];
12+
[self createTableView];
1113
}
1214

1315
- (void)viewWillAppear:(BOOL)animated {
@@ -16,8 +18,8 @@
1618
}
1719

1820
- (void)createTableView {
19-
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, 1/[UIScreen mainScreen].scale);
20-
UITableView *tableView = [[UITableView alloc]initWithFrame:frame style:UITableViewStylePlain];
21+
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, [UIScreen mainScreen].bounds.size.height);
22+
UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
2123
[tableView registerClass:[UITableViewCell self] forCellReuseIdentifier:@"Cell"];
2224
tableView.dataSource = self;
2325
tableView.delegate = self;
@@ -46,12 +48,13 @@
4648
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
4749
static NSString *cellIdentifier = @"Cell";
4850
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
49-
if (cell == nil) {
51+
if (!cell) {
5052
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
5153
}
54+
Batchomatic *bm = [Batchomatic sharedInstance];
5255

5356
cell.textLabel.font = [UIFont boldSystemFontOfSize:22];
54-
if ([Batchomatic sharedInstance].packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) {
57+
if (bm.packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) {
5558
cell.textLabel.textColor = [UIColor whiteColor];
5659
}
5760

@@ -60,7 +63,6 @@
6063
cell.textLabel.text = [cellTitles objectAtIndex:indexPath.row];
6164
cell.selectionStyle = UITableViewCellSelectionStyleNone;
6265

63-
Batchomatic *bm = [Batchomatic sharedInstance];
6466
UISwitch *toggle = [[UISwitch alloc] initWithFrame:CGRectZero];
6567
toggle.tag = indexPath.row;
6668
[toggle setOn:YES animated:YES];
@@ -131,7 +133,7 @@
131133
}];
132134
}
133135

134-
- (void)didTapDismissButton {
136+
- (void)didTapBackButton {
135137
[self dismissViewControllerAnimated:YES completion:nil];
136138
}
137139
@end

BMRepackTableViewController.xm

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#import "Headers/Batchomatic.h"
2+
#import "Headers/BMRepackTableViewController.h"
3+
4+
@implementation BMRepackTableViewController //The Repack deb screen
5+
- (void)viewDidLoad {
6+
[super viewDidLoad];
7+
Batchomatic *bm = [Batchomatic sharedInstance];
8+
bm.bm_BMRepackTableViewController = self;
9+
10+
self.navigationItem.title = @"Batchomatic";
11+
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(didTapBackButton)];
12+
if (bm.currentlyInstalledTweaks) {
13+
[self createTableView];
14+
}
15+
else {
16+
[self placeActivityIndicator];
17+
}
18+
}
19+
20+
- (void)viewWillAppear:(BOOL)animated {
21+
[super viewWillAppear:animated];
22+
[Batchomatic sharedInstance].bm_currentBMController = self;
23+
}
24+
25+
- (void)placeActivityIndicator {
26+
UIActivityIndicatorView *spinner;
27+
if (@available(iOS 13, *)) {
28+
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
29+
}
30+
else {
31+
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
32+
}
33+
Batchomatic *bm = [Batchomatic sharedInstance];
34+
if (bm.packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) {
35+
spinner.color = [UIColor colorWithRed:0.557 green:0.557 blue:0.576 alpha:1];
36+
}
37+
38+
spinner.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); //center the UIActivityIndicator
39+
CGFloat height = (CGRectGetHeight(self.view.bounds) / 2) - self.navigationController.navigationBar.frame.size.height;
40+
spinner.center = CGPointMake(CGRectGetWidth(self.view.bounds) / 2, height);
41+
42+
spinner.hidesWhenStopped = YES;
43+
[self.view addSubview:spinner];
44+
[spinner startAnimating];
45+
self.spinner = spinner;
46+
}
47+
48+
- (void)createTableView {
49+
[self.spinner stopAnimating];
50+
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, [UIScreen mainScreen].bounds.size.height);
51+
UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
52+
[tableView registerClass:[UITableViewCell self] forCellReuseIdentifier:@"Cell"];
53+
tableView.dataSource = self;
54+
tableView.delegate = self;
55+
self.tableView = tableView;
56+
}
57+
58+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
59+
return [[Batchomatic sharedInstance].currentlyInstalledTweaks count];
60+
}
61+
62+
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { //Hide the cell separator lines of extraneous/unused cells
63+
return [[UIView alloc] init];
64+
}
65+
66+
//--------------------------------------------------------------------------------------------------------------------------
67+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
68+
static NSString *cellIdentifier = @"Cell";
69+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
70+
if (!cell || !cell.detailTextLabel) { //in order to make detailTextLabel work, you must check if cell is nil or if cell.detailTextLabel is nil
71+
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
72+
}
73+
Batchomatic *bm = [Batchomatic sharedInstance];
74+
NSDictionary *tweakInfo = [bm.currentlyInstalledTweaks objectAtIndex:indexPath.row];
75+
76+
cell.textLabel.font = [UIFont systemFontOfSize:18];
77+
cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
78+
cell.detailTextLabel.textColor = [UIColor systemGrayColor]; //make the package ID text a light gray
79+
if (bm.packageManager == 2 && [%c(ZBDevice) darkModeEnabled]) {
80+
cell.textLabel.textColor = [UIColor whiteColor];
81+
cell.detailTextLabel.textColor = [UIColor colorWithRed:0.557 green:0.557 blue:0.576 alpha:1];
82+
}
83+
cell.textLabel.text = [tweakInfo objectForKey:@"name"];
84+
cell.detailTextLabel.text = [NSString stringWithFormat:@"\t%@", [tweakInfo objectForKey:@"packageID"]];
85+
86+
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
87+
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
88+
return cell;
89+
}
90+
91+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
92+
Batchomatic *bm = [Batchomatic sharedInstance];
93+
NSDictionary *tweakInfo = [bm.currentlyInstalledTweaks objectAtIndex:indexPath.row];
94+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
95+
[self didTapRepackTweakWithIdentifier:[tweakInfo objectForKey:@"packageID"]];
96+
}
97+
98+
//--------------------------------------------------------------------------------------------------------------------------
99+
- (void)didTapRepackTweakWithIdentifier:(NSString *)packageID {
100+
Batchomatic *bm = [Batchomatic sharedInstance];
101+
bm.maxSteps = 1;
102+
NSString *msg = [NSString stringWithFormat:@"Repacking tweak to .deb....\n%@", packageID];
103+
[bm showProcessingDialog:msg includeStage:true startingStep:1 autoPresent:false];
104+
[self presentViewController:bm.processingDialog animated:YES completion:^{
105+
[bm repackTweakWithIdentifier:packageID];
106+
}];
107+
}
108+
109+
- (void)didTapBackButton {
110+
[self dismissViewControllerAnimated:YES completion:nil];
111+
}
112+
@end

0 commit comments

Comments
 (0)