Add option to select two flavors of password generator: random and apple's (keychain)
This commit is contained in:
parent
3cf88dcbc8
commit
ad0c39b541
5 changed files with 59 additions and 11 deletions
|
|
@ -52,6 +52,11 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
[[.title: "About Repository", .action: "segue", .link: "showAboutRepositorySegue"],],
|
||||
|
||||
// section 1
|
||||
[
|
||||
[.title: "Password Generator Flavor", .action: "none", .style: CellDataStyle.value1],
|
||||
],
|
||||
|
||||
// section 2
|
||||
[
|
||||
[.title: "Remember Passphrase", .action: "none",],
|
||||
],
|
||||
|
|
@ -81,7 +86,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
cell.accessoryView = accessoryView
|
||||
cell.selectionStyle = .none
|
||||
hideUnknownSwitch.isOn = Defaults[.isHideUnknownOn]
|
||||
case "Hide One Time Password Fields":
|
||||
case "Hide OTP Fields":
|
||||
cell.accessoryType = .none
|
||||
let detailButton = UIButton(type: .detailDisclosure)
|
||||
hideOTPSwitch.frame = CGRect(x: detailButton.bounds.width+10, y: 0, width: hideOTPSwitch.bounds.width, height: hideOTPSwitch.bounds.height)
|
||||
|
|
@ -101,11 +106,53 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
|||
cell.accessoryType = .none
|
||||
cell.selectionStyle = .none
|
||||
cell.accessoryView = showFolderSwitch
|
||||
case "Password Generator Flavor":
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
cell.detailTextLabel?.text = Defaults[.passwordGeneratorFlavor]
|
||||
default: break
|
||||
}
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
super.tableView(tableView, didSelectRowAt: indexPath)
|
||||
let cell = tableView.cellForRow(at: indexPath)!
|
||||
if cell.textLabel!.text! == "Password Generator Flavor" {
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
showPasswordGeneratorFlavorActionSheet(sourceCell: cell)
|
||||
}
|
||||
}
|
||||
|
||||
func showPasswordGeneratorFlavorActionSheet(sourceCell: UITableViewCell) {
|
||||
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
var randomFlavorActionTitle = ""
|
||||
var appleFlavorActionTitle = ""
|
||||
if Defaults[.passwordGeneratorFlavor] == "Random" {
|
||||
randomFlavorActionTitle = "✓ Random String"
|
||||
appleFlavorActionTitle = "Apple's Keychain Style"
|
||||
} else {
|
||||
randomFlavorActionTitle = "Random String"
|
||||
appleFlavorActionTitle = "✓ Apple's Keychain Style"
|
||||
}
|
||||
let randomFlavorAction = UIAlertAction(title: randomFlavorActionTitle, style: .default) { _ in
|
||||
Defaults[.passwordGeneratorFlavor] = "Random"
|
||||
sourceCell.detailTextLabel?.text = "Random"
|
||||
}
|
||||
|
||||
let appleFlavorAction = UIAlertAction(title: appleFlavorActionTitle, style: .default) { _ in
|
||||
Defaults[.passwordGeneratorFlavor] = "Apple"
|
||||
sourceCell.detailTextLabel?.text = "Apple"
|
||||
}
|
||||
|
||||
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
|
||||
optionMenu.addAction(randomFlavorAction)
|
||||
optionMenu.addAction(appleFlavorAction)
|
||||
optionMenu.addAction(cancelAction)
|
||||
optionMenu.popoverPresentationController?.sourceView = sourceCell
|
||||
optionMenu.popoverPresentationController?.sourceRect = sourceCell.bounds
|
||||
self.present(optionMenu, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func tapHideUnknownSwitchDetailButton(_ sender: Any?) {
|
||||
let alertMessage = "Only \"key: value\" format in additional fields is supported. Unsupported fields will be given \"unkown\" keys. Turn on this switch to hide unsupported fields."
|
||||
let alertTitle = "Hide Unknown Fields"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue