Browse Source

remove need for respring

tags/v2.2.0
Viggo Lekdorf 4 years ago
parent
commit
419938c34d
8 changed files with 80 additions and 50 deletions
  1. +2
    -2
      Makefile
  2. +55
    -29
      Tweak.xm
  3. +12
    -8
      cnonprefs/CNONRootListController.m
  4. +2
    -2
      cnonprefs/Makefile
  5. BIN
      cnonprefs/Resources/.DS_Store
  6. +8
    -8
      cnonprefs/Resources/Root.plist
  7. BIN
      cnonprefs/Resources/twitter@2x.png
  8. +1
    -1
      control

+ 2
- 2
Makefile View File

ARCHS = arm64
TARGET = iphone:clang:11.2:11.2
ARCHS = arm64 arm64e
TARGET = iphone:clang:10.3:10.3


include $(THEOS)/makefiles/common.mk include $(THEOS)/makefiles/common.mk



+ 55
- 29
Tweak.xm View File

@property (nonatomic,copy) NSString *string; @property (nonatomic,copy) NSString *string;
@end @end


@interface NCNotificationListSectionRevealHintView : UIView
-(void)_updateHintTitle;
@interface NCNotificationListSectionRevealHintView : UIView
//-(void)_updateHintTitle;
//-(void)setRevealHintTitle;
@property (nonatomic,retain)SBUILegibilityLabel *revealHintTitle;
@end @end


// prefs
@interface NSUserDefaults (CnonPrefs)
-(id)objectForKey:(NSString *)key inDomain:(NSString *)domain;
-(void)setObject:(id)value forKey:(NSString *)key inDomain:(NSString *)domain;
@end

static NSString *nsDomainString = @"com.yaypixxo.cnon";
static NSString *nsNotificationString = @"com.yaypixxo.cnon/preferences.changed";

// declare switch and string
static BOOL enabled; static BOOL enabled;
static NSString* customText = @"";
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*/


#define kIdentifier @"com.yaypixxo.cnonprefs"
#define kSettingsChangedNotification (CFStringRef)@"com.yaypixxo.cnonprefs/ReloadPrefs"
#define kSettingsPath @"/var/mobile/Library/Preferences/com.yaypixxo.cnonprefs.plist"
/*%group ios13


%hook NCNotificationListSectionRevealHintView %hook NCNotificationListSectionRevealHintView


-(void)layoutSubviews {
%orig;
-(void)setRevealHintTitle:(SBUILegibilityLabel *)arg1 {
if (enabled) { if (enabled) {
[MSHookIvar<UILabel *>(self, "_revealHintTitle") setString:customText];
arg1 = customText;
} }
} }


%end %end


static void reloadPrefs() {
CFPreferencesAppSynchronize((CFStringRef)kIdentifier);

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];
}
%end*/


enabled = [prefs objectForKey:@"enabled"] ? [(NSNumber *)[prefs objectForKey:@"enabled"] boolValue] : true;
customText = [prefs objectForKey:@"customText"] ? [prefs objectForKey:@"customText"] : changeNotiTxt;
//%group ios12


%hook NCNotificationListSectionRevealHintView

-(void)didMoveToWindow {
%orig;
if (enabled) {
self.revealHintTitle.string = customText;
} }
}

%end

//%end


%ctor { %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);
} }

+ 12
- 8
cnonprefs/CNONRootListController.m View File

#include "CNONRootListController.h" #include "CNONRootListController.h"
#import <spawn.h>
//#import <spawn.h>


@implementation CNONRootListController @implementation CNONRootListController




- (void)respring:(id)sender { - (void)respring:(id)sender {
[self.view endEditing:YES]; [self.view endEditing:YES];
[NSThread sleepForTimeInterval:0.5f];
/*[NSThread sleepForTimeInterval:0.5f];
pid_t pid; pid_t pid;
const char* args[] = {"killall", "backboardd", NULL}; 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 { - (void)openTwitter {


if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetbot:"]]) { if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetbot:"]]) {
url = [NSURL URLWithString:@"tweetbot:///user_profile/Ra1nPix"]; 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"]; 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"]; 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"]; url = [NSURL URLWithString:@"twitter://user?screen_name=Ra1nPix"];
} else {
}
else {
url = [NSURL URLWithString:@"https://mobile.twitter.com/Ra1nPix"]; url = [NSURL URLWithString:@"https://mobile.twitter.com/Ra1nPix"];
} }


// [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
[[UIApplication sharedApplication] openURL:url];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
} }


@end @end

+ 2
- 2
cnonprefs/Makefile View File

ARCHS = arm64
TARGET = iphone:11.2:11.2
ARCHS = arm64 arm64e
TARGET = iphone:10.3:10.3


include $(THEOS)/makefiles/common.mk include $(THEOS)/makefiles/common.mk



BIN
cnonprefs/Resources/.DS_Store View File


+ 8
- 8
cnonprefs/Resources/Root.plist View File

<key>default</key> <key>default</key>
<true/> <true/>
<key>defaults</key> <key>defaults</key>
<string>com.yaypixxo.cnonprefs</string>
<string>com.yaypixxo.cnon</string>
<key>key</key> <key>key</key>
<string>enabled</string> <string>enabled</string>
<key>label</key> <key>label</key>
<string>Enable</string> <string>Enable</string>
<key>PostNotification</key> <key>PostNotification</key>
<string>com.yaypixxo.cnonprefs/ReloadPrefs</string>
<string>com.yaypixxo.cnon/preferences.changed</string>
</dict> </dict>
<dict> <dict>
<key>cell</key> <key>cell</key>
<string>PSGroupCell</string> <string>PSGroupCell</string>
<key>footerText</key> <key>footerText</key>
<string>Type your custom message or leave blank to hide the text.</string>
<string>Type your custom text or leave blank to hide the text</string>
</dict> </dict>
<dict> <dict>
<key>cell</key> <key>cell</key>
<string>PSEditTextCell</string> <string>PSEditTextCell</string>
<key>defaults</key> <key>defaults</key>
<string>com.yaypixxo.cnonprefs</string>
<string>com.yaypixxo.cnon</string>
<key>default</key> <key>default</key>
<string></string> <string></string>
<key>key</key> <key>key</key>
<key>placeholder</key> <key>placeholder</key>
<string>custom text here</string> <string>custom text here</string>
<key>PostNotification</key> <key>PostNotification</key>
<string>com.yaypixxo.cnonprefs/ReloadPrefs</string>
<string>com.yaypixxo.cnon/preferences.changed</string>
</dict> </dict>
<dict> <dict>
<key>cell</key> <key>cell</key>
<key>action</key> <key>action</key>
<string>respring</string> <string>respring</string>
<key>label</key> <key>label</key>
<string>Respring</string>
<string>Apply</string>
</dict> </dict>
<dict> <dict>
<key>cell</key> <key>cell</key>
<string>PSGroupCell</string> <string>PSGroupCell</string>
<key>label</key> <key>label</key>
<string>Follow me</string>
<string>Follow me on Twitter</string>
</dict> </dict>
<dict> <dict>
<key>action</key> <key>action</key>
</dict> </dict>
</array> </array>
<key>title</key> <key>title</key>
<string>CNON</string>
<string>CustomNoOlderNotifications</string>
</dict> </dict>
</plist> </plist>

BIN
cnonprefs/Resources/twitter@2x.png View File

Before After
Width: 29  |  Height: 29  |  Size: 1.7KB Width: 64  |  Height: 64  |  Size: 1.5KB

+ 1
- 1
control View File

Package: com.yaypixxo.cnon Package: com.yaypixxo.cnon
Name: CustomNoOlderNotifications Name: CustomNoOlderNotifications
Depends: mobilesubstrate, preferenceloader Depends: mobilesubstrate, preferenceloader
Version: 2.1.0
Version: 2.2.0
Architecture: iphoneos-arm Architecture: iphoneos-arm
Description: Change the "No Older Notifications" text to a custom one! Description: Change the "No Older Notifications" text to a custom one!
Icon: https://yaypixxo.com/assets/com.yaypixxo.cnon.png Icon: https://yaypixxo.com/assets/com.yaypixxo.cnon.png

Loading…
Cancel
Save