Bläddra i källkod

Add preferences post notification

master
lint 5 år sedan
förälder
incheckning
ab771d8317
4 ändrade filer med 35 tillägg och 8 borttagningar
  1. +12
    -6
      prefs/Resources/Root.plist
  2. +7
    -0
      tweak/Apollo.xm
  3. +7
    -0
      tweak/Narwhal.xm
  4. +9
    -2
      tweak/Reddit.xm

+ 12
- 6
prefs/Resources/Root.plist Visa fil

@@ -7,10 +7,14 @@
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>To enable/disable, restart the app.</string>
<key>label</key>
<string>Enabled</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
@@ -23,6 +27,8 @@
<string>Enable Reddit</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
@@ -35,6 +41,8 @@
<string>Enable Apollo</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
@@ -53,6 +61,8 @@
<string>Apollo </string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
@@ -75,6 +85,8 @@
<string>Request timeout (seconds)</string>
</dict>
<dict>
<key>PostNotification</key>
<string>com.lint.undelete.prefs.changed</string>
<key>cell</key>
<string>PSSliderCell</string>
<key>default</key>
@@ -90,12 +102,6 @@
<key>showValue</key>
<true/>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>footerText</key>
<string>In order to apply preferences, restart the app. If changes do not immediately take effect, wait a few seconds and try again.</string>
</dict>
</array>
<key>title</key>
<string>TFDidThatSay?</string>

+ 7
- 0
tweak/Apollo.xm Visa fil

@@ -265,6 +265,10 @@ static void loadPrefs(){
}
}
static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
loadPrefs();
}
%ctor {
loadPrefs();
@@ -273,6 +277,9 @@ static void loadPrefs(){
if ([processName isEqualToString:@"Apollo"]){
if (isApolloEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
%init(Apollo, ApolloCommentsHeaderCellNode = objc_getClass("Apollo.CommentsHeaderCellNode"), ApolloCommentCellNode = objc_getClass("Apollo.CommentCellNode"), ApolloApolloButtonNode = objc_getClass("Apollo.ApolloButtonNode"));
}
}

+ 7
- 0
tweak/Narwhal.xm Visa fil

@@ -235,6 +235,10 @@ static void loadPrefs(){
}
}
static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
loadPrefs();
}
%ctor {
loadPrefs();
@@ -243,6 +247,9 @@ static void loadPrefs(){

if ([processName isEqualToString:@"narwhal"]){
if (isNarwhalEnabled){
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
%init(Narwhal);
}
}

+ 9
- 2
tweak/Reddit.xm Visa fil

@@ -4,7 +4,7 @@
static CGFloat pushshiftRequestTimeoutValue;
static BOOL isRedditEnabled;
NSArray *redditVersion;
static NSArray *redditVersion;
%group Reddit_v4_current
@@ -734,6 +734,10 @@ static void loadPrefs(){
}
}
static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
loadPrefs();
}
%ctor{
loadPrefs();
@@ -742,7 +746,10 @@ static void loadPrefs(){
redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
if ([processName isEqualToString:@"Reddit"]){
if (isRedditEnabled) {
if (isRedditEnabled) {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
if ([redditVersion[0] isEqualToString:@"4"]){
if ([redditVersion[1] integerValue] <= 32){
%init(Reddit_v4_ios10);

Laddar…
Avbryt
Spara