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 0000000..5008ddf Binary files /dev/null and b/cnonprefs/Resources/.DS_Store differ diff --git a/cnonprefs/Resources/Root.plist b/cnonprefs/Resources/Root.plist index 00ec691..cdbc364 100644 --- a/cnonprefs/Resources/Root.plist +++ b/cnonprefs/Resources/Root.plist @@ -10,25 +10,25 @@ default 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 3f9a332..82ca525 100644 Binary files a/cnonprefs/Resources/twitter@2x.png and b/cnonprefs/Resources/twitter@2x.png differ diff --git a/control b/control index 52f8aeb..1c1388a 100644 --- a/control +++ b/control @@ -1,7 +1,7 @@ Package: com.yaypixxo.cnon Name: CustomNoOlderNotifications Depends: mobilesubstrate, preferenceloader -Version: 2.1.0 +Version: 2.2.0 Architecture: iphoneos-arm Description: Change the "No Older Notifications" text to a custom one! Icon: https://yaypixxo.com/assets/com.yaypixxo.cnon.png