Skip to content

Commit

Permalink
Fix preference is not updated sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
brian9206 committed Jul 9, 2018
1 parent 0dc7c2f commit 3ab53a5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pw.ssnull.homedockx
Name: HomeDockX
Depends: firmware (>= 11.0), mobilesubstrate, preferenceloader, applist
Version: 1.2.1
Version: 1.2.2
Architecture: iphoneos-arm
Description: iPhone X gesture with perfectly compatible iPad floating dock
Maintainer: Brian Choi <brian9206@hotmail.com>
Expand Down
7 changes: 6 additions & 1 deletion prefsbundle/HomeDockXRootListController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ - (NSArray *)specifiers {
}

- (void)respring {
system("sleep 2 && killall SpringBoard");
CFPreferencesSynchronize(CFSTR("pw.ssnull.homedockx"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
system("killall SpringBoard");
#pragma GCC diagnostic pop
}

@end
23 changes: 16 additions & 7 deletions src/HomeDockXPreference.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@
*/
#import "includes/HomeDockXPreference.h"

static HomeDockXPreference *sharedInstance;
static HomeDockXPreference *sharedInstance = NULL;

@implementation HomeDockXPreference {
NSDictionary *_prefsDict;
}

+ (HomeDockXPreference *)sharedInstance {
return sharedInstance;
}
if (!sharedInstance) {
sharedInstance = [[HomeDockXPreference alloc] init];
}

+ (void)load {
sharedInstance = [[self alloc] init];
return sharedInstance;
}

- (id)init {
if ((self = [super init])) {
NSDictionary *prefs = [[NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/pw.ssnull.homedockx.plist"] copy];

NSDictionary *prefs = NULL;

CFStringRef appID = CFSTR("pw.ssnull.homedockx");
CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);

if (keyList) {
prefs = (NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFRelease(keyList);
}

if (prefs) {
self.enableHomeGesture = [[prefs objectForKey:@"enableHomeGesture"] boolValue];
self.enableDock = [[prefs objectForKey:@"enableDock"] boolValue];
Expand Down Expand Up @@ -60,3 +68,4 @@ - (BOOL)isBlacklisted:(NSString*)bundleIdentifier {
}

@end

0 comments on commit 3ab53a5

Please sign in to comment.