Polish the logic about touch ID and passcode lock
This commit is contained in:
parent
750532850a
commit
6fe3c00c9f
1 changed files with 14 additions and 23 deletions
|
|
@ -156,17 +156,19 @@ class SettingsTableViewController: UITableViewController {
|
||||||
touchIDTableViewCell.accessoryView = touchIDSwitch
|
touchIDTableViewCell.accessoryView = touchIDSwitch
|
||||||
setPGPKeyTableViewCellDetailText()
|
setPGPKeyTableViewCellDetailText()
|
||||||
setPasswordRepositoryTableViewCellDetailText()
|
setPasswordRepositoryTableViewCellDetailText()
|
||||||
setTouchIDSwitch()
|
setPasscodeLockTouchIDCells()
|
||||||
setPasscodeLockRepositoryTableViewCellDetailText()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setPasscodeLockRepositoryTableViewCellDetailText() {
|
private func setPasscodeLockTouchIDCells() {
|
||||||
if PasscodeLockRepository().hasPasscode {
|
if PasscodeLockRepository().hasPasscode {
|
||||||
self.passcodeTableViewCell.detailTextLabel?.text = "On"
|
self.passcodeTableViewCell.detailTextLabel?.text = "On"
|
||||||
|
Globals.passcodeConfiguration.isTouchIDAllowed = true
|
||||||
|
touchIDSwitch.isOn = Defaults[.isTouchIDOn]
|
||||||
} else {
|
} else {
|
||||||
self.passcodeTableViewCell.detailTextLabel?.text = "Off"
|
self.passcodeTableViewCell.detailTextLabel?.text = "Off"
|
||||||
touchIDSwitch.isEnabled = false
|
|
||||||
Globals.passcodeConfiguration.isTouchIDAllowed = false
|
Globals.passcodeConfiguration.isTouchIDAllowed = false
|
||||||
|
Defaults[.isTouchIDOn] = false
|
||||||
|
touchIDSwitch.isOn = Defaults[.isTouchIDOn]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,19 +188,10 @@ class SettingsTableViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setTouchIDSwitch() {
|
|
||||||
if Defaults[.isTouchIDOn] {
|
|
||||||
touchIDSwitch.isOn = true
|
|
||||||
} else {
|
|
||||||
touchIDSwitch.isOn = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func actOnPasswordStoreErasedNotification() {
|
func actOnPasswordStoreErasedNotification() {
|
||||||
setPGPKeyTableViewCellDetailText()
|
setPGPKeyTableViewCellDetailText()
|
||||||
setPasswordRepositoryTableViewCellDetailText()
|
setPasswordRepositoryTableViewCellDetailText()
|
||||||
setTouchIDSwitch()
|
setPasscodeLockTouchIDCells()
|
||||||
setPasscodeLockRepositoryTableViewCellDetailText()
|
|
||||||
|
|
||||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||||
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
|
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
|
||||||
|
|
@ -222,12 +215,12 @@ class SettingsTableViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func touchIDSwitchAction(uiSwitch: UISwitch) {
|
func touchIDSwitchAction(uiSwitch: UISwitch) {
|
||||||
if uiSwitch.isOn {
|
if !Globals.passcodeConfiguration.isTouchIDAllowed {
|
||||||
Defaults[.isTouchIDOn] = true
|
// switch off
|
||||||
Globals.passcodeConfiguration.isTouchIDAllowed = true
|
uiSwitch.isOn = Defaults[.isTouchIDOn] // false
|
||||||
|
Utils.alert(title: "Notice", message: "Please set the passcode lock first.", controller: self, completion: nil)
|
||||||
} else {
|
} else {
|
||||||
Defaults[.isTouchIDOn] = false
|
Defaults[.isTouchIDOn] = uiSwitch.isOn
|
||||||
Globals.passcodeConfiguration.isTouchIDAllowed = false
|
|
||||||
}
|
}
|
||||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||||
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
|
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
|
||||||
|
|
@ -335,8 +328,7 @@ class SettingsTableViewController: UITableViewController {
|
||||||
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||||
let removePasscodeAction = UIAlertAction(title: "Remove Passcode", style: .destructive) { [weak self] _ in
|
let removePasscodeAction = UIAlertAction(title: "Remove Passcode", style: .destructive) { [weak self] _ in
|
||||||
passcodeRemoveViewController.successCallback = { _ in
|
passcodeRemoveViewController.successCallback = { _ in
|
||||||
self?.passcodeTableViewCell.detailTextLabel?.text = "Off"
|
self?.setPasscodeLockTouchIDCells()
|
||||||
self?.touchIDSwitch.isEnabled = false
|
|
||||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||||
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
|
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration)
|
||||||
}
|
}
|
||||||
|
|
@ -359,8 +351,7 @@ class SettingsTableViewController: UITableViewController {
|
||||||
func setPasscodeLock() {
|
func setPasscodeLock() {
|
||||||
let passcodeSetViewController = PasscodeLockViewController(state: .set, configuration: Globals.passcodeConfiguration)
|
let passcodeSetViewController = PasscodeLockViewController(state: .set, configuration: Globals.passcodeConfiguration)
|
||||||
passcodeSetViewController.successCallback = { _ in
|
passcodeSetViewController.successCallback = { _ in
|
||||||
self.passcodeTableViewCell.detailTextLabel?.text = "On"
|
self.setPasscodeLockTouchIDCells()
|
||||||
self.touchIDSwitch.isEnabled = true
|
|
||||||
}
|
}
|
||||||
present(passcodeSetViewController, animated: true, completion: nil)
|
present(passcodeSetViewController, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue