Update SwiftyUserDefaults to current version 5.0.0
This commit is contained in:
parent
b60ce3b003
commit
a2edf41d33
26 changed files with 145 additions and 149 deletions
|
|
@ -20,7 +20,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
|
|||
[[.type: PasswordEditorCellType.additionsCell, .title: "additions"]],
|
||||
[[.type: PasswordEditorCellType.scanQRCodeCell]]
|
||||
]
|
||||
if PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]) == .RANDOM {
|
||||
if PasswordGeneratorFlavour.from(Defaults.passwordGeneratorFlavor) == .RANDOM {
|
||||
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
||||
}
|
||||
tableData[1].append([.type: PasswordEditorCellType.memorablePasswordGeneratorCell])
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
encryptInASCIIArmoredSwitch.isOn = SharedDefaults[.encryptInArmored]
|
||||
encryptInASCIIArmoredSwitch.isOn = Defaults.encryptInArmored
|
||||
encryptInASCIIArmoredTableViewCell.accessoryView = encryptInASCIIArmoredSwitch
|
||||
encryptInASCIIArmoredTableViewCell.selectionStyle = .none
|
||||
setGitSignatureText()
|
||||
|
|
@ -39,7 +39,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
|
|||
let gitSignatureEmail = passwordStore.gitSignatureForNow?.email ?? ""
|
||||
self.gitSignatureTableViewCell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote)
|
||||
self.gitSignatureTableViewCell.detailTextLabel?.text = "\(gitSignatureName) <\(gitSignatureEmail)>"
|
||||
if SharedDefaults[.gitSignatureName] == nil && SharedDefaults[.gitSignatureEmail] == nil {
|
||||
if Defaults.gitSignatureName == nil && Defaults.gitSignatureEmail == nil {
|
||||
self.gitSignatureTableViewCell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
gitSignatureTableViewCell.detailTextLabel?.text = "NotSet".localize()
|
||||
}
|
||||
|
|
@ -78,15 +78,15 @@ class AdvancedSettingsTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
@objc func encryptInASCIIArmoredAction(_ sender: Any?) {
|
||||
SharedDefaults[.encryptInArmored] = encryptInASCIIArmoredSwitch.isOn
|
||||
Defaults.encryptInArmored = encryptInASCIIArmoredSwitch.isOn
|
||||
}
|
||||
|
||||
@IBAction func saveGitConfigSetting(segue: UIStoryboardSegue) {
|
||||
if let controller = segue.source as? GitConfigSettingTableViewController {
|
||||
if let gitSignatureName = controller.nameTextField.text,
|
||||
let gitSignatureEmail = controller.emailTextField.text {
|
||||
SharedDefaults[.gitSignatureName] = gitSignatureName.isEmpty ? nil : gitSignatureName
|
||||
SharedDefaults[.gitSignatureEmail] = gitSignatureEmail.isEmpty ? nil : gitSignatureEmail
|
||||
Defaults.gitSignatureName = gitSignatureName.isEmpty ? nil : gitSignatureName
|
||||
Defaults.gitSignatureEmail = gitSignatureEmail.isEmpty ? nil : gitSignatureEmail
|
||||
}
|
||||
setGitSignatureText()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class EditPasswordTableViewController: PasswordEditorTableViewController {
|
|||
[[.type: PasswordEditorCellType.scanQRCodeCell],
|
||||
[.type: PasswordEditorCellType.deletePasswordCell]]
|
||||
]
|
||||
if PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]) == .RANDOM {
|
||||
if PasswordGeneratorFlavour.from(Defaults.passwordGeneratorFlavor) == .RANDOM {
|
||||
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
||||
}
|
||||
tableData[1].append([.type: PasswordEditorCellType.memorablePasswordGeneratorCell])
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
uiSwitch.onTintColor = Colors.systemBlue
|
||||
uiSwitch.sizeToFit()
|
||||
uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
||||
uiSwitch.isOn = SharedDefaults[.isRememberPGPPassphraseOn]
|
||||
uiSwitch.isOn = Defaults.isRememberPGPPassphraseOn
|
||||
return uiSwitch
|
||||
}()
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
uiSwitch.onTintColor = Colors.systemBlue
|
||||
uiSwitch.sizeToFit()
|
||||
uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
||||
uiSwitch.isOn = SharedDefaults[.isRememberGitCredentialPassphraseOn]
|
||||
uiSwitch.isOn = Defaults.isRememberGitCredentialPassphraseOn
|
||||
return uiSwitch
|
||||
}()
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
uiSwitch.onTintColor = Colors.systemBlue
|
||||
uiSwitch.sizeToFit()
|
||||
uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
||||
uiSwitch.isOn = SharedDefaults[.isShowFolderOn]
|
||||
uiSwitch.isOn = Defaults.isShowFolderOn
|
||||
return uiSwitch
|
||||
}()
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
uiSwitch.onTintColor = Colors.systemBlue
|
||||
uiSwitch.sizeToFit()
|
||||
uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction(_:)), for: UIControl.Event.valueChanged)
|
||||
uiSwitch.isOn = SharedDefaults[.isHidePasswordImagesOn]
|
||||
uiSwitch.isOn = Defaults.isHidePasswordImagesOn
|
||||
return uiSwitch
|
||||
}()
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
accessoryView.addSubview(hideUnknownSwitch)
|
||||
cell.accessoryView = accessoryView
|
||||
cell.selectionStyle = .none
|
||||
hideUnknownSwitch.isOn = SharedDefaults[.isHideUnknownOn]
|
||||
hideUnknownSwitch.isOn = Defaults.isHideUnknownOn
|
||||
case "HideOtpFields".localize():
|
||||
cell.accessoryType = .none
|
||||
let detailButton = UIButton(type: .detailDisclosure)
|
||||
|
|
@ -117,7 +117,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
accessoryView.addSubview(hideOTPSwitch)
|
||||
cell.accessoryView = accessoryView
|
||||
cell.selectionStyle = .none
|
||||
hideOTPSwitch.isOn = SharedDefaults[.isHideOTPOn]
|
||||
hideOTPSwitch.isOn = Defaults.isHideOTPOn
|
||||
case "RememberPgpKeyPassphrase".localize():
|
||||
cell.accessoryType = .none
|
||||
cell.selectionStyle = .none
|
||||
|
|
@ -141,10 +141,10 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
accessoryView.addSubview(hidePasswordImagesSwitch)
|
||||
cell.accessoryView = accessoryView
|
||||
cell.selectionStyle = .none
|
||||
hidePasswordImagesSwitch.isOn = SharedDefaults[.isHidePasswordImagesOn]
|
||||
hidePasswordImagesSwitch.isOn = Defaults.isHidePasswordImagesOn
|
||||
case "PasswordGeneratorFlavor".localize():
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
cell.detailTextLabel?.text = PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]).name
|
||||
cell.detailTextLabel?.text = PasswordGeneratorFlavour.from(Defaults.passwordGeneratorFlavor).name
|
||||
default: break
|
||||
}
|
||||
return cell
|
||||
|
|
@ -163,7 +163,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
var randomFlavorActionTitle = ""
|
||||
var appleFlavorActionTitle = ""
|
||||
if SharedDefaults[.passwordGeneratorFlavor] == PasswordGeneratorFlavour.RANDOM.rawValue {
|
||||
if Defaults.passwordGeneratorFlavor == PasswordGeneratorFlavour.RANDOM.rawValue {
|
||||
randomFlavorActionTitle = "✓ " + "RandomString".localize()
|
||||
appleFlavorActionTitle = "ApplesKeychainStyle".localize()
|
||||
} else {
|
||||
|
|
@ -171,12 +171,12 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
appleFlavorActionTitle = "✓ " + "ApplesKeychainStyle".localize()
|
||||
}
|
||||
let randomFlavorAction = UIAlertAction(title: randomFlavorActionTitle, style: .default) { _ in
|
||||
SharedDefaults[.passwordGeneratorFlavor] = PasswordGeneratorFlavour.RANDOM.rawValue
|
||||
Defaults.passwordGeneratorFlavor = PasswordGeneratorFlavour.RANDOM.rawValue
|
||||
sourceCell.detailTextLabel?.text = PasswordGeneratorFlavour.RANDOM.name
|
||||
}
|
||||
|
||||
let appleFlavorAction = UIAlertAction(title: appleFlavorActionTitle, style: .default) { _ in
|
||||
SharedDefaults[.passwordGeneratorFlavor] = PasswordGeneratorFlavour.APPLE.rawValue
|
||||
Defaults.passwordGeneratorFlavor = PasswordGeneratorFlavour.APPLE.rawValue
|
||||
sourceCell.detailTextLabel?.text = PasswordGeneratorFlavour.APPLE.name
|
||||
}
|
||||
|
||||
|
|
@ -209,24 +209,24 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
}
|
||||
|
||||
@objc func hideUnknownSwitchAction(_ sender: Any?) {
|
||||
SharedDefaults[.isHideUnknownOn] = hideUnknownSwitch.isOn
|
||||
Defaults.isHideUnknownOn = hideUnknownSwitch.isOn
|
||||
NotificationCenter.default.post(name: .passwordDetailDisplaySettingChanged, object: nil)
|
||||
}
|
||||
|
||||
@objc func hideOTPSwitchAction(_ sender: Any?) {
|
||||
SharedDefaults[.isHideOTPOn] = hideOTPSwitch.isOn
|
||||
Defaults.isHideOTPOn = hideOTPSwitch.isOn
|
||||
NotificationCenter.default.post(name: .passwordDetailDisplaySettingChanged, object: nil)
|
||||
}
|
||||
|
||||
@objc func rememberPGPPassphraseSwitchAction(_ sender: Any?) {
|
||||
SharedDefaults[.isRememberPGPPassphraseOn] = rememberPGPPassphraseSwitch.isOn
|
||||
Defaults.isRememberPGPPassphraseOn = rememberPGPPassphraseSwitch.isOn
|
||||
if rememberPGPPassphraseSwitch.isOn == false {
|
||||
AppKeychain.shared.removeContent(for: Globals.pgpKeyPassphrase)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func rememberGitCredentialPassphraseSwitchAction(_ sender: Any?) {
|
||||
SharedDefaults[.isRememberGitCredentialPassphraseOn] = rememberGitCredentialPassphraseSwitch.isOn
|
||||
Defaults.isRememberGitCredentialPassphraseOn = rememberGitCredentialPassphraseSwitch.isOn
|
||||
if rememberGitCredentialPassphraseSwitch.isOn == false {
|
||||
passwordStore.gitSSHPrivateKeyPassphrase = nil
|
||||
passwordStore.gitPassword = nil
|
||||
|
|
@ -234,12 +234,12 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
}
|
||||
|
||||
@objc func showFolderSwitchAction(_ sender: Any?) {
|
||||
SharedDefaults[.isShowFolderOn] = showFolderSwitch.isOn
|
||||
Defaults.isShowFolderOn = showFolderSwitch.isOn
|
||||
NotificationCenter.default.post(name: .passwordDisplaySettingChanged, object: nil)
|
||||
}
|
||||
|
||||
@objc func hidePasswordImagesSwitchAction(_ sender: Any?) {
|
||||
SharedDefaults[.isHidePasswordImagesOn] = hidePasswordImagesSwitch.isOn
|
||||
Defaults.isHidePasswordImagesOn = hidePasswordImagesSwitch.isOn
|
||||
NotificationCenter.default.post(name: .passwordDetailDisplaySettingChanged, object: nil)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftyUserDefaults
|
||||
import passKit
|
||||
|
||||
class GitConfigSettingTableViewController: UITableViewController {
|
||||
|
|
@ -23,8 +22,8 @@ class GitConfigSettingTableViewController: UITableViewController {
|
|||
let signature = passwordStore.gitSignatureForNow
|
||||
nameTextField.placeholder = signature?.name ?? ""
|
||||
emailTextField.placeholder = signature?.email ?? ""
|
||||
nameTextField.text = SharedDefaults[.gitSignatureName]
|
||||
emailTextField.text = SharedDefaults[.gitSignatureEmail]
|
||||
nameTextField.text = Defaults.gitSignatureName
|
||||
emailTextField.text = Defaults.gitSignatureEmail
|
||||
}
|
||||
|
||||
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ class GitSSHKeyArmorSettingTableViewController: AutoCellHeightUITableViewControl
|
|||
} catch {
|
||||
Utils.alert(title: "CannotSave".localize(), message: "CannotSaveSshKey".localize(), controller: self, completion: nil)
|
||||
}
|
||||
SharedDefaults[.gitSSHKeySource] = .armor
|
||||
SharedDefaults[.gitAuthenticationMethod] = .key
|
||||
Defaults.gitSSHKeySource = .armor
|
||||
Defaults.gitAuthenticationMethod = .key
|
||||
self.navigationController!.popViewController(animated: true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,32 +27,32 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
private var sshLabel: UILabel?
|
||||
private let passwordStore = PasswordStore.shared
|
||||
private var gitAuthenticationMethod: GitAuthenticationMethod {
|
||||
get { SharedDefaults[.gitAuthenticationMethod] }
|
||||
get { Defaults.gitAuthenticationMethod }
|
||||
set {
|
||||
SharedDefaults[.gitAuthenticationMethod] = newValue
|
||||
Defaults.gitAuthenticationMethod = newValue
|
||||
updateAuthenticationMethodCheckView(for: newValue)
|
||||
}
|
||||
}
|
||||
private var gitUrl: URL {
|
||||
get { SharedDefaults[.gitURL] }
|
||||
set { SharedDefaults[.gitURL] = newValue }
|
||||
get { Defaults.gitURL }
|
||||
set { Defaults.gitURL = newValue }
|
||||
}
|
||||
private var gitBranchName: String {
|
||||
get { SharedDefaults[.gitBranchName] }
|
||||
set { SharedDefaults[.gitBranchName] = newValue }
|
||||
get { Defaults.gitBranchName }
|
||||
set { Defaults.gitBranchName = newValue }
|
||||
}
|
||||
private var gitUsername: String {
|
||||
get { SharedDefaults[.gitUsername] }
|
||||
set { SharedDefaults[.gitUsername] = newValue }
|
||||
get { Defaults.gitUsername }
|
||||
set { Defaults.gitUsername = newValue }
|
||||
}
|
||||
private var gitCredential: GitCredential {
|
||||
get {
|
||||
switch SharedDefaults[.gitAuthenticationMethod] {
|
||||
switch Defaults.gitAuthenticationMethod {
|
||||
case .password:
|
||||
return GitCredential(credential: .http(userName: SharedDefaults[.gitUsername]))
|
||||
return GitCredential(credential: .http(userName: Defaults.gitUsername))
|
||||
case .key:
|
||||
let privateKey: String = AppKeychain.shared.get(for: SshKey.PRIVATE.getKeychainKey()) ?? ""
|
||||
return GitCredential(credential: .ssh(userName: SharedDefaults[.gitUsername], privateKey: privateKey))
|
||||
return GitCredential(credential: .ssh(userName: Defaults.gitUsername, privateKey: privateKey))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
|
||||
private func cloneAndSegueIfSuccess() {
|
||||
// Remember git credential password/passphrase temporarily, ask whether users want this after a successful clone.
|
||||
SharedDefaults[.isRememberGitCredentialPassphraseOn] = true
|
||||
Defaults.isRememberGitCredentialPassphraseOn = true
|
||||
DispatchQueue.global(qos: .userInitiated).async() {
|
||||
do {
|
||||
let transferProgressBlock: (UnsafePointer<git_transfer_progress>, UnsafeMutablePointer<ObjCBool>) -> Void = { (git_transfer_progress, _) in
|
||||
|
|
@ -183,13 +183,13 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
let savePassphraseAlert: UIAlertController = {
|
||||
let alert = UIAlertController(title: "Done".localize(), message: "WantToSaveGitCredential?".localize(), preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "No".localize(), style: .default) { _ in
|
||||
SharedDefaults[.isRememberGitCredentialPassphraseOn] = false
|
||||
Defaults.isRememberGitCredentialPassphraseOn = false
|
||||
self.passwordStore.gitPassword = nil
|
||||
self.passwordStore.gitSSHPrivateKeyPassphrase = nil
|
||||
self.performSegue(withIdentifier: "saveGitServerSettingSegue", sender: self)
|
||||
})
|
||||
alert.addAction(UIAlertAction(title: "Yes".localize(), style: .destructive) {_ in
|
||||
SharedDefaults[.isRememberGitCredentialPassphraseOn] = true
|
||||
Defaults.isRememberGitCredentialPassphraseOn = true
|
||||
self.performSegue(withIdentifier: "saveGitServerSettingSegue", sender: self)
|
||||
})
|
||||
return alert
|
||||
|
|
@ -221,7 +221,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
var armorActionTitle = "AsciiArmorEncryptedKey".localize()
|
||||
var fileActionTitle = "ITunesFileSharing".localize()
|
||||
|
||||
switch SharedDefaults[.gitSSHKeySource] {
|
||||
switch Defaults.gitSSHKeySource {
|
||||
case .url: urlActionTitle = "✓ \(urlActionTitle)"
|
||||
case .armor: armorActionTitle = "✓ \(armorActionTitle)"
|
||||
case .file: fileActionTitle = "✓ \(fileActionTitle)"
|
||||
|
|
@ -244,7 +244,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
let action = UIAlertAction(title: fileActionTitle, style: .default) { _ in
|
||||
do {
|
||||
try self.passwordStore.gitSSHKeyImportFromFileSharing()
|
||||
SharedDefaults[.gitSSHKeySource] = .file
|
||||
Defaults.gitSSHKeySource = .file
|
||||
SVProgressHUD.showSuccess(withStatus: "Imported".localize())
|
||||
SVProgressHUD.dismiss(withDelay: 1)
|
||||
self.sshLabel?.isEnabled = true
|
||||
|
|
@ -268,10 +268,10 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
}()
|
||||
optionMenu.addAction(fileAction)
|
||||
|
||||
if SharedDefaults[.gitSSHKeySource] != nil {
|
||||
if Defaults.gitSSHKeySource != nil {
|
||||
let deleteAction = UIAlertAction(title: "RemoveSShKeys".localize(), style: .destructive) { _ in
|
||||
self.passwordStore.removeGitSSHKeys()
|
||||
SharedDefaults[.gitSSHKeySource] = nil
|
||||
Defaults.gitSSHKeySource = nil
|
||||
self.sshLabel?.isEnabled = false
|
||||
self.updateAuthenticationMethodCheckView(for: .password)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class PGPKeyArmorSettingTableViewController: AutoCellHeightUITableViewController
|
|||
// no
|
||||
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in
|
||||
self.keychain.removeContent(for: Globals.pgpKeyPassphrase)
|
||||
SharedDefaults[.isRememberPGPPassphraseOn] = false
|
||||
Defaults.isRememberPGPPassphraseOn = false
|
||||
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
|
||||
})
|
||||
// yes
|
||||
|
|
@ -99,7 +99,7 @@ class PGPKeyArmorSettingTableViewController: AutoCellHeightUITableViewController
|
|||
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
|
||||
self.keychain.add(string: alert.textFields?.first?.text, for: Globals.pgpKeyPassphrase)
|
||||
SharedDefaults[.isRememberPGPPassphraseOn] = true
|
||||
Defaults.isRememberPGPPassphraseOn = true
|
||||
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
|
||||
}))
|
||||
alert.addTextField(configurationHandler: {(textField: UITextField!) in
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ class PGPKeySettingTableViewController: AutoCellHeightUITableViewController {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
pgpPublicKeyURLTextField.text = SharedDefaults[.pgpPublicKeyURL]?.absoluteString
|
||||
pgpPrivateKeyURLTextField.text = SharedDefaults[.pgpPrivateKeyURL]?.absoluteString
|
||||
pgpPublicKeyURLTextField.text = Defaults.pgpPublicKeyURL?.absoluteString
|
||||
pgpPrivateKeyURLTextField.text = Defaults.pgpPrivateKeyURL?.absoluteString
|
||||
}
|
||||
|
||||
private func validatePGPKeyURL(input: String?) -> Bool {
|
||||
|
|
@ -44,7 +44,7 @@ class PGPKeySettingTableViewController: AutoCellHeightUITableViewController {
|
|||
// no
|
||||
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in
|
||||
self.keychain.removeContent(for: Globals.pgpKeyPassphrase)
|
||||
SharedDefaults[.isRememberPGPPassphraseOn] = false
|
||||
Defaults.isRememberPGPPassphraseOn = false
|
||||
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
|
||||
})
|
||||
// yes
|
||||
|
|
@ -53,7 +53,7 @@ class PGPKeySettingTableViewController: AutoCellHeightUITableViewController {
|
|||
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
|
||||
self.keychain.add(string: alert.textFields?.first?.text, for: Globals.pgpKeyPassphrase)
|
||||
SharedDefaults[.isRememberPGPPassphraseOn] = true
|
||||
Defaults.isRememberPGPPassphraseOn = true
|
||||
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
|
||||
}))
|
||||
alert.addTextField(configurationHandler: {(textField: UITextField!) in
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
self.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
let _ = sem.wait(timeout: DispatchTime.distantFuture)
|
||||
if SharedDefaults[.isRememberPGPPassphraseOn] {
|
||||
if Defaults.isRememberPGPPassphraseOn {
|
||||
self.keychain.add(string: passphrase, for: Globals.pgpKeyPassphrase)
|
||||
}
|
||||
return passphrase
|
||||
|
|
@ -144,7 +144,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
self?.setTableData()
|
||||
self?.tableView.reloadData()
|
||||
self?.editUIBarButtonItem.isEnabled = true
|
||||
if !SharedDefaults[.isHidePasswordImagesOn] {
|
||||
if !Defaults.isHidePasswordImagesOn {
|
||||
if let urlString = self?.password?.urlString {
|
||||
if self?.passwordEntity?.getImage() == nil {
|
||||
self?.updatePasswordImage(urlString: urlString)
|
||||
|
|
@ -395,7 +395,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
switch(tableData[sectionIndex].type) {
|
||||
case .name:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordDetailTitleTableViewCell", for: indexPath) as! PasswordDetailTitleTableViewCell
|
||||
if !SharedDefaults[.isHidePasswordImagesOn] {
|
||||
if !Defaults.isHidePasswordImagesOn {
|
||||
cell.labelCellConstraint.isActive = false
|
||||
cell.labelImageConstraint.isActive = true
|
||||
cell.passwordImageImageView.image = passwordImage ?? #imageLiteral(resourceName: "PasswordImagePlaceHolder")
|
||||
|
|
@ -438,8 +438,8 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
}
|
||||
|
||||
var numberOfHiddenFields = 0
|
||||
numberOfHiddenFields += SharedDefaults[.isHideUnknownOn] ? password!.numberOfUnknowns : 0
|
||||
numberOfHiddenFields += SharedDefaults[.isHideOTPOn] ? password!.numberOfOtpRelated : 0
|
||||
numberOfHiddenFields += Defaults.isHideUnknownOn ? password!.numberOfUnknowns : 0
|
||||
numberOfHiddenFields += Defaults.isHideOTPOn ? password!.numberOfOtpRelated : 0
|
||||
guard numberOfHiddenFields > 0 else {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
|||
return fillPasswordCell!
|
||||
case .passwordLengthCell:
|
||||
passwordLengthCell = tableView.dequeueReusableCell(withIdentifier: "passwordLengthCell", for: indexPath) as? SliderTableViewCell
|
||||
let lengthSetting = PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]).defaultLength
|
||||
let lengthSetting = PasswordGeneratorFlavour.from(Defaults.passwordGeneratorFlavor).defaultLength
|
||||
let minimumLength = lengthSetting.min
|
||||
let maximumLength = lengthSetting.max
|
||||
var defaultLength = lengthSetting.def
|
||||
|
|
@ -215,7 +215,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
|||
showPasswordSettings()
|
||||
|
||||
let length = passwordLengthCell?.roundedValue ?? 0
|
||||
let plainPassword = PasswordGeneratorFlavour.from(SharedDefaults[.passwordGeneratorFlavor]).generatePassword(length: length)
|
||||
let plainPassword = PasswordGeneratorFlavour.from(Defaults.passwordGeneratorFlavor).generatePassword(length: length)
|
||||
|
||||
// update tableData so to make sure reloadData() works correctly
|
||||
tableData[passwordSection][0][PasswordEditorCellKey.content] = plainPassword
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
|
||||
private var gitCredential: GitCredential {
|
||||
get {
|
||||
switch SharedDefaults[.gitAuthenticationMethod] {
|
||||
switch Defaults.gitAuthenticationMethod {
|
||||
case .password:
|
||||
return GitCredential(credential: .http(userName: SharedDefaults[.gitUsername]))
|
||||
return GitCredential(credential: .http(userName: Defaults.gitUsername))
|
||||
case .key:
|
||||
let privateKey: String = AppKeychain.shared.get(for: SshKey.PRIVATE.getKeychainKey()) ?? ""
|
||||
return GitCredential(credential: .ssh(userName: SharedDefaults[.gitUsername], privateKey: privateKey))
|
||||
return GitCredential(credential: .ssh(userName: Defaults.gitUsername, privateKey: privateKey))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
filteredPasswordsTableEntries.removeAll()
|
||||
var passwordEntities = [PasswordEntity]()
|
||||
var passwordAllEntities = [PasswordEntity]()
|
||||
if SharedDefaults[.isShowFolderOn] {
|
||||
if Defaults.isShowFolderOn {
|
||||
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(parent: parent)
|
||||
} else {
|
||||
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(withDir: false)
|
||||
|
|
@ -230,7 +230,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
if SharedDefaults[.isShowFolderOn] {
|
||||
if Defaults.isShowFolderOn {
|
||||
searchController.searchBar.scopeButtonTitles = SearchBarScope.allCases.map { $0.localizedName }
|
||||
} else {
|
||||
searchController.searchBar.scopeButtonTitles = nil
|
||||
|
|
@ -396,7 +396,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
}
|
||||
|
||||
@objc func backAction(_ sender: Any?) {
|
||||
guard SharedDefaults[.isShowFolderOn] else { return }
|
||||
guard Defaults.isShowFolderOn else { return }
|
||||
var anim: CATransition? = transitionFromLeft
|
||||
if parentPasswordEntity == nil {
|
||||
anim = nil
|
||||
|
|
@ -464,7 +464,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
self.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
let _ = sem.wait(timeout: DispatchTime.distantFuture)
|
||||
if SharedDefaults[.isRememberPGPPassphraseOn] {
|
||||
if Defaults.isRememberPGPPassphraseOn {
|
||||
self.keychain.add(string: passphrase, for: Globals.pgpKeyPassphrase)
|
||||
}
|
||||
return passphrase
|
||||
|
|
@ -682,13 +682,13 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
|||
|
||||
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
|
||||
// update the default search scope
|
||||
SharedDefaults[.searchDefault] = SearchBarScope(rawValue: selectedScope)
|
||||
Defaults.searchDefault = SearchBarScope(rawValue: selectedScope)
|
||||
updateSearchResults(for: searchController)
|
||||
}
|
||||
|
||||
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
|
||||
// set the default search scope to "all"
|
||||
if SharedDefaults[.isShowFolderOn] && SharedDefaults[.searchDefault] == .all {
|
||||
if Defaults.isShowFolderOn && Defaults.searchDefault == .all {
|
||||
searchController.searchBar.selectedScopeButtonIndex = SearchBarScope.all.rawValue
|
||||
} else {
|
||||
searchController.searchBar.selectedScopeButtonIndex = SearchBarScope.current.rawValue
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ class SSHKeySettingTableViewController: AutoCellHeightUITableViewController {
|
|||
do {
|
||||
try Data(contentsOf: privateKeyURL).write(to: URL(fileURLWithPath: SshKey.PRIVATE.getFileSharingPath()), options: .atomic)
|
||||
try self.passwordStore.gitSSHKeyImportFromFileSharing()
|
||||
SharedDefaults[.gitSSHKeySource] = .file
|
||||
SharedDefaults[.gitAuthenticationMethod] = .key
|
||||
Defaults.gitSSHKeySource = .file
|
||||
Defaults.gitAuthenticationMethod = .key
|
||||
SVProgressHUD.showSuccess(withStatus: "Imported".localize())
|
||||
SVProgressHUD.dismiss(withDelay: 1)
|
||||
} catch {
|
||||
Utils.alert(title: "Error".localize(), message: error.localizedDescription, controller: self, completion: nil)
|
||||
}
|
||||
SharedDefaults[.gitSSHKeySource] = .url
|
||||
Defaults.gitSSHKeySource = .url
|
||||
self.navigationController!.popViewController(animated: true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,17 +27,17 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
|
||||
@IBAction func savePGPKey(segue: UIStoryboardSegue) {
|
||||
if let controller = segue.source as? PGPKeySettingTableViewController {
|
||||
SharedDefaults[.pgpPrivateKeyURL] = URL(string: controller.pgpPrivateKeyURLTextField.text!.trimmed)
|
||||
SharedDefaults[.pgpPublicKeyURL] = URL(string: controller.pgpPublicKeyURLTextField.text!.trimmed)
|
||||
SharedDefaults[.pgpKeySource] = "url"
|
||||
Defaults.pgpPrivateKeyURL = URL(string: controller.pgpPrivateKeyURLTextField.text!.trimmed)
|
||||
Defaults.pgpPublicKeyURL = URL(string: controller.pgpPublicKeyURLTextField.text!.trimmed)
|
||||
Defaults.pgpKeySource = "url"
|
||||
|
||||
SVProgressHUD.setDefaultMaskType(.black)
|
||||
SVProgressHUD.setDefaultStyle(.light)
|
||||
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
|
||||
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
||||
do {
|
||||
try KeyFileManager.PublicPgp.importKey(from: SharedDefaults[.pgpPublicKeyURL]!)
|
||||
try KeyFileManager.PrivatePgp.importKey(from: SharedDefaults[.pgpPrivateKeyURL]!)
|
||||
try KeyFileManager.PublicPgp.importKey(from: Defaults.pgpPublicKeyURL!)
|
||||
try KeyFileManager.PrivatePgp.importKey(from: Defaults.pgpPrivateKeyURL!)
|
||||
try PGPAgent.shared.initKeys()
|
||||
DispatchQueue.main.async {
|
||||
self.setPGPKeyTableViewCellDetailText()
|
||||
|
|
@ -54,7 +54,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
}
|
||||
|
||||
} else if let controller = segue.source as? PGPKeyArmorSettingTableViewController {
|
||||
SharedDefaults[.pgpKeySource] = "armor"
|
||||
Defaults.pgpKeySource = "armor"
|
||||
|
||||
SVProgressHUD.setDefaultMaskType(.black)
|
||||
SVProgressHUD.setDefaultStyle(.light)
|
||||
|
|
@ -81,7 +81,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
|
||||
private func saveImportedPGPKey() {
|
||||
// load keys
|
||||
SharedDefaults[.pgpKeySource] = "file"
|
||||
Defaults.pgpKeySource = "file"
|
||||
SVProgressHUD.setDefaultMaskType(.black)
|
||||
SVProgressHUD.setDefaultStyle(.light)
|
||||
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
|
||||
|
|
@ -105,7 +105,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
}
|
||||
|
||||
@IBAction func saveGitServerSetting(segue: UIStoryboardSegue) {
|
||||
self.passwordRepositoryTableViewCell.detailTextLabel?.text = SharedDefaults[.gitURL].host
|
||||
self.passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults.gitURL.host
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
|
|
@ -115,7 +115,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(SettingsTableViewController.actOnPasswordStoreErasedNotification), name: .passwordStoreErased, object: nil)
|
||||
self.passwordRepositoryTableViewCell.detailTextLabel?.text = SharedDefaults[.gitURL].host
|
||||
self.passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults.gitURL.host
|
||||
setPGPKeyTableViewCellDetailText()
|
||||
setPasscodeLockCell()
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
|
||||
private func setPasswordRepositoryTableViewCellDetailText() {
|
||||
let host: String? = {
|
||||
let gitURL = SharedDefaults[.gitURL]
|
||||
let gitURL = Defaults.gitURL
|
||||
if gitURL.scheme == nil {
|
||||
return URL(string: "scheme://" + gitURL.absoluteString)?.host
|
||||
} else {
|
||||
|
|
@ -186,11 +186,11 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
var armorActionTitle = "AsciiArmorEncryptedKey".localize()
|
||||
var fileActionTitle = "ITunesFileSharing".localize()
|
||||
|
||||
if SharedDefaults[.pgpKeySource] == "url" {
|
||||
if Defaults.pgpKeySource == "url" {
|
||||
urlActionTitle = "✓ \(urlActionTitle)"
|
||||
} else if SharedDefaults[.pgpKeySource] == "armor" {
|
||||
} else if Defaults.pgpKeySource == "armor" {
|
||||
armorActionTitle = "✓ \(armorActionTitle)"
|
||||
} else if SharedDefaults[.pgpKeySource] == "file" {
|
||||
} else if Defaults.pgpKeySource == "file" {
|
||||
fileActionTitle = "✓ \(fileActionTitle)"
|
||||
}
|
||||
let urlAction = UIAlertAction(title: urlActionTitle, style: .default) { _ in
|
||||
|
|
@ -211,7 +211,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
// no
|
||||
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in
|
||||
self.keychain.removeContent(for: Globals.pgpKeyPassphrase)
|
||||
SharedDefaults[.isRememberPGPPassphraseOn] = false
|
||||
Defaults.isRememberPGPPassphraseOn = false
|
||||
self.saveImportedPGPKey()
|
||||
})
|
||||
// yes
|
||||
|
|
@ -220,7 +220,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
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
|
||||
self.keychain.add(string: alert.textFields?.first?.text, for: Globals.pgpKeyPassphrase)
|
||||
SharedDefaults[.isRememberPGPPassphraseOn] = true
|
||||
Defaults.isRememberPGPPassphraseOn = true
|
||||
self.saveImportedPGPKey()
|
||||
}))
|
||||
alert.addTextField(configurationHandler: {(textField: UITextField!) in
|
||||
|
|
@ -243,7 +243,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
|||
}
|
||||
|
||||
|
||||
if SharedDefaults[.pgpKeySource] != nil {
|
||||
if Defaults.pgpKeySource != nil {
|
||||
let deleteAction = UIAlertAction(title: "RemovePgpKeys".localize(), style: .destructive) { _ in
|
||||
self.keychain.removeContent(for: PgpKey.PUBLIC.getKeychainKey())
|
||||
self.keychain.removeContent(for: PgpKey.PRIVATE.getKeychainKey())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue