-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tweak.xm
43 lines (40 loc) · 1.4 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#import <QuartzCore/QuartzCore.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <substrate.h>
#import "CReachabilityController.h"
#import "Defines.h"
#define kBundlePath @"/Library/Application Support/CRSettings/CRSettings.bundle"
static BOOL enabled = NO;
// for iOS9&iOS10
%hook SBMainWorkspace
-(void)handleReachabilityModeActivated {
%orig;
if (enabled){
SBWindow *backgroundView = MSHookIvar<SBWindow*>(self,"_reachabilityEffectWindow");
[[CReachabilityController sharedInstance] setBackgroundWindow:backgroundView];
[[CReachabilityController sharedInstance] setupImage];
}
}
%end
static void loadPrefs()
{
CFPreferencesAppSynchronize(CFSTR("com.watcher.crsettings"));
enabled = !CFPreferencesCopyAppValue(CFSTR("enabled"), CFSTR("com.watcher.crsettings")) ? NO : [(id)CFPreferencesCopyAppValue(CFSTR("enabled"), CFSTR("com.watcher.crsettings")) boolValue];
if (enabled) {
NSLog(@"Enabled");
} else {
NSLog(@"NOT!Enabled");
}
}
%ctor
{
NSLog(@"Loading..");
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
(CFNotificationCallback)loadPrefs,
CFSTR("com.watcher.crsettings.settings/changed"),
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
loadPrefs();
}