Option to open apps in action sheet

This commit is contained in:
osama alhour 2022-09-12 17:10:50 +03:00
parent 92e4981ac0
commit 736a467588
4 changed files with 35 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,27 @@
[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:^(UIAlertAction* action)
{
}];
[didFailController addAction: cancelAction];
[self presentViewController:didFailController animated:YES completion:nil];
}
}
- (void)uninstallPressedForRowAtIndexPath:(NSIndexPath*)indexPath
{
TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance];
@ -134,6 +155,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

@ -148,6 +148,11 @@
return ret;
}
- (BOOL)openApplicationWithBundleID:(NSString *)appId
{
return [[LSApplicationWorkspace defaultWorkspace] openApplicationWithBundleID:appId];
}
/*- (int)detachFromApp:(NSString*)appId
{
if(!appId) return -200;