forked from yaypixxo/CustomNoOlderNotifications
remove need for respring
This commit is contained in:
84
Tweak.xm
84
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<UILabel *>(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);
|
||||
}
|
Reference in New Issue
Block a user