From 419938c34dc435239943780ef665bda5314b4633 Mon Sep 17 00:00:00 2001 From: yaypixxo Date: Sun, 5 Jan 2020 16:49:52 +0100 Subject: [PATCH] remove need for respring --- Makefile | 4 +- Tweak.xm | 84 +++++++++++++++++++---------- cnonprefs/CNONRootListController.m | 20 ++++--- cnonprefs/Makefile | 4 +- cnonprefs/Resources/.DS_Store | Bin 0 -> 6148 bytes cnonprefs/Resources/Root.plist | 16 +++--- cnonprefs/Resources/twitter@2x.png | Bin 1755 -> 1499 bytes control | 2 +- 8 files changed, 80 insertions(+), 50 deletions(-) create mode 100644 cnonprefs/Resources/.DS_Store diff --git a/Makefile b/Makefile index 1e127cf..d49a274 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -ARCHS = arm64 -TARGET = iphone:clang:11.2:11.2 +ARCHS = arm64 arm64e +TARGET = iphone:clang:10.3:10.3 include $(THEOS)/makefiles/common.mk diff --git a/Tweak.xm b/Tweak.xm index feea7e1..40d905b 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -2,51 +2,77 @@ @property (nonatomic,copy) NSString *string; @end -@interface NCNotificationListSectionRevealHintView : UIView --(void)_updateHintTitle; +@interface NCNotificationListSectionRevealHintView : UIView +//-(void)_updateHintTitle; +//-(void)setRevealHintTitle; +@property (nonatomic,retain)SBUILegibilityLabel *revealHintTitle; @end -static BOOL enabled; -static NSString* customText = @""; +// prefs +@interface NSUserDefaults (CnonPrefs) +-(id)objectForKey:(NSString *)key inDomain:(NSString *)domain; +-(void)setObject:(id)value forKey:(NSString *)key inDomain:(NSString *)domain; +@end -#define kIdentifier @"com.yaypixxo.cnonprefs" -#define kSettingsChangedNotification (CFStringRef)@"com.yaypixxo.cnonprefs/ReloadPrefs" -#define kSettingsPath @"/var/mobile/Library/Preferences/com.yaypixxo.cnonprefs.plist" +static NSString *nsDomainString = @"com.yaypixxo.cnon"; +static NSString *nsNotificationString = @"com.yaypixxo.cnon/preferences.changed"; + +// declare switch and string +static BOOL enabled; +static NSString *customText = @""; + +static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { + NSNumber *eEnabled = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:nsDomainString]; + NSString *eCustomText = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:@"customText" inDomain:nsDomainString]; + + enabled = (eEnabled) ? [eEnabled boolValue]:NO; + customText = eCustomText; //(eCustomText) ? [eCustomText value]:@""; +} + +/*#ifndef kCFCoreFoundationVersionNumber_iOS_13_0 +#define kCFCoreFoundationVersionNumber_iOS_13_0 1665.15 +#endif + +#define kSLSystemVersioniOS13 kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_13_0*/ + +/*%group ios13 %hook NCNotificationListSectionRevealHintView --(void)layoutSubviews { - %orig; +-(void)setRevealHintTitle:(SBUILegibilityLabel *)arg1 { if (enabled) { - [MSHookIvar(self, "_revealHintTitle") setString:customText]; + arg1 = customText; } } %end -static void reloadPrefs() { - CFPreferencesAppSynchronize((CFStringRef)kIdentifier); +%end*/ - NSDictionary *prefs = nil; - if ([NSHomeDirectory() isEqualToString:@"/var/mobile"]) { - CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (keyList != nil) { - prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)); - if (prefs == nil) - prefs = [NSDictionary dictionary]; - CFRelease(keyList); - } - } - else { - prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath]; +//%group ios12 + +%hook NCNotificationListSectionRevealHintView + +-(void)didMoveToWindow { + %orig; + if (enabled) { + self.revealHintTitle.string = customText; } +} - enabled = [prefs objectForKey:@"enabled"] ? [(NSNumber *)[prefs objectForKey:@"enabled"] boolValue] : true; - customText = [prefs objectForKey:@"customText"] ? [prefs objectForKey:@"customText"] : changeNotiTxt; +%end - } +//%end %ctor { - reloadPrefs(); - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)reloadPrefs, kSettingsChangedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + // check iOS version + /*if (kSLSystemVersioniOS13) { + %init(ios13); + } + else { + %init(ios12); + }*/ + + notificationCallback(NULL, NULL, NULL, NULL, NULL); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce); } \ No newline at end of file diff --git a/cnonprefs/CNONRootListController.m b/cnonprefs/CNONRootListController.m index d786a6e..0cac39d 100644 --- a/cnonprefs/CNONRootListController.m +++ b/cnonprefs/CNONRootListController.m @@ -1,5 +1,5 @@ #include "CNONRootListController.h" -#import +//#import @implementation CNONRootListController @@ -13,10 +13,10 @@ - (void)respring:(id)sender { [self.view endEditing:YES]; - [NSThread sleepForTimeInterval:0.5f]; + /*[NSThread sleepForTimeInterval:0.5f]; pid_t pid; const char* args[] = {"killall", "backboardd", NULL}; - posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); + posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL);*/ } - (void)openTwitter { @@ -24,18 +24,22 @@ if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetbot:"]]) { url = [NSURL URLWithString:@"tweetbot:///user_profile/Ra1nPix"]; - } else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitterrific:"]]) { + } + else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitterrific:"]]) { url = [NSURL URLWithString:@"twitterrific:///profile?screen_name=Ra1nPix"]; - } else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetings:"]]) { + } + else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetings:"]]) { url = [NSURL URLWithString:@"tweetings:///user?screen_name=Ra1nPix"]; - } else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter:"]]) { + } + else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter:"]]) { url = [NSURL URLWithString:@"twitter://user?screen_name=Ra1nPix"]; - } else { + } + else { url = [NSURL URLWithString:@"https://mobile.twitter.com/Ra1nPix"]; } // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - [[UIApplication sharedApplication] openURL:url]; + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; } @end diff --git a/cnonprefs/Makefile b/cnonprefs/Makefile index 62cb2c9..1253a2a 100644 --- a/cnonprefs/Makefile +++ b/cnonprefs/Makefile @@ -1,5 +1,5 @@ -ARCHS = arm64 -TARGET = iphone:11.2:11.2 +ARCHS = arm64 arm64e +TARGET = iphone:10.3:10.3 include $(THEOS)/makefiles/common.mk diff --git a/cnonprefs/Resources/.DS_Store b/cnonprefs/Resources/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0default defaults - com.yaypixxo.cnonprefs + com.yaypixxo.cnon key enabled label Enable PostNotification - com.yaypixxo.cnonprefs/ReloadPrefs + com.yaypixxo.cnon/preferences.changed cell PSGroupCell footerText - Type your custom message or leave blank to hide the text. + Type your custom text or leave blank to hide the text cell PSEditTextCell defaults - com.yaypixxo.cnonprefs + com.yaypixxo.cnon default key @@ -36,7 +36,7 @@ placeholder custom text here PostNotification - com.yaypixxo.cnonprefs/ReloadPrefs + com.yaypixxo.cnon/preferences.changed cell @@ -44,13 +44,13 @@ action respring label - Respring + Apply cell PSGroupCell label - Follow me + Follow me on Twitter action @@ -64,6 +64,6 @@ title - CNON + CustomNoOlderNotifications diff --git a/cnonprefs/Resources/twitter@2x.png b/cnonprefs/Resources/twitter@2x.png index 3f9a33262416fbfe6e6bea166f22635a461bed06..82ca525a22aba1de04870048e136df06d2a98e0a 100644 GIT binary patch literal 1499 zcmV<11tj{3P)Px#AY({UO#lFTCIA3{ga82g z0001h=l}q9FaQARU;qF*m;eA5aGbhPJOBU%Nl8RORP9=6Y*bYgo~<*Tjaj-+JNtB| zGi`xVPzVKSDYZ&vu^@|L(;zJnjJ2^Wl7^+qQX4GQQcZUdDjE?9SO^LzAc`UZ3POd5 z8khLPE$(|i<0Q>ElfLcF?T_~*-;bHe+;_fn?>+C_bB{zKLWBqrB1DJ~F-(zUQlw7G z*4}>iB*Xo4ZZnoo&C%UuOH{gO+eH)xt=zP1M*Nzi^`0v?d$Rrx$5Tz-n>F(iHzgS4 zDNM%nrm3gX);f-{GQ^pp^c~vlKCg|Hju1rI5WwtgUy-(lsqj$lT4O&NwAB))u$L8?AKbUW zc_#RKUY4$ql|k#vlAppK;W?#35=%t&f57ZLTWx)rtN0*aZ*X5dzAgQF==X3eYop%Y z;rl!|K-VgJFUjptJvXtAulPtjT<_^)y^3v#G49ZTp0Bl^(5q!ep~d^sRM{Wy^8Z0Z z{1*46V35?rN_DgI42vcNGzCK%HF>1AINX4U%5aX54rr;ezC=R&&QkkJRQVuv$@43v|0l>T|#s^3lNs@bO9dB|LjivffX~Ozs zv%-qc3#XcvMk`?vicKrhdU!bigWPy7^RM15t_$@QmJXZ+Xp3S)6iYZe0D+3O0KP}w6~4`>TwL%goddU>KC4gheDMp{W*7*lqywjUNud=RLs zy|B)ClD0S|EFPyX72E*;qUybcre%Yx#lwxL{3v7+h2Y``SA38oz{|riGb}GQR|zg2 zu*55D=UTj9;o<=$rs0?*VPz7%z!Bo+h9q%nB_m2XQj|mpv z8COkPY$#E2%5=nz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