diff --git a/pass/AppDelegate.swift b/pass/AppDelegate.swift index 19c7a61..f78d574 100644 --- a/pass/AppDelegate.swift +++ b/pass/AppDelegate.swift @@ -15,9 +15,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - + lazy var passcodeLockPresenter: PasscodeLockPresenter = { + let presenter = PasscodeLockPresenter(mainWindow: self.window, configuration: Globals.passcodeConfiguration) + return presenter + }() + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. + passcodeLockPresenter.present() + print("Present") if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { print(shortcutItem.type) if shortcutItem.type == "me.mssun.pass.search" { @@ -49,10 +55,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - if PasscodeLockRepository().hasPasscode { - let passcodeEnterViewController = PasscodeLockViewController(state: .enter, configuration: Globals.passcodeConfiguration) - UIApplication.shared.keyWindow?.rootViewController?.present(passcodeEnterViewController, animated: true, completion: nil) - } + passcodeLockPresenter.present() } func applicationWillEnterForeground(_ application: UIApplication) { diff --git a/pass/PasswordsViewController.swift b/pass/PasswordsViewController.swift index 604f7fa..56b442d 100644 --- a/pass/PasswordsViewController.swift +++ b/pass/PasswordsViewController.swift @@ -56,11 +56,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV override func viewDidLoad() { super.viewDidLoad() - - if PasscodeLockRepository().hasPasscode { - let passcodeEnterViewController = PasscodeLockViewController(state: .enter, configuration: Globals.passcodeConfiguration) - UIApplication.shared.keyWindow?.rootViewController?.present(passcodeEnterViewController, animated: true, completion: nil) - } passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData() NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnPasswordUpdatedNotification), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(PasswordsViewController.actOnPasswordStoreErasedNotification), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil) diff --git a/pass/SettingsTableViewController.swift b/pass/SettingsTableViewController.swift index c8ee106..7268530 100644 --- a/pass/SettingsTableViewController.swift +++ b/pass/SettingsTableViewController.swift @@ -155,6 +155,8 @@ class SettingsTableViewController: UITableViewController { Defaults[.isTouchIDOn] = false Globals.passcodeConfiguration.isTouchIDAllowed = false } + let appDelegate = UIApplication.shared.delegate as! AppDelegate + appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration) } func showPasscodeActionSheet() {