Skip to content

Commit

Permalink
Clean up and fix preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
semvis123 committed May 27, 2021
1 parent dd0f506 commit 4847937
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions NoSpatialAudioBtnPreferences/NSARootListController.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>
#import <spawn.h>

@interface NSARootListController : PSListController
Expand Down
15 changes: 15 additions & 0 deletions NoSpatialAudioBtnPreferences/NSARootListController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
}

-(id)readPreferenceValue:(PSSpecifier *)specifier {
NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
NSMutableDictionary *settings = [NSMutableDictionary dictionary];
[settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"];
}

- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
NSMutableDictionary *settings = [NSMutableDictionary dictionary];
[settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
[settings setObject:value forKey:specifier.properties[@"key"]];
[settings writeToFile:path atomically:YES];
}

-(void)twitter {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://twitter.com/semvis123"] options:@{} completionHandler:nil];
}
Expand Down
11 changes: 0 additions & 11 deletions Tweak.h
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
#import <Foundation/Foundation.h>

@interface NSDistributedNotificationCenter : NSNotificationCenter
+(id)defaultCenter;
-(void)postNotificationName:(id)arg1 object:(id)arg2 userInfo:(id)arg3 deliverImmediately:(BOOL)arg4;
-(void)addObserver:(id)arg1 selector:(SEL)arg2 name:(id)arg3 object:(id)arg4;
-(void)postNotificationName:(id)arg1 object:(id)arg2 userInfo:(id)arg3;
@end

@interface AVOutputDevice : NSObject
-(NSString *)name;
@end
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Description: Simple tweak that removes the spatial audio button
Maintainer: Sem Visscher
Author: Sem Visscher
Section: Tweaks
Depends: mobilesubstrate, preferenceloader, firmware (>=13.0)
Depends: mobilesubstrate, preferenceloader, firmware (>=14.0)

0 comments on commit 4847937

Please sign in to comment.