@@ -28,6 +28,8 @@ static BOOL isIndicatorEnabled;
28
28
static BOOL isToastEnabled;
29
29
static BOOL isLockIndicatorEnabled;
30
30
31
+ %group init
32
+
31
33
%hook SpringBoard
32
34
- (void )frontDisplayDidChange:(id )arg1 {
33
35
%orig ;
@@ -142,7 +144,6 @@ static BOOL isLockIndicatorEnabled;
142
144
}
143
145
%end
144
146
145
-
146
147
%hook FBScene
147
148
-(void )updateSettings:(id )arg1 withTransitionContext:(id )arg2 completion:(id )arg3{
148
149
FBProcess *process = self.clientProcess ;
@@ -270,6 +271,8 @@ static BOOL isLockIndicatorEnabled;
270
271
}
271
272
%end
272
273
274
+ %end
275
+
273
276
static void prefsLockIndicatorChanged () {
274
277
Immortalizer *immortalizer = [Immortalizer sharedInstance ];
275
278
NSArray *lockedBundleIDs = [[NSUserDefaults standardUserDefaults ] arrayForKey: @" LockedBundleIDs" ];
@@ -290,15 +293,15 @@ static void immortalizerPreferencesChanged() {
290
293
}
291
294
292
295
static void prefsNotifsChanged () {
293
- Immortalizer *immortalizer = [Immortalizer sharedInstance ];
294
- NSArray *immortalBundleIDs = [[NSUserDefaults standardUserDefaults ] arrayForKey: @" ImmortalForegroundBundleIDs" ];
295
- for (NSString * immortalApp in immortalBundleIDs) {
296
- if ([immortalizer isNotificationEnabledForBundleIdentifier: immortalApp]) {
297
- [[%c (UNSUserNotificationServer) sharedInstance ] _didChangeApplicationState: 4 forBundleIdentifier: immortalApp];
298
- } else {
299
- [[%c (UNSUserNotificationServer) sharedInstance ] _didChangeApplicationState: 8 forBundleIdentifier: immortalApp];
296
+ Immortalizer *immortalizer = [Immortalizer sharedInstance ];
297
+ NSArray *immortalBundleIDs = [[NSUserDefaults standardUserDefaults ] arrayForKey: @" ImmortalForegroundBundleIDs" ];
298
+ for (NSString * immortalApp in immortalBundleIDs) {
299
+ if ([immortalizer isNotificationEnabledForBundleIdentifier: immortalApp]) {
300
+ [[%c (UNSUserNotificationServer) sharedInstance ] _didChangeApplicationState: 4 forBundleIdentifier: immortalApp];
301
+ } else {
302
+ [[%c (UNSUserNotificationServer) sharedInstance ] _didChangeApplicationState: 8 forBundleIdentifier: immortalApp];
303
+ }
300
304
}
301
- }
302
305
}
303
306
304
307
static void prefsIndicatorChanged () {
@@ -311,15 +314,20 @@ static void prefsToastChanged() {
311
314
isToastEnabled = [toastPrefs objectForKey: @" isToastEnabled" ] ? [toastPrefs boolForKey: @" isToastEnabled" ] : YES ;
312
315
}
313
316
317
+ static id observer;
314
318
static void loadAllImmortalizerPrefs () {
315
- immortalizerPreferencesChanged ();
316
- prefsNotifsChanged ();
317
- prefsIndicatorChanged ();
318
- prefsToastChanged ();
319
- prefsLockIndicatorChanged ();
319
+ observer = [NSNotificationCenter .defaultCenter addObserverForName: UIApplicationDidFinishLaunchingNotification object: nil queue: [NSOperationQueue mainQueue ] usingBlock: ^(NSNotification *_) {
320
+ immortalizerPreferencesChanged ();
321
+ prefsNotifsChanged ();
322
+ prefsIndicatorChanged ();
323
+ prefsToastChanged ();
324
+ prefsLockIndicatorChanged ();
325
+ [NSNotificationCenter .defaultCenter removeObserver: observer];
326
+ }];
320
327
}
321
328
322
329
%ctor {
330
+ %init (init);
323
331
loadAllImmortalizerPrefs ();
324
332
CFNotificationCenterAddObserver (CFNotificationCenterGetDarwinNotifyCenter (), NULL , (CFNotificationCallback)immortalizerPreferencesChanged, CFSTR (" com.sergy.immortalizer.preferenceschanged" ), NULL , CFNotificationSuspensionBehaviorDeliverImmediately);
325
333
CFNotificationCenterAddObserver (CFNotificationCenterGetDarwinNotifyCenter (), NULL , (CFNotificationCallback)prefsNotifsChanged, CFSTR (" com.sergy.immortalizer.preferenceschanged.notifs" ), NULL , CFNotificationSuspensionBehaviorDeliverImmediately);
0 commit comments