-
Notifications
You must be signed in to change notification settings - Fork 4
/
Tweak.xm
executable file
·96 lines (71 loc) · 2.51 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#import <dlfcn.h>
#import <UIKit/UIKit.h>
#include <notify.h>
#include <objc/message.h>
#import "FLEXManager.h"
// SpringBoard
#import <SpringBoard/SpringBoard.h>
%hook SpringBoard
-(void)frontDisplayDidChange:(id)newDisplay {
%orig(newDisplay);
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.pba.FlexTool.plist"];
id setting = [settings objectForKey:[NSString stringWithFormat:@"FlexToolEnabled-com.apple.springboard"]];
if (setting && [setting boolValue]) {
if (newDisplay == NULL){
[[FLEXManager sharedManager] showExplorer];
} else {
[[FLEXManager sharedManager] hideExplorer];
}
}
}
%end
// FlexTool.h
__attribute__((visibility("hidden")))
@interface FlexTool : NSObject {
@private
}
@end
#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/FlexToolBundle.bundle"
// FlexTool.m
@implementation FlexTool
+ (instancetype)sharedInstance
{
static FlexTool *_sharedFactory;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedFactory = [[self alloc] init];
});
return _sharedFactory;
}
- (id)init
{
if ((self = [super init]))
{
}
return self;
}
-(void)inject {
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.pba.FlexTool.plist"];
id setting = [settings objectForKey:[NSString stringWithFormat:@"FlexToolEnabled-%@", [NSBundle mainBundle].bundleIdentifier]];
if (setting && [setting boolValue]) {
[[FLEXManager sharedManager] showExplorer];
}
}
@end
/*static NSString *nsNotificationString = @"com.pba.flextool.springboardsettingschanged";
static BOOL notificationState;
static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
notificationState = !notificationState;
}*/
%ctor {
// Add observer for UIApplicationDidBecomeActiveNotification
[[NSNotificationCenter defaultCenter] addObserver:[FlexTool sharedInstance] selector:@selector(inject) name:UIApplicationDidBecomeActiveNotification object:nil];
/*// Add observer for ALChangeNotification
notificationCallback(NULL, NULL, NULL, NULL, NULL);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
notificationCallback,
(CFStringRef)nsNotificationString,
NULL,
CFNotificationSuspensionBehaviorCoalesce);*/
}