Skip to content

Commit

Permalink
settings should now apply w/o respringing
Browse files Browse the repository at this point in the history
  • Loading branch information
vanwijkdave committed Dec 21, 2022
1 parent c6e945c commit 2b4d6c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
15 changes: 11 additions & 4 deletions Tweak/Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,26 @@ UILabel *fromLabel;
%end


HBPreferences *file;
extern NSString *const HBPreferencesDidChangeNotification;

void loadPrefs() {
HBPreferences *file = [[HBPreferences alloc] initWithIdentifier:@"com.daveapps.quitallprefs"];
file = [[HBPreferences alloc] initWithIdentifier:@"com.daveapps.quitallprefs"];
enabled = [([file objectForKey:@"kEnabled"] ?: @(YES)) boolValue];
darkStyle = [([file objectForKey:@"kDarkButton"] ?: @(0)) intValue];
leftButtonPlacement = [([file objectForKey:@"kLeftPlacement"] ?: @(NO)) boolValue];
bottomPlacement = [([file objectForKey:@"kBottom"] ?: @(NO)) boolValue];
}

if (enabled) {
%init(tweak);
}
static void PreferencesChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
loadPrefs();
}

// Load the preferences before the other code is ran.
%ctor {
loadPrefs();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) PreferencesChangedCallback, CFSTR("me.dave.quitall.reloadprefs"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
if (enabled) {
%init(tweak);
}
}
Binary file not shown.
12 changes: 11 additions & 1 deletion Tweak/quitallprefs/Resources/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<string>kEnabled</string>
<key>label</key>
<string>Enabled</string>
<key>PostNotification</key>
<string>me.dave.quitall.reloadprefs</string>
</dict>
<dict>
<key>cell</key>
Expand All @@ -49,6 +51,8 @@
<string>Light</string>
<string>Dark</string>
</array>
<key>PostNotification</key>
<string>me.dave.quitall.reloadprefs</string>
</dict>
<dict>
<key>cell</key>
Expand All @@ -61,6 +65,8 @@
<string>kLeftPlacement</string>
<key>label</key>
<string>Place button at the left side</string>
<key>PostNotification</key>
<string>me.dave.quitall.reloadprefs</string>
</dict>
<dict>
<key>cell</key>
Expand All @@ -73,6 +79,8 @@
<string>kBottom</string>
<key>label</key>
<string>Place button at the bottom</string>
<key>PostNotification</key>
<string>me.dave.quitall.reloadprefs</string>
</dict>
<dict>
<key>cell</key>
Expand All @@ -81,8 +89,10 @@
<string></string>
</dict>
<dict>
<key>cellClass</key>
<string>HBTintedTableCell</string>
<key>cell</key>
<string>HBLinkTableCell</string>
<string>PSButtonCell</string>
<key>label</key>
<string>Select apps to exclude</string>
<key>action</key>
Expand Down
2 changes: 1 addition & 1 deletion Tweak/quitallprefs/zodiacs.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(id)re
versionLabel = [[UILabel alloc] initWithFrame:versionFrame];
[versionLabel setFont:[UIFont systemFontOfSize:22 weight: UIFontWeightMedium] ];
versionLabel.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.8];
versionLabel.text = @"3.0";
versionLabel.text = @"3.1";

bgView.backgroundColor = [UIColor colorWithRed:0.46 green:0.72 blue:0.84 alpha:1.0];

Expand Down

0 comments on commit 2b4d6c0

Please sign in to comment.