From 81af389a071fd312acd13fdeb93ec1cedb6a2304 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Mon, 18 Sep 2017 00:48:09 +0800 Subject: [PATCH] Fix the Touch ID setting of passcode lock - Disable Touch ID alone does not work before this commit. --- pass/Controllers/SettingsTableViewController.swift | 11 ++++++----- passKit/Models/PasscodeLockConfiguration.swift | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift index 86c308a..2495378 100644 --- a/pass/Controllers/SettingsTableViewController.swift +++ b/pass/Controllers/SettingsTableViewController.swift @@ -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) diff --git a/passKit/Models/PasscodeLockConfiguration.swift b/passKit/Models/PasscodeLockConfiguration.swift index 4152ce9..eb26f21 100644 --- a/passKit/Models/PasscodeLockConfiguration.swift +++ b/passKit/Models/PasscodeLockConfiguration.swift @@ -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