Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS9.3 patch #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 105 additions & 43 deletions CyDelete.xm
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
//
// CyDelete8.xm
// CyDelete8
// CyDelete.xm
// CyDelete
//
// Created by Ryan Burke on 02.01.2014.
// Copyright (c) 2014 Ryan Burke. All rights reserved.
//
// Modified by Pal Lockheart on 12.04.2016.
// Copyright (c) 2016 Pal Lockheart. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#include <substrate.h>

#import <SpringBoard/SpringBoard.h>
#import <SpringBoard/SBApplication.h>
#import <SpringBoard/SBIcon.h>
#import <SpringBoard/SBIconView.h>
Expand Down Expand Up @@ -165,6 +169,14 @@ static id ownerForSBApplication(SBApplication *application) {
return package;
}

static BOOL isOfficialUninstallable(SBApplication *application) {
return [application isSystemApplication]
|| [application isInternalApplication]
|| [application isWebApplication]
|| [[application path] hasPrefix:@"/private/var/mobile/Containers/Bundle/Application"] //iOS 9.1.x-
|| [[application path] hasPrefix:@"/private/var/containers/Bundle/Application"]; //iOS 9.2.x+
}

@implementation CDUninstallOperation
- (id)init {
if((self = [super init]) != nil) {
Expand Down Expand Up @@ -219,7 +231,7 @@ static id ownerForSBApplication(SBApplication *application) {
- (void)displayError {
NSString *body = [NSString stringWithFormat:CDLocalizedString(@"PACKAGE_UNINSTALL_ERROR_BODY"), _package];
UIAlertView *delView = [[UIAlertView alloc] initWithTitle:CDLocalizedString(@"PACKAGE_UNINSTALL_ERROR_TITLE") message:body delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[delView show];
[delView show];
}

-(void)displayRespring {
Expand Down Expand Up @@ -283,10 +295,10 @@ static void removeBundleFromMIList(NSString *bundle) {
//Show the user an error message warning them that we didn't remove the application.
NSString *nonCydiaText = [NSString stringWithFormat:CDLocalizedString(@"PACKAGE_NOT_CYDIA_BODY"), package];
UIAlertView *nonCydiaAlert = [[UIAlertView alloc] initWithTitle:CDLocalizedString(@"PACKAGE_NOT_CYDIA_TITLE")
message:nonCydiaText
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
message:nonCydiaText
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[nonCydiaAlert show];
}
else {
Expand All @@ -298,10 +310,31 @@ static void removeBundleFromMIList(NSString *bundle) {
}
%end

@interface SBApplicationIcon (CyDelete)
-(BOOL)cydelete_allowsUninstall;
-(void)cydelete_uninstallClicked;
@end
static BOOL cydelete_IOSVersionAbove92() {
return kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_9_2;
}

static BOOL cydelete_allowsUninstall(SBIcon *arg) {
//Get the bundle ID for this application.
NSString *bundle = nil;
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_8_0) {
bundle = [[arg application] bundleIdentifier];
}
else {
bundle = [[arg application] displayName];
}
//If the application is an Apple application.
bool isApple = ([bundle hasPrefix:@"com.apple."] && ![bundle hasPrefix:@"com.apple.samplecode."]);
//If the application is Cydia and user has protected it.
bool isCydia = ([bundle isEqualToString:@"com.saurik.Cydia"] && getProtectCydia());
//If the application is Cydia and user has protected it.
bool isPangu = ([bundle isEqualToString:@"io.pangu.nvwastone"] && getProtectPangu());
//If any of these match then we don't want to allow uninstall.
if(isApple || isCydia || isPangu || !getEnabled() || getFreeMemory() < 20 ) {
return NO;
}
return YES;
}

static void uninstallClickedForIcon(SBIcon *self) {
//Get the application for this icon.
Expand All @@ -325,59 +358,80 @@ static void uninstallClickedForIcon(SBIcon *self) {
}
}

static BOOL _forceCydia;
@interface SBApplicationIcon(CyDelete)
@property (nonatomic) BOOL forceCydia;
@end


@interface LSApplicationWorkspace : NSObject
+ (id) defaultWorkspace;
- (BOOL) unregisterApplication:(id)application;
- (BOOL) registerApplicationDictionary:(id)application;
@end

%hook SBIconController
- (_Bool)iconViewDisplaysCloseBox:(id)arg1{
if([arg1 class] != %c(SBIconView) && [arg1 class] != %c(SBActivatorIcon)) {
return %orig(arg1);
}
SBIconView *iconView = arg1;
SBIcon *icon = [iconView icon];
return cydelete_allowsUninstall(icon);
}
- (void)iconCloseBoxTapped:(id)_i {
%log;
SBIconView *iconView = _i;
SBIcon *icon = [iconView icon];
SBApplicationIcon *appicon = (SBApplicationIcon *)icon;
SBApplication *app = [icon application];
id pkgName = ownerForSBApplication(app);
if(pkgName != [NSNull null]) {
uninstallClickedForIcon(icon);
}
%orig;
if(cydelete_IOSVersionAbove92() && [[iconPackagesDict allKeys] containsObject:[app bundleIdentifier]]) {
//new mechanism: iOS 9.2 above will not automatically trigger uninstall, we've to call it manually
appicon.forceCydia = YES;
UIAlertController* alert=[UIAlertController alertControllerWithTitle:[appicon uninstallAlertTitle] message:[appicon uninstallAlertBody] preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:[appicon uninstallAlertCancelTitle] style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:[appicon uninstallAlertConfirmTitle] style:UIAlertActionStyleCancel handler:^(UIAlertAction* _Nonnull action)
{
Class $LSApplicationWorkspace = objc_getClass("LSApplicationWorkspace");
[[$LSApplicationWorkspace defaultWorkspace] unregisterApplication:[NSURL fileURLWithPath:[app path]]];
Class $SBApplicationController = objc_getClass("SBApplicationController");
[[$SBApplicationController sharedInstance] uninstallApplication:app];
}]];
appicon.forceCydia = NO;
[self presentViewController: alert animated:YES completion:nil];
}else{
%orig;
}
}
%end

%hook SBApplicationIcon

%new(c@:)
-(BOOL)cydelete_allowsUninstall {
//Get the bundle ID for this application.
NSString *bundle = nil;
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_8_0) {
bundle = [[self application] bundleIdentifier];
}
else {
bundle = [[self application] displayName];
}
//If the application is an Apple application.
bool isApple = ([bundle hasPrefix:@"com.apple."] && ![bundle hasPrefix:@"com.apple.samplecode."]);
//If the application is Cydia and user has protected it.
bool isCydia = ([bundle isEqualToString:@"com.saurik.Cydia"] && getProtectCydia());
//If the application is Cydia and user has protected it.
bool isPangu = ([bundle isEqualToString:@"io.pangu.loader"] && getProtectPangu());
//If any of these match then we don't want to allow uninstall.
if(isApple || isCydia || isPangu || !getEnabled() || getFreeMemory() < 20 ) {
return NO;
}
return YES;
%new
- (BOOL)forceCydia{
return _forceCydia;
}
%new
- (void)setForceCydia:(BOOL)force{
_forceCydia = force;
}

//iOS 7/8/9.0-9.1 compatible code
-(BOOL)allowsCloseBox {
if([self class] != %c(SBApplicationIcon) && [self class] != %c(SBActivatorIcon)) {
return %orig;
}
return [self cydelete_allowsUninstall];
return cydelete_allowsUninstall(self);
}

-(BOOL)allowsUninstall {
if([self class] != %c(SBApplicationIcon) && [self class] != %c(SBActivatorIcon)) {
return %orig;
}
return [self cydelete_allowsUninstall];
return cydelete_allowsUninstall(self);
}

-(void)closeBoxClicked:(id)event {
if([self class] != %c(SBApplicationIcon) && [self class] != %c(SBActivatorIcon)) {
%orig;
Expand All @@ -386,7 +440,6 @@ static void uninstallClickedForIcon(SBIcon *self) {
uninstallClickedForIcon(self);
%orig;
}

-(void)uninstallClicked:(id)event {
if([self class] != %c(SBApplicationIcon) && [self class] != %c(SBActivatorIcon)) {
%orig;
Expand All @@ -397,11 +450,16 @@ static void uninstallClickedForIcon(SBIcon *self) {
}

-(NSString *)uninstallAlertTitle {
return [NSString stringWithFormat:SBLocalizedString(@"UNINSTALL_ICON_TITLE"),
if(!_forceCydia && isOfficialUninstallable([self application]))
return %orig;
return [NSString stringWithFormat:cydelete_IOSVersionAbove92() ? SBLocalizedString(@"UNINSTALL_ICON_TITLE_DELETE_WITH_NAME") : SBLocalizedString(@"UNINSTALL_ICON_TITLE"),
[[self application] displayName]];
}

-(NSString *)uninstallAlertBody {
%log;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove log

if(!_forceCydia && isOfficialUninstallable([self application]))
return %orig;

NSString *bundle = nil;

Expand All @@ -427,11 +485,15 @@ static void uninstallClickedForIcon(SBIcon *self) {
}

-(NSString *)uninstallAlertConfirmTitle {
return SBLocalizedString(@"UNINSTALL_ICON_CONFIRM");
if(!_forceCydia && isOfficialUninstallable([self application]))
return %orig;
return cydelete_IOSVersionAbove92() ? SBLocalizedString(@"UNINSTALL_ICON_BUTTON_DELETE") : SBLocalizedString(@"UNINSTALL_ICON_CONFIRM");
}

-(NSString *)uninstallAlertCancelTitle {
return SBLocalizedString(@"UNINSTALL_ICON_CANCEL");
if(!_forceCydia && isOfficialUninstallable([self application]))
return %orig;
return cydelete_IOSVersionAbove92() ? SBLocalizedString(@"UNINSTALL_ICON_BUTTON_CANCEL") : SBLocalizedString(@"UNINSTALL_ICON_CANCEL");
}
%end

Expand All @@ -441,4 +503,4 @@ static void uninstallClickedForIcon(SBIcon *self) {
iconPackagesDict = [[NSMutableDictionary alloc] init];
uninstallQueue = [[NSOperationQueue alloc] init];
[uninstallQueue setMaxConcurrentOperationCount:1];
}
}
39 changes: 36 additions & 3 deletions CyDelete/CyDeleteListController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@interface CyDeleteListController : PSListController

- (id)specifiers;
- (void)ryanDonate:(id)arg;
- (void)donate:(id)arg;
- (void)viewSource:(id)arg;

@end
Expand All @@ -30,6 +30,10 @@ - (id)navigationTitle {
return [[self bundle] localizedStringForKey:[super title] value:[super title] table:nil];
}

- (id)localized:(NSString *)key{
return [[self bundle] localizedStringForKey:key value:key table:nil];
}

- (id)localizedSpecifiersWithSpecifiers:(NSArray *)specifiers {

NSLog(@"localizedSpecifiersWithSpecifiers");
Expand All @@ -54,8 +58,37 @@ - (id)localizedSpecifiersWithSpecifiers:(NSArray *)specifiers {
return specifiers;
}

- (void)ryanDonate:(id)arg {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4VBFWEFBUF56N"]];
- (void)donate:(id)arg {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4VBFWEFBUF56N"]];
}

- (void)donate2:(id)arg {
UIAlertController* alert=[UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"%@ palxex",[self localized:@"DONATE"]] message:nil preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:[self localized:@"BITCOIN"] style:UIAlertActionStyleDefault handler:^(UIAlertAction* _Nonnull action)
{
NSURL *targetURL = [NSURL URLWithString:@"bitcoin:1EXrR9YSEEXtFSYWjNnwrhyRhc4DoQHhzC"];
if([[UIApplication sharedApplication] canOpenURL:targetURL])
[[UIApplication sharedApplication] openURL:targetURL];
else{
[[UIPasteboard generalPasteboard] setString:@"1EXrR9YSEEXtFSYWjNnwrhyRhc4DoQHhzC"];
UIAlertController* alert=[UIAlertController alertControllerWithTitle:@"" message:@"BTC address 1EXrR9YSEEXtFSYWjNnwrhyRhc4DoQHhzC; have been copied in your pasteboard" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"OKay" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController: alert animated:YES completion:nil];
}
}]];
[alert addAction:[UIAlertAction actionWithTitle:[self localized:@"ALIPAY"] style:UIAlertActionStyleDefault handler:^(UIAlertAction* _Nonnull action)
{
NSURL *targetURL = [NSURL URLWithString:@"alipayqr://platformapi/startapp?saId=10000007&qrcode=https%3A%2F%2Fqr.alipay.com%2Faex04760kwfblpiaho9mg00"];
if([[UIApplication sharedApplication] canOpenURL:targetURL])
[[UIApplication sharedApplication] openURL:targetURL];
else
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://qr.alipay.com/aex04760kwfblpiaho9mg00"]];
}]];
[alert addAction:[UIAlertAction actionWithTitle:[self localized:@"PAYPAL"] style:UIAlertActionStyleDefault handler:^(UIAlertAction* _Nonnull action)
{[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=W25D7EKNG9JNQ&lc=C2&item_name=Donation&button_subtype=services"]];
}]];
[alert addAction:[UIAlertAction actionWithTitle:[self localized:@"CANCEL"] style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController: alert animated:YES completion:nil];
}

- (void)viewSource:(id)arg {
Expand Down
2 changes: 1 addition & 1 deletion CyDelete/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARCHS = armv7 arm64

TARGET = iphone:8.1
TARGET = iphone

include theos/makefiles/common.mk

Expand Down
12 changes: 10 additions & 2 deletions CyDelete/Resources/CyDelete.plist
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@
</dict>
<dict>
<key>action</key>
<string>ryanDonate:</string>
<string>donate:</string>
<key>cell</key>
<string>PSButtonCell</string>
<key>label</key>
<string>DONATE</string>
</dict>
<dict>
<key>action</key>
<string>donate2:</string>
<key>cell</key>
<string>PSButtonCell</string>
<key>label</key>
Expand All @@ -84,6 +92,6 @@
</dict>
</array>
<key>title</key>
<string>CyDelete8</string>
<string>CyDelete9</string>
</dict>
</plist>
Binary file modified CyDelete/Resources/Pangu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions CyDelete/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>DONATE</key>
<string>Donate via PayPal</string>
<string>Donate</string>
<key>NON_CYDIA_DEL</key>
<string>Non-Cydia Deletion</string>
<key>NON_CYDIA_DEL_TEXT</key>
Expand All @@ -18,12 +18,21 @@
<string>Settings</string>
<key>NO_DRM_DONATE_COPYRIGHT</key>
<string>
There is no DRM protection on this application but please help support future development (my coffee fund) by donating via PayPal.
There is no DRM protection on this application but please help support future development (my coffee fund) by donating.

CyDelete9 © 2016 Pal Lockheart
CyDelete8 © 2014 Ryan Burke
CyDelete © 2009-2011 Dustin L. Howett
Released under the GPLv3 Licence.</string>
<key>SOURCE_CODE</key>
<string>Source Code</string>
<key>PAYPAL</key>
<string>PayPal</string>
<key>BITCOIN</key>
<string>Bitcoin</string>
<key>ALIPAY</key>
<string>Alipay</string>
<key>CANCEL</key>
<string>Cancel</string>
</dict>
</plist>
5 changes: 3 additions & 2 deletions CyDelete/Resources/pt_PT.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>DONATE</key>
<string>Doar via PayPal</string>
<string>Doar</string>
<key>NON_CYDIA_DEL</key>
<string>Eliminação não Cydia</string>
<key>NON_CYDIA_DEL_TEXT</key>
Expand All @@ -18,8 +18,9 @@
<string>Definições</string>
<key>NO_DRM_DONATE_COPYRIGHT</key>
<string>
Não há protecção DRM nesta aplicação, por favor apoie o desenvolvimento futuro (o meu fundo para café) ao doar via PayPal.
Não há protecção DRM nesta aplicação, por favor apoie o desenvolvimento futuro (o meu fundo para café) ao doar.

CyDelete9 © 2016 Pal Lockhart
CyDelete8 © 2014 Ryan Burke
CyDelete © 2009-2011 Dustin L. Howett
Disponibilizado sob licença GPLv3.</string>
Expand Down
Loading