diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index a9df895..9b36687 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -126,6 +126,7 @@ 9A5D06F525A56F0E00FA59D4 /* PasswordTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A8F9EE1259EDD520027CE15 /* PasswordTableViewCell.swift */; }; 9A5D070225A5769A00FA59D4 /* PasswordTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A8F9EE1259EDD520027CE15 /* PasswordTableViewCell.swift */; }; 9A652414244BB33300DA0A41 /* UIAlertActionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A652413244BB33300DA0A41 /* UIAlertActionExtension.swift */; }; + 9A74D2E0277D2F8C00F7BC44 /* UIAlertControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A74D2DF277D2F8C00F7BC44 /* UIAlertControllerExtension.swift */; }; 9A78A7CC277BECE80093222D /* SVProgressHUD.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30F6C1B327664C7200BE5AB2 /* SVProgressHUD.xcframework */; }; 9A78A7CD277BECE80093222D /* SVProgressHUD.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 30F6C1B327664C7200BE5AB2 /* SVProgressHUD.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 9A8F9EBD259EA4C50027CE15 /* PasswordsTableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A8F9EBC259EA4C50027CE15 /* PasswordsTableDataSource.swift */; }; @@ -411,6 +412,7 @@ 9A5865EF25AA944B006719C2 /* SearchPassword.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = SearchPassword.storyboard; sourceTree = ""; }; 9A58665025AADB76006719C2 /* CredentialProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialProvider.swift; sourceTree = ""; }; 9A652413244BB33300DA0A41 /* UIAlertActionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertActionExtension.swift; sourceTree = ""; }; + 9A74D2DF277D2F8C00F7BC44 /* UIAlertControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertControllerExtension.swift; sourceTree = ""; }; 9A8F9EBC259EA4C50027CE15 /* PasswordsTableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordsTableDataSource.swift; sourceTree = ""; }; 9A8F9ECB259ECB410027CE15 /* PasswordSelectionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordSelectionDelegate.swift; sourceTree = ""; }; 9A8F9EE1259EDD520027CE15 /* PasswordTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordTableViewCell.swift; sourceTree = ""; }; @@ -654,6 +656,7 @@ 30697C3521F63C990064FCAC /* UIViewControllerExtension.swift */, 30697C3821F63C990064FCAC /* UIViewExtension.swift */, 9A652413244BB33300DA0A41 /* UIAlertActionExtension.swift */, + 9A74D2DF277D2F8C00F7BC44 /* UIAlertControllerExtension.swift */, ); path = Extensions; sourceTree = ""; @@ -1516,6 +1519,7 @@ 30697C2A21F63C5A0064FCAC /* NotificationNames.swift in Sources */, 30CCA91623258C380048CA51 /* PGPInterface.swift in Sources */, 30DAFD4A240985A7002456E7 /* Array+Slices.swift in Sources */, + 9A74D2E0277D2F8C00F7BC44 /* UIAlertControllerExtension.swift in Sources */, 30697C4721F63CAB0064FCAC /* PasscodeLock.swift in Sources */, A2699ACD2402631400F36323 /* PasswordTableEntry.swift in Sources */, 30697C3421F63C8B0064FCAC /* PasscodeLockViewController.swift in Sources */, diff --git a/pass/Controllers/GitRepositorySettingsTableViewController.swift b/pass/Controllers/GitRepositorySettingsTableViewController.swift index 0ec098a..f50e911 100644 --- a/pass/Controllers/GitRepositorySettingsTableViewController.swift +++ b/pass/Controllers/GitRepositorySettingsTableViewController.swift @@ -314,10 +314,13 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA if Defaults.gitSSHKeySource != nil { optionMenu.addAction( UIAlertAction(title: "RemoveSShKeys".localize(), style: .destructive) { _ in - self.passwordStore.removeGitSSHKeys() - Defaults.gitSSHKeySource = nil - self.sshLabel?.isEnabled = false - self.gitAuthenticationMethod = .password + let alert = UIAlertController.removeConfirmationAlert(title: "RemoveSShKeys".localize(), message: "") { _ in + self.passwordStore.removeGitSSHKeys() + Defaults.gitSSHKeySource = nil + self.sshLabel?.isEnabled = false + self.gitAuthenticationMethod = .password + } + self.present(alert, animated: true, completion: nil) } ) } diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift index 0490539..397dc44 100644 --- a/pass/Controllers/SettingsTableViewController.swift +++ b/pass/Controllers/SettingsTableViewController.swift @@ -184,11 +184,14 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele if Defaults.pgpKeySource != nil { optionMenu.addAction( UIAlertAction(title: "RemovePgpKeys".localize(), style: .destructive) { _ in - self.keychain.removeContent(for: PGPKey.PUBLIC.getKeychainKey()) - self.keychain.removeContent(for: PGPKey.PRIVATE.getKeychainKey()) - PGPAgent.shared.uninitKeys() - self.pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize() - Defaults.pgpKeySource = nil + let alert = UIAlertController.removeConfirmationAlert(title: "RemovePgpKeys".localize(), message: "") { _ in + self.keychain.removeContent(for: PGPKey.PUBLIC.getKeychainKey()) + self.keychain.removeContent(for: PGPKey.PRIVATE.getKeychainKey()) + PGPAgent.shared.uninitKeys() + self.pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize() + Defaults.pgpKeySource = nil + } + self.present(alert, animated: true, completion: nil) } ) } diff --git a/pass/de.lproj/Localizable.strings b/pass/de.lproj/Localizable.strings index a0b30f9..422b5ad 100644 --- a/pass/de.lproj/Localizable.strings +++ b/pass/de.lproj/Localizable.strings @@ -206,6 +206,7 @@ "On" = "An"; "Off" = "Aus"; "Save" = "Speichern"; +"Remove" = "Löschen"; // Lock screen "EnterPasscode" = "Passcode für Pass eingeben"; diff --git a/pass/en.lproj/Localizable.strings b/pass/en.lproj/Localizable.strings index e19813f..f12635f 100644 --- a/pass/en.lproj/Localizable.strings +++ b/pass/en.lproj/Localizable.strings @@ -208,6 +208,7 @@ "On" = "On"; "Off" = "Off"; "Save" = "Save"; +"Remove" = "Remove"; // Lock screen "EnterPasscode" = "Enter passcode for Pass"; diff --git a/passKit/Extensions/UIAlertActionExtension.swift b/passKit/Extensions/UIAlertActionExtension.swift index b663b35..b49ba07 100644 --- a/passKit/Extensions/UIAlertActionExtension.swift +++ b/passKit/Extensions/UIAlertActionExtension.swift @@ -28,6 +28,10 @@ public extension UIAlertAction { UIAlertAction(title: "Ok".localize(), style: .default, handler: handler) } + static func remove(handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertAction { + UIAlertAction(title: "Remove".localize(), style: .destructive, handler: handler) + } + static func okAndPopView(controller: UIViewController) -> UIAlertAction { ok { _ in controller.navigationController?.popViewController(animated: true) diff --git a/passKit/Extensions/UIAlertControllerExtension.swift b/passKit/Extensions/UIAlertControllerExtension.swift new file mode 100644 index 0000000..962c707 --- /dev/null +++ b/passKit/Extensions/UIAlertControllerExtension.swift @@ -0,0 +1,17 @@ +// +// UIAlertControllerExtension.swift +// passKit +// +// Copyright © 2021 Bob Sun. All rights reserved. +// + +import Foundation + +public extension UIAlertController { + class func removeConfirmationAlert(title: String, message: String, handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertController { + let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) + alert.addAction(UIAlertAction.remove(handler: handler)) + alert.addAction(UIAlertAction.cancel()) + return alert + } +}