From 96926fa8626228aa096ec81958fbb8e529a18057 Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Mon, 5 Aug 2024 12:37:49 +0700 Subject: [PATCH] Add name sorting because I forgor --- LCRootViewController.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/LCRootViewController.m b/LCRootViewController.m index 8caa1ae..d908af4 100644 --- a/LCRootViewController.m +++ b/LCRootViewController.m @@ -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]; @@ -290,7 +291,7 @@ - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocum return; } [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; - [self patchExecAndSignIfNeed:indexPath]; + [self patchExecAndSignIfNeed:indexPath shouldSort:YES]; }); } @@ -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 { @@ -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]; @@ -448,6 +449,10 @@ - (void)patchExecAndSignIfNeed:(NSIndexPath *)indexPath { } if (!LCUtils.certificatePassword) { + if (sortNames) { + [self.objects sortUsingSelector:@selector(caseInsensitiveCompare:)]; + [self.tableView reloadData]; + } return; } @@ -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]; }); }];