summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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];
}