Skip to content

Commit c29e15f

Browse files
committed
UIAlertView -> UIAlertController
1 parent ab53678 commit c29e15f

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

Model/Slicer.mm

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#import "Slicer.h"
22
#import "../Headers/SpringBoardHeaders.h"
3+
#import "../SLWindow.h"
34

45
@interface LSBundleProxy
56
+(id)bundleProxyForIdentifier:(id)arg1;
@@ -52,7 +53,6 @@ - (instancetype)initWithDisplayIdentifier:(NSString *)displayIdentifier {
5253
FBApplicationInfo *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:displayIdentifier];
5354
self.workingDirectory = appInfo.dataContainerURL.path;
5455
}
55-
HBLogDebug(@"A1 %@", self.workingDirectory);
5656

5757
if (!self.workingDirectory) {
5858
HBLogDebug(@"[Slices] Error: working directory cannot be found");
@@ -147,26 +147,31 @@ - (void)killApplication {
147147
[process killForReason:1 andReport:NO withDescription:nil];
148148
}
149149
else BKSTerminateApplicationForReasonAndReportWithDescription(self.displayIdentifier, 5, NO, NULL);
150-
// [NSThread sleepForTimeInterval:0.1];
150+
[NSThread sleepForTimeInterval:0.1];
151151
}
152152

153153
- (void)switchToSlice:(NSString *)targetSliceName completionHandler:(void (^)(BOOL))completionHandler {
154154
if(targetSliceName == NULL) {
155155
HBLogDebug(@"Slices: switchToSlice failed (NULL)");
156-
if (completionHandler)
157-
completionHandler(NO);
156+
if (completionHandler) completionHandler(NO);
158157
return;
159158
}
160159
if (![self.currentSlice isEqualToString:targetSliceName]) [self killApplication];
161-
UIAlertView *switchAlert = [[UIAlertView alloc] initWithTitle:@"Switching slice" message:@"Please wait. It may take some time." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
162-
[switchAlert show];
160+
SLWindow *window = [SLWindow sharedInstance];
161+
window.touchInjection = true;
162+
UIAlertController *switchAlert = [UIAlertController alertControllerWithTitle:@"Switching slice" message:@"Please wait. It may take some time." preferredStyle:UIAlertControllerStyleAlert];
163+
[window.rootViewController presentViewController:switchAlert animated:YES completion:nil];
163164
NSArray *IGNORE_SUFFIXES = @[ @".app", @"iTunesMetadata.plist", @"iTunesArtwork", @"Slices", @".com.apple.mobile_container_manager.metadata.plist"];
164165
BOOL success = [super switchToSlice:targetSliceName ignoreSuffixes:IGNORE_SUFFIXES];
165166
if (!success) {
166167
if (completionHandler) completionHandler(NO);
167-
[switchAlert dismissWithClickedButtonIndex:-1 animated:TRUE];
168-
UIAlertView *switchAlert = [[UIAlertView alloc] initWithTitle:@"switchToSlice Failed." message:@"switchToSlices could not be completed successfully." delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
169-
[switchAlert show];
168+
[switchAlert dismissViewControllerAnimated:YES completion:^() {
169+
UIAlertController *switchAlert = [UIAlertController alertControllerWithTitle:@"switchToSlice Failed." message:@"switchToSlices could not be completed successfully." preferredStyle:UIAlertControllerStyleAlert];
170+
[window.rootViewController presentViewController:switchAlert animated:YES completion:nil];
171+
[switchAlert addAction:[UIAlertAction actionWithTitle:Localize(@"Cancel") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
172+
window.touchInjection = false;
173+
}]];
174+
}];
170175
return;
171176
}
172177

@@ -177,14 +182,17 @@ - (void)switchToSlice:(NSString *)targetSliceName completionHandler:(void (^)(BO
177182
}
178183
}
179184

180-
NSString *gameCenterAccount = [self gameCenterAccountForSlice:targetSliceName];
181-
GameCenterAccountManager *gameCenterAccountManager = [GameCenterAccountManager sharedInstance];
182-
[gameCenterAccountManager switchToAccount:gameCenterAccount completionHandler:^(BOOL gameCenterSuccess) {
185+
// NSString *gameCenterAccount = [self gameCenterAccountForSlice:targetSliceName];
186+
// GameCenterAccountManager *gameCenterAccountManager = [GameCenterAccountManager sharedInstance];
187+
// [gameCenterAccountManager switchToAccount:gameCenterAccount completionHandler:^(BOOL gameCenterSuccess) {
183188
if (completionHandler) {
184-
completionHandler(success && gameCenterSuccess);
185-
[switchAlert dismissWithClickedButtonIndex:-1 animated:TRUE];
189+
// completionHandler(success && gameCenterSuccess);
190+
[switchAlert dismissViewControllerAnimated:YES completion:^() {
191+
completionHandler(success);
192+
window.touchInjection = false;
193+
}];
186194
}
187-
}];
195+
// }];
188196
}
189197

190198
- (BOOL)createSlice:(NSString *)newSliceName {

0 commit comments

Comments
 (0)