mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-04 15:59:48 +00:00
Update AppIconOptionsController.m (Experimental)
Experimental
This commit is contained in:
parent
021c5f916b
commit
813603b214
1 changed files with 21 additions and 43 deletions
|
|
@ -24,6 +24,8 @@
|
|||
self.tableView.delegate = self;
|
||||
[self.view addSubview:self.tableView];
|
||||
|
||||
self.appIcons = @[@"White", @"YTLitePlus", @"Blue", @"Outline", @"2012", @"2013", @"2007", @"Black", @"Oreo", @"uYou", @"2012_Cyan", @"uYouPlus"];
|
||||
|
||||
self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
NSBundle *backIcon = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]];
|
||||
UIImage *backImage = [UIImage imageNamed:@"Back.png" inBundle:backIcon compatibleWithTraitCollection:nil];
|
||||
|
|
@ -70,22 +72,18 @@
|
|||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
|
||||
}
|
||||
|
||||
NSString *iconPath = self.appIcons[indexPath.row];
|
||||
cell.textLabel.text = [iconPath.lastPathComponent stringByDeletingPathExtension];
|
||||
|
||||
UIImage *iconImage = [UIImage imageWithContentsOfFile:iconPath];
|
||||
cell.imageView.image = iconImage;
|
||||
cell.imageView.layer.cornerRadius = 10.0;
|
||||
cell.imageView.clipsToBounds = YES;
|
||||
cell.imageView.frame = CGRectMake(10, 10, 40, 40);
|
||||
cell.textLabel.frame = CGRectMake(60, 10, self.view.frame.size.width - 70, 40);
|
||||
|
||||
NSString *iconName = self.appIcons[indexPath.row];
|
||||
cell.textLabel.text = iconName;
|
||||
|
||||
UIImage *iconImage = [UIImage imageNamed:iconName];
|
||||
cell.imageView.image = [self resizeImage:iconImage newSize:CGSizeMake(40, 40)];
|
||||
|
||||
if (indexPath.row == self.selectedIconIndex) {
|
||||
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
||||
} else {
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
}
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
@ -97,11 +95,6 @@
|
|||
}
|
||||
|
||||
- (void)resetIcon {
|
||||
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
|
||||
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
|
||||
[infoDict removeObjectForKey:@"ALTAppIcon"];
|
||||
[infoDict writeToFile:plistPath atomically:YES];
|
||||
|
||||
[[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"Error resetting icon: %@", error.localizedDescription);
|
||||
|
|
@ -109,9 +102,7 @@
|
|||
} else {
|
||||
NSLog(@"Icon reset successfully");
|
||||
[self showAlertWithTitle:@"Success" message:@"Icon reset successfully"];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
|
@ -121,32 +112,19 @@
|
|||
NSLog(@"Alternate icons are not supported on this device.");
|
||||
return;
|
||||
}
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
NSString *selectedIcon = self.selectedIconIndex >= 0 ? self.appIcons[self.selectedIconIndex] : nil;
|
||||
if (selectedIcon) {
|
||||
NSString *iconName = [selectedIcon.lastPathComponent stringByDeletingPathExtension];
|
||||
|
||||
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
|
||||
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
|
||||
[infoDict setObject:iconName forKey:@"ALTAppIcon"];
|
||||
[infoDict writeToFile:plistPath atomically:YES];
|
||||
|
||||
[[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"Error setting alternate icon: %@", error.localizedDescription);
|
||||
[self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"];
|
||||
} else {
|
||||
NSLog(@"Alternate icon set successfully");
|
||||
[self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
}
|
||||
}];
|
||||
|
||||
NSString *iconName = self.appIcons[self.selectedIconIndex];
|
||||
|
||||
[[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"Error setting alternate icon: %@", error.localizedDescription);
|
||||
[self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"];
|
||||
} else {
|
||||
NSLog(@"Selected icon path is nil");
|
||||
NSLog(@"Alternate icon set successfully");
|
||||
[self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIImage *)resizeImage:(UIImage *)image toSize:(CGSize)size {
|
||||
|
|
|
|||
Loading…
Reference in a new issue