Polish code of PGPKeySettingTableViewController
This commit is contained in:
parent
e9b40828cc
commit
972062935c
1 changed files with 6 additions and 13 deletions
|
|
@ -26,24 +26,15 @@ class PGPKeySettingTableViewController: UITableViewController {
|
|||
|
||||
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
|
||||
if identifier == "savePGPKeySegue" {
|
||||
guard pgpPublicKeyURLTextField.text != nil else {
|
||||
return false
|
||||
}
|
||||
guard pgpPrivateKeyURLTextField.text != nil else {
|
||||
return false
|
||||
}
|
||||
|
||||
guard URL(string: pgpPublicKeyURLTextField.text!) != nil else {
|
||||
guard let pgpPublicKeyURL = URL(string: pgpPublicKeyURLTextField.text!) else {
|
||||
Utils.alert(title: "Cannot Save", message: "Please set Public Key URL first.", controller: self, completion: nil)
|
||||
return false
|
||||
}
|
||||
guard URL(string: pgpPrivateKeyURLTextField.text!) != nil else {
|
||||
guard let pgpPrivateKeyURL = URL(string: pgpPrivateKeyURLTextField.text!) else {
|
||||
Utils.alert(title: "Cannot Save", message: "Please set Private Key URL first.", controller: self, completion: nil)
|
||||
return false
|
||||
}
|
||||
|
||||
if URL(string: pgpPublicKeyURLTextField.text!)!.scheme! == "http" &&
|
||||
URL(string: pgpPrivateKeyURLTextField.text!)!.scheme! == "http" {
|
||||
guard pgpPublicKeyURL.scheme! == "https", pgpPrivateKeyURL.scheme! == "https" else {
|
||||
Utils.alert(title: "Cannot Save Settings", message: "HTTP connection is not supported.", controller: self, completion: nil)
|
||||
return false
|
||||
}
|
||||
|
|
@ -55,7 +46,9 @@ class PGPKeySettingTableViewController: UITableViewController {
|
|||
let alert = UIAlertController(title: "Passphrase", message: "Please fill in the passphrase of your PGP secret key.", preferredStyle: UIAlertControllerStyle.alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {_ in
|
||||
self.pgpPassphrase = alert.textFields?.first?.text
|
||||
if self.shouldPerformSegue(withIdentifier: "savePGPKeySegue", sender: self) {
|
||||
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
|
||||
}
|
||||
}))
|
||||
alert.addTextField(configurationHandler: {(textField: UITextField!) in
|
||||
textField.text = self.pgpPassphrase
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue