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
commit b766a8586f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 0 deletions

View File

@ -23,6 +23,7 @@
- (BOOL)unregisterApplication:(id)arg1;
- (BOOL)_LSPrivateRebuildApplicationDatabasesForSystemApps:(BOOL)arg1 internal:(BOOL)arg2 user:(BOOL)arg3;
- (BOOL)uninstallApplication:(NSString*)arg1 withOptions:(id)arg2;
- (BOOL)openApplicationWithBundleID:(NSString *)arg1 ;
- (void)enumerateApplicationsOfType:(NSUInteger)type block:(void (^)(LSApplicationProxy*))block;
@end

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];

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

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;