From 4847937db26f965b7e2228f04ac3840c60086361 Mon Sep 17 00:00:00 2001 From: semvis123 Date: Thu, 27 May 2021 21:29:02 +0200 Subject: [PATCH] Clean up and fix preferences --- .../NSARootListController.h | 1 + .../NSARootListController.m | 15 +++++++++++++++ Tweak.h | 11 ----------- control | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/NoSpatialAudioBtnPreferences/NSARootListController.h b/NoSpatialAudioBtnPreferences/NSARootListController.h index c6c0e8e..3f880a6 100644 --- a/NoSpatialAudioBtnPreferences/NSARootListController.h +++ b/NoSpatialAudioBtnPreferences/NSARootListController.h @@ -1,4 +1,5 @@ #import +#import #import @interface NSARootListController : PSListController diff --git a/NoSpatialAudioBtnPreferences/NSARootListController.m b/NoSpatialAudioBtnPreferences/NSARootListController.m index 69d3b17..736bfbe 100644 --- a/NoSpatialAudioBtnPreferences/NSARootListController.m +++ b/NoSpatialAudioBtnPreferences/NSARootListController.m @@ -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]; } diff --git a/Tweak.h b/Tweak.h index ac261a3..0b8c4b8 100644 --- a/Tweak.h +++ b/Tweak.h @@ -1,12 +1 @@ #import - -@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 diff --git a/control b/control index 22ec231..f227dbf 100644 --- a/control +++ b/control @@ -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)