Remove optional arguments and qualified names

This commit is contained in:
Danny Moesch 2020-02-09 22:43:21 +01:00 committed by Mingshen Sun
parent 43bba1fb50
commit a5570a8409
4 changed files with 14 additions and 14 deletions

View file

@ -157,6 +157,6 @@ extension PGPKeyArmorSettingTableViewController: PGPKeyImporter {
}
func saveImportedKeys() {
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
performSegue(withIdentifier: "savePGPKeySegue", sender: self)
}
}

View file

@ -91,7 +91,7 @@ extension PGPKeyFileSettingTableViewController: PGPKeyImporter {
}
func saveImportedKeys() {
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
performSegue(withIdentifier: "savePGPKeySegue", sender: self)
}
private func validate(key: String?) -> Bool {

View file

@ -38,28 +38,28 @@ extension PGPKeyImporter {
extension PGPKeyImporter where Self: UIViewController {
func savePassphraseDialog() {
let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertController.Style.alert)
let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: .alert)
// Do not save the key's passphrase.
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: .default) { _ in
AppKeychain.shared.removeContent(for: Globals.pgpKeyPassphrase)
Defaults.isRememberPGPPassphraseOn = false
self.saveImportedKeys()
})
// Save the key's passphrase.
savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertAction.Style.destructive) {_ in
savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: .destructive) { _ in
// Ask for the passphrase.
let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in
let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: .default) { _ in
AppKeychain.shared.add(string: alert.textFields?.first?.text, for: Globals.pgpKeyPassphrase)
Defaults.isRememberPGPPassphraseOn = true
self.saveImportedKeys()
}))
})
alert.addTextField { textField in
textField.text = AppKeychain.shared.get(for: Globals.pgpKeyPassphrase)
textField.isSecureTextEntry = true
}
self.present(alert, animated: true, completion: nil)
self.present(alert, animated: true)
})
self.present(savePassphraseAlert, animated: true, completion: nil)
present(savePassphraseAlert, animated: true)
}
}

View file

@ -47,20 +47,20 @@ extension PGPKeyUrlTableViewController: PGPKeyImporter {
}
func doAfterImport() {
Utils.alert(title: "RememberToRemoveKey".localize(), message: "RememberToRemoveKeyFromServer.".localize(), controller: self, completion: nil)
Utils.alert(title: "RememberToRemoveKey".localize(), message: "RememberToRemoveKeyFromServer.".localize(), controller: self)
}
func saveImportedKeys() {
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
performSegue(withIdentifier: "savePGPKeySegue", sender: self)
}
private func validate(pgpKeyUrl: String?) -> Bool {
guard let pgpKeyUrl = pgpKeyUrl, let url = URL(string: pgpKeyUrl), let scheme = url.scheme else {
Utils.alert(title: "CannotSavePgpKey".localize(), message: "SetPgpKeyUrlFirst.".localize(), controller: self, completion: nil)
Utils.alert(title: "CannotSavePgpKey".localize(), message: "SetPgpKeyUrlFirst.".localize(), controller: self)
return false
}
guard scheme == "https" else {
Utils.alert(title: "CannotSavePgpKey".localize(), message: "UseHttps.".localize(), controller: self, completion: nil)
Utils.alert(title: "CannotSavePgpKey".localize(), message: "UseHttps.".localize(), controller: self)
return false
}
return true