Merge pull request #148 from SerenaKit/serena/open-opt

Option to open apps in action sheet
This commit is contained in:
Lars Fröder
2022-09-12 18:21:16 +02:00
committed by GitHub
4 changed files with 33 additions and 0 deletions
+26
View File
@@ -39,6 +39,25 @@
[self presentViewController:errorAlert animated:YES completion:nil];
}
- (void)openAppPressedForRowAtIndexPath:(NSIndexPath *)indexPath
{
TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance];
NSString* appPath = [appsManager installedAppPaths][indexPath.row];
NSString* appId = [appsManager appIdForAppPath:appPath];
BOOL didOpen = [appsManager openApplicationWithBundleID:appId];
// if we failed to open the app, show an alert
if (!didOpen) {
NSString *failMessage = [NSString stringWithFormat: @"Failed to open %@", appId];
UIAlertController* didFailController = [UIAlertController alertControllerWithTitle:failMessage message: nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[didFailController addAction: cancelAction];
[self presentViewController:didFailController animated:YES completion:nil];
}
}
- (void)uninstallPressedForRowAtIndexPath:(NSIndexPath*)indexPath
{
TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance];
@@ -141,6 +160,13 @@
}];
[appSelectAlert addAction:detachAction];*/
UIAlertAction* openAction = [UIAlertAction actionWithTitle: @"Open" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
{
[self openAppPressedForRowAtIndexPath:indexPath];
}];
[appSelectAlert addAction: openAction];
UIAlertAction* uninstallAction = [UIAlertAction actionWithTitle:@"Uninstall App" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action)
{
[self uninstallPressedForRowAtIndexPath:indexPath];
+1
View File
@@ -19,6 +19,7 @@
- (int)installIpa:(NSString*)pathToIpa;
- (int)uninstallApp:(NSString*)appId;
- (int)uninstallAppByPath:(NSString*)path;
- (BOOL)openApplicationWithBundleID:(NSString *)appID;
//- (int)detachFromApp:(NSString*)appId;
@end
+5
View File
@@ -156,6 +156,11 @@
return ret;
}
- (BOOL)openApplicationWithBundleID:(NSString *)appId
{
return [[LSApplicationWorkspace defaultWorkspace] openApplicationWithBundleID:appId];
}
/*- (int)detachFromApp:(NSString*)appId
{
if(!appId) return -200;