mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-21 07:41:59 +00:00
Update plistPath
This commit is contained in:
parent
c5c8ca2ccb
commit
0177d38d67
1 changed files with 17 additions and 15 deletions
|
|
@ -89,6 +89,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)resetIcon {
|
- (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) {
|
[[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Error resetting icon: %@", error.localizedDescription);
|
NSLog(@"Error resetting icon: %@", error.localizedDescription);
|
||||||
|
|
@ -96,34 +101,31 @@
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Icon reset successfully");
|
NSLog(@"Icon reset successfully");
|
||||||
[self showAlertWithTitle:@"Success" message:@"Icon reset successfully"];
|
[self showAlertWithTitle:@"Success" message:@"Icon reset successfully"];
|
||||||
[self.tableView reloadData];
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self.tableView reloadData];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)saveIcon {
|
- (void)saveIcon {
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
|
NSString *selectedIcon = self.selectedIconIndex >= 0 ? self.appIcons[self.selectedIconIndex] : nil;
|
||||||
NSString *selectedIconName = self.selectedIconIndex >= 0 ? [self.appIcons[self.selectedIconIndex] lastPathComponent] : nil;
|
if (selectedIcon) {
|
||||||
|
NSString *iconName = [selectedIcon.lastPathComponent stringByDeletingPathExtension];
|
||||||
if (selectedIconName) {
|
|
||||||
NSDictionary *iconsDict = [infoDict objectForKey:@"CFBundleIcons"];
|
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
|
||||||
NSDictionary *primaryIconDict = [iconsDict objectForKey:@"CFBundlePrimaryIcon"];
|
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
|
||||||
NSArray *iconFiles = [primaryIconDict objectForKey:@"CFBundleIconFiles"];
|
[infoDict setObject:iconName forKey:@"ALTAppIcon"];
|
||||||
|
[infoDict writeToFile:plistPath atomically:YES];
|
||||||
|
|
||||||
UIImage *selectedIconImage = [UIImage imageWithContentsOfFile:self.appIcons[self.selectedIconIndex]];
|
[[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) {
|
||||||
CGSize appIconSize = CGSizeMake(60, 60);
|
|
||||||
|
|
||||||
selectedIconImage = [self resizeImage:selectedIconImage toSize:appIconSize];
|
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setAlternateIconImage:selectedIconImage completionHandler:^(NSError * _Nullable error) {
|
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Error setting alternate icon: %@", error.localizedDescription);
|
NSLog(@"Error setting alternate icon: %@", error.localizedDescription);
|
||||||
[self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"];
|
[self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"];
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Alternate icon set successfully");
|
NSLog(@"Alternate icon set successfully");
|
||||||
[self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"];
|
[self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"];
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.tableView reloadData];
|
[self.tableView reloadData];
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue