From 5a32a85e2aeb293af1f7a982edcde508f9e07fd1 Mon Sep 17 00:00:00 2001 From: yaypixxo Date: Sun, 5 Jan 2020 18:21:03 +0100 Subject: [PATCH] add iOS 13 support --- Tweak.xm | 53 +++++++++++++----------------- cnonprefs/CNONRootListController.m | 1 + cnonprefs/Resources/Root.plist | 2 +- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/Tweak.xm b/Tweak.xm index b91f08c..c07e06b 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -1,3 +1,14 @@ +// respring function +@interface FBSystemService : NSObject ++(id)sharedInstance; +-(void)exitAndRelaunch:(bool)arg1; +@end + +static void RespringDevice() { + [[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES]; +} + +// headers @interface SBUILegibilityLabel : UIView @property (nonatomic,copy) NSString *string; @property (assign,nonatomic) long long textAlignment; @@ -25,54 +36,36 @@ static void notificationCallback(CFNotificationCenterRef center, void *observer, NSString *eCustomText = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:@"customText" inDomain:nsDomainString]; enabled = (eEnabled) ? [eEnabled boolValue]:NO; - customText = eCustomText; //(eCustomText) ? [eCustomText value]:@""; + customText = eCustomText; } -/*#ifndef kCFCoreFoundationVersionNumber_iOS_13_0 +// check iOS version +#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)setRevealHintTitle:(SBUILegibilityLabel *)arg1 { - if (enabled) { - arg1 = customText; - } -} - -%end - -%end*/ - -//%group ios12 +#define kSLSystemVersioniOS13 kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_13_0 +// hook class %hook NCNotificationListSectionRevealHintView -(void)didMoveToWindow { %orig; if (enabled) { self.revealHintTitle.string = customText; - self.revealHintTitle.textAlignment = 1; + if (kSLSystemVersioniOS13) { + self.revealHintTitle.textAlignment = 1; + } } } %end -//%end - %ctor { - // check iOS version - /*if (kSLSystemVersioniOS13) { - %init(ios13); - } - else { - %init(ios12); - }*/ - + // prefs changed listener notificationCallback(NULL, NULL, NULL, NULL, NULL); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce); + + // respring notification listener + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.yaypixxo.cnon/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } \ No newline at end of file diff --git a/cnonprefs/CNONRootListController.m b/cnonprefs/CNONRootListController.m index 6437a2b..6ebbf6e 100644 --- a/cnonprefs/CNONRootListController.m +++ b/cnonprefs/CNONRootListController.m @@ -13,6 +13,7 @@ - (void)apply { [self.view endEditing:YES]; + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.yaypixxo.cnon/respring"), NULL, NULL, YES); } - (void)openTwitter { diff --git a/cnonprefs/Resources/Root.plist b/cnonprefs/Resources/Root.plist index 5ea9755..cd445d7 100644 --- a/cnonprefs/Resources/Root.plist +++ b/cnonprefs/Resources/Root.plist @@ -44,7 +44,7 @@ action apply label - Apply + Respring cell