/
Tweak.xm
executable file
·177 lines (150 loc) · 5.71 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#import "Tweak.h"
void reloadColors() {
fetchColor = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.archergs.labelPrefs.plist"];
nongColor = fetchColor[@"nongColor"];
unlockColor = fetchColor[@"unlockColor"];
[preferences setObject:nongColor forKey:@"nongColor"];
[preferences setObject:unlockColor forKey:@"unlockColor"];
NSLog(@"nongColor: %@", nongColor);
}
%group Labels
/*%hook NCNotificationCombinedListViewController
-(void)viewWillAppear:(BOOL)arg1{
orig;
}
%end */
%hook NCNotificationListSectionRevealHintView
/*
-(void)setLegibilitySettings:(_UILegibilitySettings *)settings{
NSString *customColor = [preferences objectForKey:@"nongColor"];
[settings setPrimaryColor:LCPParseColorString(customColor, @"#FFFFFF")];
%orig(settings);
}*/
-(void)layoutSubviews {
%orig;
// get the values from the prefs
id isEnabled = [preferences objectForKey:@"isEnabled"];
NSString *customText = [preferences objectForKey:@"customTextNotif"];
NSUInteger characterCount = [customText length];
NSString *customColor = [preferences objectForKey:@"nongColor"];
NSLog(@"Custom color: %@", customColor);
// if the enabled switch is on, set the custom text!
if ([isEnabled isEqual:@1] && characterCount > 0){
NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet];
if ([[customText stringByTrimmingCharactersInSet: set] length] == 0)
{
customText = @"";
}
[self revealHintTitle].string = customText;
}
if ([isEnabled isEqual:@1]){
NSLog(@"Running color code");
/*[self revealHintTitle].legibilitySettings.primaryColor = LCPParseColorString(customColor, @"#FFFFFF");
[[self revealHintTitle] setTextColor:LCPParseColorString(customColor, @"#FFFFFF")];
[[self revealHintTitle] _updateLabelForLegibilitySettings];
[[self revealHintTitle] _updateLegibilityView];*/
}
}
%end
%hook SBUICallToActionLabel
-(void)layoutSubviews{
%orig;
// get the values from the prefs
id isEnabled = [preferences objectForKey:@"isEnabled"];
NSString *customText = [preferences objectForKey:@"customTextUnlock"];
NSUInteger characterCount = [customText length];
//NSString *customColor = [preferences objectForKey:@"unlockColor"];
NSLog(@"press home text:%@", customText);
// if the enabled switch is on, set the custom text!
if ([isEnabled isEqual:@1] && characterCount > 0){
NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet];
if ([[customText stringByTrimmingCharactersInSet: set] length] == 0)
{
customText = @"";
}
[self label].string = customText;
/*[self label].legibilitySettings.primaryColor = LCPParseColorString(customColor, @"#FFFFFF");
[[self label] _updateLabelForLegibilitySettings];
[[self label] _updateLegibilityView];*/
}
}
/*
-(void)setLabel:(SBUILegibilityLabel *)textLabel{
// get the values from the prefs
id isEnabled = [preferences objectForKey:@"isEnabled"];
NSString *customText = [preferences objectForKey:@"customTextUnlock"];
NSUInteger characterCount = [customText length];
//NSString *customColor = [preferences objectForKey:@"unlockColor"];
NSLog(@"press home text legLabel:%@", customText);
// if the enabled switch is on, set the custom text!
if ([isEnabled isEqual:@1] && characterCount > 0){
NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet];
if ([[customText stringByTrimmingCharactersInSet: set] length] == 0)
{
customText = @"";
}
//[self label].string = customText;
/*[self label].legibilitySettings.primaryColor = LCPParseColorString(customColor, @"#FFFFFF");
[[self label] _updateLabelForLegibilitySettings];
[[self label] _updateLegibilityView];
}
textLabel.string = customText;
//textLabel.textColor = [UIColor redColor];
%orig(textLabel);
}
-(void)setText:(NSString *)string{
// get the values from the prefs
id isEnabled = [preferences objectForKey:@"isEnabled"];
NSString *customText = [preferences objectForKey:@"customTextUnlock"];
NSUInteger characterCount = [customText length];
//NSString *customColor = [preferences objectForKey:@"unlockColor"];
NSLog(@"press home text String:%@", customText);
// if the enabled switch is on, set the custom text!
if ([isEnabled isEqual:@1] && characterCount > 0){
NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet];
if ([[customText stringByTrimmingCharactersInSet: set] length] == 0)
{
customText = @"";
}
//[self label].string = customText;
/*[self label].legibilitySettings.primaryColor = LCPParseColorString(customColor, @"#FFFFFF");
[[self label] _updateLabelForLegibilitySettings];
[[self label] _updateLegibilityView];
}
string = customText;
%orig(string);
}*/
%end
%hook SBTelephonyManager
-(void)_reallySetOperatorName:(id)arg1 inSubscriptionContext:(id)arg2{
// get the values from the prefs
id isEnabled = [preferences objectForKey:@"isEnabled"];
NSString *customText = [preferences objectForKey:@"customTextCarrier"];
NSUInteger characterCount = [customText length];
NSLog(@"%@", customText);
if ([isEnabled isEqual:@1] && characterCount > 0){
NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet];
if ([[customText stringByTrimmingCharactersInSet: set] length] == 0)
{
customText = @"";
}
arg1 = customText;
arg2 = [self subscriptionContext];
}
return %orig(arg1, arg2);
}
%end
// end group
%end
%ctor{
preferences = [[HBPreferences alloc] initWithIdentifier:@"com.archergs.labelPrefs"];
[preferences registerDefaults:@{
@"isEnabled": @YES,
@"customTextCarrier": @"",
@"customTextNotif": @"",
@"customTextUnlock": @"",
@"nongColor": @"#FFFFFF:1.0"
}];
%init(Labels);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)reloadColors, (CFStringRef)@"com.archergs.labelPrefs.color", NULL, (CFNotificationSuspensionBehavior)kNilOptions);
}