Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Allow showing/cloning repository in Working Copy when installed #2366

Merged
merged 1 commit into from
Oct 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Classes/Repository/RepositoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ ContextMenuDelegate {
.newIssue(issueController: newIssueViewController)
}

func workingCopyAction() -> UIAlertAction? {
guard let remote = self.repoUrl.absoluteString.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics) else { return nil}

guard let url = URL(string: "working-copy://show?remote=\(remote)") else { return nil }
guard UIApplication.shared.canOpenURL(url) else { return nil }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palmin Would this work without adding working-copy to LSApplicationQueriesSchemes ?

https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl

If your app is linked on or after iOS 9.0, you must declare the URL schemes you pass to this method by adding the LSApplicationQueriesSchemes key to your app's Info.plist file. This method always returns false for undeclared schemes, whether or not an appropriate app is installed. To learn more about the key, see LSApplicationQueriesSchemes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoopsie ! 🚢


let title = NSLocalizedString("Working Copy", comment: "")
let action = UIAlertAction(title: title, style: .default,
handler: { _ in
UIApplication.shared.open(url)
})
return action
}

@objc func onMore(sender: UIButton) {
let alertTitle = "\(repo.owner)/\(repo.name):\(branch)"
let alert = UIAlertController.configured(title: alertTitle, preferredStyle: .actionSheet)
Expand All @@ -173,6 +187,7 @@ ContextMenuDelegate {
$0.popoverPresentationController?.setSourceView(sender)
},
switchBranchAction,
workingCopyAction(),
AlertAction.cancel()
])
alert.popoverPresentationController?.setSourceView(sender)
Expand Down
1 change: 1 addition & 0 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<key>LSApplicationQueriesSchemes</key>
<array>
<string>org-appextension-feature-password-management</string>
<string>working-copy</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
Expand Down