-
Notifications
You must be signed in to change notification settings - Fork 1
/
LTMPrefsManager.m
43 lines (36 loc) · 1.3 KB
/
LTMPrefsManager.m
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
#include "LTMPrefsManager.h"
@implementation LTMPrefsManager
@synthesize enabled = _enabled, script = _script, theme = _theme, batteryView = _batteryView, data = _data;
static LTMPrefsManager *sharedManager;
+ (instancetype)sharedManager {
if(!sharedManager) {
sharedManager = [[self alloc] init];
}
return sharedManager;
}
- (instancetype)init {
self = [super init];
NSDictionary *preferences = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/lithium.plist"];
_enabled = ([preferences objectForKey:@"lithiumEnabled"] != nil) ? [[preferences objectForKey:@"lithiumEnabled"] boolValue] : YES;
self.theme = [preferences objectForKey:@"lithiumTheme"] ?: @"Habesha";
[preferences release];
return self;
}
- (void)setTheme:(NSMutableString*)theme {
_theme = theme;
if(_enabled) {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fileLocation = [[NSString alloc] initWithFormat:@"/var/mobile/Lithium/%@.js", _theme];
if(![fileManager fileExistsAtPath:fileLocation]) _enabled = NO;
else _script = [[NSMutableString alloc] initWithContentsOfFile:fileLocation encoding:NSUTF8StringEncoding error:nil];
[fileLocation release];
}
}
- (void)dealloc {
[_script release];
[_batteryView release];
[_theme release];
[_data release];
[super dealloc];
}
@end