Support generating memorable pwd: open xkpasswd
This commit is contained in:
parent
cacbeb57ee
commit
aca01c8c72
3 changed files with 20 additions and 5 deletions
|
|
@ -24,6 +24,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
|
||||||
lengthSetting.max > lengthSetting.min {
|
lengthSetting.max > lengthSetting.min {
|
||||||
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
||||||
}
|
}
|
||||||
|
tableData[1].append([.type: PasswordEditorCellType.memorablePasswordGeneratorCell])
|
||||||
tableData[0][0][PasswordEditorCellKey.content] = defaultDirPrefix
|
tableData[0][0][PasswordEditorCellKey.content] = defaultDirPrefix
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ class EditPasswordTableViewController: PasswordEditorTableViewController {
|
||||||
lengthSetting.max > lengthSetting.min {
|
lengthSetting.max > lengthSetting.min {
|
||||||
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
tableData[1].append([.type: PasswordEditorCellType.passwordLengthCell, .title: "passwordlength"])
|
||||||
}
|
}
|
||||||
|
tableData[1].append([.type: PasswordEditorCellType.memorablePasswordGeneratorCell])
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import OneTimePassword
|
||||||
import passKit
|
import passKit
|
||||||
|
|
||||||
enum PasswordEditorCellType {
|
enum PasswordEditorCellType {
|
||||||
case nameCell, fillPasswordCell, passwordLengthCell, additionsCell, deletePasswordCell, scanQRCodeCell
|
case nameCell, fillPasswordCell, passwordLengthCell, additionsCell, deletePasswordCell, scanQRCodeCell, memorablePasswordGeneratorCell
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PasswordEditorCellKey {
|
enum PasswordEditorCellKey {
|
||||||
|
|
@ -40,6 +40,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
var additionsCell: TextViewTableViewCell?
|
var additionsCell: TextViewTableViewCell?
|
||||||
private var deletePasswordCell: UITableViewCell?
|
private var deletePasswordCell: UITableViewCell?
|
||||||
private var scanQRCodeCell: UITableViewCell?
|
private var scanQRCodeCell: UITableViewCell?
|
||||||
|
private var memorablePasswordGeneratorCell: UITableViewCell?
|
||||||
|
|
||||||
override func loadView() {
|
override func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
@ -54,9 +55,12 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
scanQRCodeCell?.textLabel?.textColor = Globals.blue
|
scanQRCodeCell?.textLabel?.textColor = Globals.blue
|
||||||
scanQRCodeCell?.selectionStyle = .default
|
scanQRCodeCell?.selectionStyle = .default
|
||||||
scanQRCodeCell?.accessoryType = .disclosureIndicator
|
scanQRCodeCell?.accessoryType = .disclosureIndicator
|
||||||
// scanQRCodeCell?.imageView?.image = #imageLiteral(resourceName: "Camera").withRenderingMode(.alwaysTemplate)
|
|
||||||
// scanQRCodeCell?.imageView?.tintColor = Globals.blue
|
memorablePasswordGeneratorCell = UITableViewCell(style: .default, reuseIdentifier: "default")
|
||||||
// scanQRCodeCell?.imageView?.contentMode = .scaleAspectFit
|
memorablePasswordGeneratorCell?.textLabel?.text = "Get a Memorable One: xkpasswd"
|
||||||
|
memorablePasswordGeneratorCell?.textLabel?.textColor = Globals.blue
|
||||||
|
memorablePasswordGeneratorCell?.selectionStyle = .default
|
||||||
|
memorablePasswordGeneratorCell?.accessoryType = .disclosureIndicator
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
|
|
@ -115,6 +119,8 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
defaultValue: defaultLength)
|
defaultValue: defaultLength)
|
||||||
passwordLengthCell?.delegate = self
|
passwordLengthCell?.delegate = self
|
||||||
return passwordLengthCell!
|
return passwordLengthCell!
|
||||||
|
case .memorablePasswordGeneratorCell:
|
||||||
|
return memorablePasswordGeneratorCell!
|
||||||
case .additionsCell:
|
case .additionsCell:
|
||||||
additionsCell = tableView.dequeueReusableCell(withIdentifier: "textViewCell", for: indexPath) as?TextViewTableViewCell
|
additionsCell = tableView.dequeueReusableCell(withIdentifier: "textViewCell", for: indexPath) as?TextViewTableViewCell
|
||||||
additionsCell?.contentTextView.delegate = self
|
additionsCell?.contentTextView.delegate = self
|
||||||
|
|
@ -163,6 +169,10 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
self.present(alert, animated: true, completion: nil)
|
self.present(alert, animated: true, completion: nil)
|
||||||
} else if selectedCell == scanQRCodeCell {
|
} else if selectedCell == scanQRCodeCell {
|
||||||
self.performSegue(withIdentifier: "showQRScannerSegue", sender: self)
|
self.performSegue(withIdentifier: "showQRScannerSegue", sender: self)
|
||||||
|
} else if selectedCell == memorablePasswordGeneratorCell {
|
||||||
|
// open the webpage
|
||||||
|
guard let url = URL(string: "https://xkpasswd.net/") else { return }
|
||||||
|
UIApplication.shared.open(url)
|
||||||
}
|
}
|
||||||
tableView.deselectRow(at: indexPath, animated: true)
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +261,10 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
||||||
if textField == nameCell?.contentTextField {
|
if textField == nameCell?.contentTextField {
|
||||||
tableData[nameSection][0][PasswordEditorCellKey.content] = nameCell?.getContent()
|
tableData[nameSection][0][PasswordEditorCellKey.content] = nameCell?.getContent()
|
||||||
} else if textField == fillPasswordCell?.contentTextField {
|
} else if textField == fillPasswordCell?.contentTextField {
|
||||||
tableData[passwordSection][0][PasswordEditorCellKey.content] = fillPasswordCell?.getContent()
|
if let plainPassword = fillPasswordCell?.getContent() {
|
||||||
|
tableData[passwordSection][0][PasswordEditorCellKey.content] = plainPassword
|
||||||
|
SecurePasteboard.shared.copy(textToCopy: plainPassword)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue