mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Uses alternate app icon for AltStore in My Apps, if one is chosen
This commit is contained in:
@@ -111,6 +111,8 @@ class MyAppsViewController: UICollectionViewController, PeekPopPreviewing
|
||||
}
|
||||
|
||||
(self as PeekPopPreviewing).registerForPreviewing(with: self, sourceView: self.collectionView)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(MyAppsViewController.didChangeAppIcon(_:)), name: UIApplication.didChangeAppIconNotification, object: nil)
|
||||
}
|
||||
|
||||
override func viewIsAppearing(_ animated: Bool)
|
||||
@@ -1593,6 +1595,43 @@ private extension MyAppsViewController
|
||||
sender.endRefreshing()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func didChangeAppIcon(_ notification: Notification)
|
||||
{
|
||||
guard let altStoreApp = InstalledApp.fetchAltStore(in: DatabaseManager.shared.viewContext) else { return }
|
||||
|
||||
// Remove previous icon from cache.
|
||||
self.activeAppsDataSource.prefetchItemCache.removeObject(forKey: altStoreApp)
|
||||
self.inactiveAppsDataSource.prefetchItemCache.removeObject(forKey: altStoreApp)
|
||||
|
||||
if let indexPath = self.activeAppsDataSource.fetchedResultsController.indexPath(forObject: altStoreApp)
|
||||
{
|
||||
let indexPath = IndexPath(item: indexPath.item, section: Section.activeApps.rawValue)
|
||||
|
||||
if #available(iOS 15, *)
|
||||
{
|
||||
self.collectionView.reconfigureItems(at: [indexPath])
|
||||
}
|
||||
else
|
||||
{
|
||||
self.collectionView.reloadItems(at: [indexPath])
|
||||
}
|
||||
}
|
||||
|
||||
if let indexPath = self.inactiveAppsDataSource.fetchedResultsController.indexPath(forObject: altStoreApp)
|
||||
{
|
||||
let indexPath = IndexPath(item: indexPath.item, section: Section.inactiveApps.rawValue)
|
||||
|
||||
if #available(iOS 15, *)
|
||||
{
|
||||
self.collectionView.reconfigureItems(at: [indexPath])
|
||||
}
|
||||
else
|
||||
{
|
||||
self.collectionView.reloadItems(at: [indexPath])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension MyAppsViewController
|
||||
|
||||
@@ -13,6 +13,11 @@ import AltSign
|
||||
import AltStoreCore
|
||||
import Roxas
|
||||
|
||||
extension UIApplication
|
||||
{
|
||||
static let didChangeAppIconNotification = Notification.Name("io.altstore.AppManager.didChangeAppIcon")
|
||||
}
|
||||
|
||||
private final class AltIcon: Decodable
|
||||
{
|
||||
var name: String
|
||||
@@ -190,6 +195,10 @@ extension AltAppIconsViewController
|
||||
alertController.addAction(.ok)
|
||||
self.present(alertController, animated: true)
|
||||
}
|
||||
else
|
||||
{
|
||||
NotificationCenter.default.post(name: UIApplication.didChangeAppIconNotification, object: icon)
|
||||
}
|
||||
|
||||
if let selectedIndexPath = self.collectionView.indexPathsForSelectedItems?.first
|
||||
{
|
||||
|
||||
@@ -159,6 +159,16 @@ public extension InstalledApp
|
||||
|
||||
func loadIcon(completion: @escaping (Result<UIImage?, Error>) -> Void)
|
||||
{
|
||||
if self.bundleIdentifier == StoreApp.altstoreAppID, let iconName = UIApplication.alt_shared?.alternateIconName
|
||||
{
|
||||
// Use alternate app icon for AltStore, if one is chosen.
|
||||
|
||||
let image = UIImage(named: iconName)
|
||||
completion(.success(image))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let hasAlternateIcon = self.hasAlternateIcon
|
||||
let alternateIconURL = self.alternateIconURL
|
||||
let fileURL = self.fileURL
|
||||
|
||||
Reference in New Issue
Block a user