From 3edd8d5ebec615497e61865a74981537b5bae536 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 2 Sep 2021 15:52:59 -0500 Subject: [PATCH] Adds "Open" context menu action for active apps Launches the sideloaded app by opening the app-specific URL scheme embedded by AltStore during resigning. --- AltStore/My Apps/MyAppsViewController.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AltStore/My Apps/MyAppsViewController.swift b/AltStore/My Apps/MyAppsViewController.swift index 43d1d3b5..0d1e4585 100644 --- a/AltStore/My Apps/MyAppsViewController.swift +++ b/AltStore/My Apps/MyAppsViewController.swift @@ -1005,6 +1005,16 @@ private extension MyAppsViewController private extension MyAppsViewController { + func open(_ installedApp: InstalledApp) + { + UIApplication.shared.open(installedApp.openAppURL) { success in + guard !success else { return } + + let toastView = ToastView(error: OperationError.openAppFailed(name: installedApp.name)) + toastView.show(in: self) + } + } + func refresh(_ installedApp: InstalledApp) { let previousProgress = AppManager.shared.refreshProgress(for: installedApp) @@ -1523,6 +1533,12 @@ extension MyAppsViewController { var actions = [UIMenuElement]() + let openAction = UIAction(title: NSLocalizedString("Open", comment: ""), image: UIImage(systemName: "arrow.up.forward.app")) { (action) in + self.open(installedApp) + } + + let openMenu = UIMenu(title: "", options: .displayInline, children: [openAction]) + let refreshAction = UIAction(title: NSLocalizedString("Refresh", comment: ""), image: UIImage(systemName: "arrow.clockwise")) { (action) in self.refresh(installedApp) } @@ -1577,6 +1593,7 @@ extension MyAppsViewController if installedApp.isActive { + actions.append(openMenu) actions.append(refreshAction) } else