summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2017-02-01 09:05:18 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2017-02-01 09:05:18 -0800
commit42e97527a93a5bf5db7d5389ceb71a00aa60a910 (patch)
tree6d2b85fd14de78dfed0b0dfc51212d8bd588b399
parente7e2bcf06bf33293673e08d5869cf4d4287253fb (diff)
Support iOS 10+, which lost alertSheet (ashikase).
-rw-r--r--Tweak.xm45
1 files changed, 42 insertions, 3 deletions
diff --git a/Tweak.xm b/Tweak.xm
index f3b74e4..7c7c20a 100644
--- a/Tweak.xm
+++ b/Tweak.xm
@@ -29,9 +29,23 @@
Class $SafeModeAlertItem;
+#define UIAlertActionStyleDefault 0
+
+@interface UIAlertAction
++ (UIAlertAction *) actionWithTitle:(NSString *)title style:(NSUInteger)style handler:(void (^)(UIAlertAction *action))handler;
+@end
+
+@interface UIAlertController : UIViewController
+- (void) addAction:(UIAlertAction *)action;
+- (void) setMessage:(NSString *)message;
+- (void) setTitle:(NSString *)title;
+@end
+
@interface SBAlertItem : NSObject {
}
+- (UIAlertController *) alertController;
- (UIAlertView *) alertSheet;
+- (void) deactivateForButton;
- (void) dismiss;
@end
@@ -75,6 +89,11 @@ void SafeModeButtonClicked(int button) {
}
}
+void SafeModeButtonClicked(id self, int button) {
+ SafeModeButtonClicked(button);
+ [self deactivateForButton];
+}
+
void SafeModeAlertItem$alertSheet$buttonClicked$(id self, SEL sel, id sheet, int button) {
SafeModeButtonClicked(button);
[self dismiss];
@@ -86,16 +105,36 @@ void SafeModeAlertItem$alertView$clickedButtonAtIndex$(id self, SEL sel, id shee
}
void SafeModeAlertItem$configure$requirePasscodeForActions$(id self, SEL sel, BOOL configure, BOOL require) {
- UIAlertView *sheet([self alertSheet]);
+ NSString *text(@"We apologize for the inconvenience, but SpringBoard has just crashed.\n\nMobileSubstrate /did not/ cause this problem: it has protected you from it.\n\nSpringBoard is now running in Safe Mode. All extensions that support this safety system are disabled.\n\nReboot (or restart SpringBoard) to return to the normal mode. To return to this dialog touch the status bar.\n\nTap \"Help\" below for more tips.");
+
+#ifdef __arm64__
+ if ([self respondsToSelector:@selector(alertController)]) {
+ UIAlertController *alert([self alertController]);
+ [alert setTitle:@""];
+ [alert setMessage:text];
+
+ [alert addAction:[%c(UIAlertAction) actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { SafeModeButtonClicked(self, 1); }]];
+ [alert addAction:[%c(UIAlertAction) actionWithTitle:@"Restart" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { SafeModeButtonClicked(self, 2); }]];
+ [alert addAction:[%c(UIAlertAction) actionWithTitle:@"Help" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { SafeModeButtonClicked(self, 3); }]];
+
+ return;
+ }
+#else
+ if (false) %c(UIAlertAction);
+#endif
+
+ UIAlertView *sheet([self alertSheet]);
[sheet setDelegate:self];
+
[sheet setTitle:@""];
- [sheet setBodyText:@"We apologize for the inconvenience, but SpringBoard has just crashed.\n\nMobileSubstrate /did not/ cause this problem: it has protected you from it.\n\nYour device is now running in Safe Mode. All extensions that support this safety system are disabled.\n\nReboot (or restart SpringBoard) to return to the normal mode. To return to this dialog touch the status bar.\n\nTap \"Help\" below for more tips."];
+ [sheet setBodyText:text];
+
[sheet addButtonWithTitle:@"OK"];
[sheet addButtonWithTitle:@"Restart"];
[sheet addButtonWithTitle:@"Help"];
- [sheet setNumberOfRows:1];
+ [sheet setNumberOfRows:1];
if ([sheet respondsToSelector:@selector(setForceHorizontalButtonsLayout:)])
[sheet setForceHorizontalButtonsLayout:YES];
}