-
Notifications
You must be signed in to change notification settings - Fork 3
/
Tweak.xm
104 lines (80 loc) · 2.46 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
97
98
99
100
101
102
103
104
#include <CoreFoundation/CFNotificationCenter.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSString.h>
@interface NSUserDefaults (UFS_Category)
- (id)objectForKey:(NSString *)key inDomain:(NSString *)domain;
- (void)setObject:(id)value forKey:(NSString *)key inDomain:(NSString *)domain;
@end
static NSString *domainString = @"com.gnos.bloard";
static NSString *notificationString = @"com.gnos.bloard/preferences.changed";
static BOOL enabled;
static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSNumber *n = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:domainString];
enabled = (n)? [n boolValue]:YES;
}
%ctor {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
//set initial `enable' variable
notificationCallback(NULL, NULL, NULL, NULL, NULL);
//register for notifications
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)notificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
[pool release];
}
/*
As of 0.1.2 this section has been disabled.
// Black background in pickerView
%hook UIPickerView
-(void)setBackgroundColor:(UIColor *)color {
if (enabled) {
color = [UIColor colorWithWhite:40.0/255 alpha:0.7];
}
%orig(color);
}
%end
%hook UIDatePickerContentView
// White text in date picker
-(UILabel *)titleLabel {
if (enabled) {
// white UIPickerView text
UILabel *titleLabel = %orig();
titleLabel.textColor = [UIColor whiteColor];
return titleLabel;
} else {
return %orig();
}
}
%end
// White UIPickerView text entries
%hook UIPickerTableViewTitledCell
- (void)setAttributedTitle:(NSAttributedString *)attributedString {
if (enabled) {
// white UIPickerView text
NSAttributedString *title = [[NSAttributedString alloc] initWithString:[attributedString string] attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
%orig(title);
[title release];
} else {
%orig();
}
}
%end
*/
// Dark keyboard background
%hook UIKBRenderConfig
- (BOOL)lightKeyboard {
BOOL light = %orig();
if (enabled) {
light = NO;
}
return light;
}
%end
// Dark PIN keypad in Settings
%hook DevicePINKeypad
- (id)initWithFrame:(CGRect)frame {
id keypad = %orig();
if (enabled) {
[keypad setBackgroundColor:[UIColor colorWithWhite:40.0/255 alpha:0.7]];
}
return keypad;
}
%end