Skip to content

Commit

Permalink
Add name sorting because I forgor
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduytran0 committed Aug 5, 2024
1 parent 499cae4 commit 96926fa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions LCRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ - (void)loadView {
self.objects = [[fm contentsOfDirectoryAtPath:self.bundlePath error:nil] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id object, NSDictionary *bindings) {
return [object hasSuffix:@".app"];
}]].mutableCopy;
[self.objects sortUsingSelector:@selector(caseInsensitiveCompare:)];

// Setup tweak directory
self.tweakPath = [NSString stringWithFormat:@"%@/Tweaks", self.docPath];
Expand Down Expand Up @@ -290,7 +291,7 @@ - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocum
return;
}
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[self patchExecAndSignIfNeed:indexPath];
[self patchExecAndSignIfNeed:indexPath shouldSort:YES];
});
}

Expand Down Expand Up @@ -410,7 +411,7 @@ - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleFo
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.navigationItem.leftBarButtonItems[0].enabled = YES;
[NSUserDefaults.standardUserDefaults setObject:self.objects[indexPath.row] forKey:@"selected"];
[self patchExecAndSignIfNeed:indexPath];
[self patchExecAndSignIfNeed:indexPath shouldSort:NO];
}

- (void)preprocessBundleBeforeSiging:(NSURL *)bundleURL completion:(dispatch_block_t)completion {
Expand All @@ -425,7 +426,7 @@ - (void)preprocessBundleBeforeSiging:(NSURL *)bundleURL completion:(dispatch_blo
});
}

- (void)patchExecAndSignIfNeed:(NSIndexPath *)indexPath {
- (void)patchExecAndSignIfNeed:(NSIndexPath *)indexPath shouldSort:(BOOL)sortNames {
NSString *appPath = [NSString stringWithFormat:@"%@/%@", self.bundlePath, self.objects[indexPath.row]];
NSString *infoPath = [NSString stringWithFormat:@"%@/Info.plist", appPath];
NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:infoPath];
Expand All @@ -448,6 +449,10 @@ - (void)patchExecAndSignIfNeed:(NSIndexPath *)indexPath {
}

if (!LCUtils.certificatePassword) {
if (sortNames) {
[self.objects sortUsingSelector:@selector(caseInsensitiveCompare:)];
[self.tableView reloadData];
}
return;
}

Expand Down Expand Up @@ -503,6 +508,9 @@ - (void)patchExecAndSignIfNeed:(NSIndexPath *)indexPath {

[progress removeObserver:self forKeyPath:@"fractionCompleted"];
[self.progressView removeFromSuperview];
if (sortNames) {
[self.objects sortUsingSelector:@selector(caseInsensitiveCompare:)];
}
[self.tableView reloadData];
});
}];
Expand Down

0 comments on commit 96926fa

Please sign in to comment.