Fix the Touch ID setting of passcode lock

- Disable Touch ID alone does not work before this commit.
This commit is contained in:
Yishi Lin 2017-09-18 00:48:09 +08:00
parent 611dd39131
commit 81af389a07
2 changed files with 7 additions and 5 deletions

View file

@ -165,12 +165,12 @@ class SettingsTableViewController: UITableViewController {
private func setPasscodeLockTouchIDCells() {
if PasscodeLockConfiguration.shared.repository.hasPasscode {
self.passcodeTableViewCell.detailTextLabel?.text = "On"
passcodeLockConfig.isTouchIDAllowed = true
passcodeLockConfig.isTouchIDAllowed = SharedDefaults[.isTouchIDOn]
touchIDSwitch.isOn = SharedDefaults[.isTouchIDOn]
} else {
self.passcodeTableViewCell.detailTextLabel?.text = "Off"
passcodeLockConfig.isTouchIDAllowed = false
SharedDefaults[.isTouchIDOn] = false
passcodeLockConfig.isTouchIDAllowed = SharedDefaults[.isTouchIDOn]
touchIDSwitch.isOn = SharedDefaults[.isTouchIDOn]
}
}
@ -214,14 +214,15 @@ class SettingsTableViewController: UITableViewController {
}
func touchIDSwitchAction(uiSwitch: UISwitch) {
if !passcodeLockConfig.isTouchIDAllowed || !isTouchIDEnabled() {
if !PasscodeLockConfiguration.shared.repository.hasPasscode || !isTouchIDEnabled() {
// switch off
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {
uiSwitch.isOn = SharedDefaults[.isTouchIDOn] // false
Utils.alert(title: "Notice", message: "Please enable Touch ID and set the passcode lock first.", controller: self, completion: nil)
uiSwitch.isOn = SharedDefaults[.isTouchIDOn] // SharedDefaults[.isTouchIDOn] should be false
Utils.alert(title: "Notice", message: "Please enable Touch ID of your phone and setup the passcode lock for Pass.", controller: self, completion: nil)
}
} else {
SharedDefaults[.isTouchIDOn] = uiSwitch.isOn
passcodeLockConfig.isTouchIDAllowed = SharedDefaults[.isTouchIDOn]
}
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: passcodeLockConfig)

View file

@ -16,6 +16,7 @@ public struct PasscodeLockConfiguration: PasscodeLockConfigurationType {
public let repository: PasscodeRepositoryType
public let passcodeLength = 4
public var isTouchIDAllowed = SharedDefaults[.isTouchIDOn]
public let shouldRequestTouchIDImmediately = true
public let maximumInccorectPasscodeAttempts = 3