-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTPPrefsObserver.m
30 lines (27 loc) · 1.22 KB
/
TPPrefsObserver.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
#import "TPPrefsObserver.h"
@implementation TPPrefsObserver
- (instancetype)init {
self = [super init];
[self observeKey:@"TPAllowLandscapeHomeScreen"];
[self observeKey:@"TPForceEnableMedusaForLandscapeOnlyApps"];
[self observeKey:@"TPHideStageManagerResizeCorners"];
[self observeKey:@"TPUseiPadAppSwitchingAnimation"];
// Fetch keys
[self observeValueForKeyPath:nil ofObject:nil change:nil context:nil];
return self;
}
- (void)observeKey:(NSString *)key {
[NSUserDefaults.standardUserDefaults addObserver:self
forKeyPath:key
options:NSKeyValueObservingOptionNew
context:NULL];
}
- (void)observeValueForKeyPath:(NSString *)
keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
self.allowLandscapeHomeScreen = [defaults boolForKey:@"TPAllowLandscapeHomeScreen"];
self.forceEnableMedusaForLandscapeOnlyApps = [defaults boolForKey:@"TPForceEnableMedusaForLandscapeOnlyApps"];
self.hideStageManagerResizeCorners = [defaults boolForKey:@"TPHideStageManagerResizeCorners"];
self.useiPadAppSwitchingAnimation = [defaults boolForKey:@"TPUseiPadAppSwitchingAnimation"];
}
@end