Provide info about the iTunes File Sharing

- only when key files are not existed (not downloaded/pasted/imported)
This commit is contained in:
Yishi Lin 2017-06-07 16:54:54 +08:00
parent 3cde0d954c
commit 6daa84df30
3 changed files with 34 additions and 17 deletions

View file

@ -257,17 +257,12 @@ class SettingsTableViewController: UITableViewController {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
}
func pgpKeyExists() -> Bool {
return FileManager.default.fileExists(atPath: Globals.pgpPublicKeyPath) &&
FileManager.default.fileExists(atPath: Globals.pgpPrivateKeyPath)
}
func showPGPKeyActionSheet() {
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
var urlActionTitle = "Download from URL"
var armorActionTitle = "ASCII-Armor Encrypted Key"
var fileActionTitle = "Use Uploaded Keys"
var fileActionTitle = "Use Imported Keys"
if Defaults[.pgpKeySource] == "url" {
urlActionTitle = "\(urlActionTitle)"
@ -286,7 +281,7 @@ class SettingsTableViewController: UITableViewController {
optionMenu.addAction(urlAction)
optionMenu.addAction(armorAction)
if (pgpKeyExists()) {
if passwordStore.pgpKeyExists() {
let fileAction = UIAlertAction(title: fileActionTitle, style: .default) { _ in
SVProgressHUD.setDefaultMaskType(.black)
@ -337,9 +332,17 @@ class SettingsTableViewController: UITableViewController {
}
optionMenu.addAction(fileAction)
} else {
let fileAction = UIAlertAction(title: "iTunes File Sharing", style: .default) { _ in
let title = "Import via iTunes File Sharing"
let message = "Copy your public and private key from your computer to Pass for iOS with the name \"gpg_key.pub\" and \"gpg_key\" (without quotes)."
Utils.alert(title: title, message: message, controller: self)
}
optionMenu.addAction(fileAction)
}
if Defaults[.pgpKeySource] != nil {
let deleteAction = UIAlertAction(title: "Remove PGP Keys", style: .destructive) { _ in
self.passwordStore.removePGPKeys()