Ask to save passphrase while setting PGP keys through URLs
This commit is contained in:
parent
665746f962
commit
bef9e0251c
3 changed files with 66 additions and 51 deletions
|
|
@ -22,12 +22,9 @@ class PGPKeyArmorSettingTableViewController: UITableViewController, UITextViewDe
|
|||
armorPublicKeyTextView.text = Defaults[.pgpPublicKeyArmor]
|
||||
armorPrivateKeyTextView.text = Defaults[.pgpPrivateKeyArmor]
|
||||
pgpPassphrase = passwordStore.pgpKeyPassphrase
|
||||
|
||||
armorPublicKeyTextView.delegate = self
|
||||
armorPrivateKeyTextView.delegate = self
|
||||
}
|
||||
|
||||
private func createSavePassphraseAlert() -> UIAlertController {
|
||||
private func createSavePassphraseAndSegueAlert() -> UIAlertController {
|
||||
let savePassphraseAlert = UIAlertController(title: "Passphrase", message: "Do you want to save the passphrase for later decryption?", preferredStyle: UIAlertControllerStyle.alert)
|
||||
savePassphraseAlert.addAction(UIAlertAction(title: "No", style: UIAlertActionStyle.default) { _ in
|
||||
Defaults[.isRememberPassphraseOn] = false
|
||||
|
|
@ -44,8 +41,8 @@ class PGPKeyArmorSettingTableViewController: UITableViewController, UITextViewDe
|
|||
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
|
||||
let savePassphraseAlert = self.createSavePassphraseAlert()
|
||||
self.present(savePassphraseAlert, animated: true, completion: nil)
|
||||
let savePassphraseAndSegueAlert = self.createSavePassphraseAndSegueAlert()
|
||||
self.present(savePassphraseAndSegueAlert, animated: true, completion: nil)
|
||||
}))
|
||||
alert.addTextField(configurationHandler: {(textField: UITextField!) in
|
||||
textField.text = self.pgpPassphrase
|
||||
|
|
@ -56,7 +53,7 @@ class PGPKeyArmorSettingTableViewController: UITableViewController, UITextViewDe
|
|||
|
||||
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
|
||||
if text == UIPasteboard.general.string {
|
||||
// user pastes somethint, get ready to clear in 10s
|
||||
// user pastes something, get ready to clear in 10s
|
||||
recentPastedText = text
|
||||
DispatchQueue.global(qos: .background).asyncAfter(deadline: DispatchTime.now() + 10) { [weak weakSelf = self] in
|
||||
if let pasteboardString = UIPasteboard.general.string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue