Show password generation settings automatically

This commit is contained in:
Yishi Lin 2018-08-30 01:33:36 +08:00
parent aca01c8c72
commit 421b5aed1d

View file

@ -196,10 +196,8 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
// generate the password, don't care whether the original line is otp
func generateAndCopyPasswordNoOtpCheck() {
// show password settings (e.g., the length slider)
if hidePasswordSettings == true {
hidePasswordSettings = false
tableView.reloadSections([passwordSection], with: .fade)
}
showPasswordSettings()
let length = passwordLengthCell?.roundedValue ?? 0
let plainPassword = Utils.generatePassword(length: length)
SecurePasteboard.shared.copy(textToCopy: plainPassword)
@ -211,6 +209,15 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
fillPasswordCell?.setContent(content: plainPassword)
}
// show password settings (e.g., the length slider)
func showPasswordSettings() {
if hidePasswordSettings == true {
hidePasswordSettings = false
tableView.reloadSections([passwordSection], with: .fade)
}
}
// show/hide password settings (e.g., the length slider)
func showHidePasswordSettings() {
hidePasswordSettings = !hidePasswordSettings
tableView.reloadSections([passwordSection], with: .fade)
@ -275,6 +282,13 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
}
}
func textFieldDidBeginEditing(_ textField: UITextField) {
if textField == fillPasswordCell?.contentTextField {
// show password generation settings automatically
showPasswordSettings()
}
}
func getNameURL() -> (String, URL) {
let encodedName = (nameCell?.getContent()?.stringByAddingPercentEncodingForRFC3986())!
let name = URL(string: encodedName)!.lastPathComponent