diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index d9f7bfd..8eeec14 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -917,6 +917,7 @@ A239F5942158C08B00576CBF = { CreatedOnToolsVersion = 10.0; DevelopmentTeam = 4WDM8E95VU; + LastSwiftMigration = 1020; ProvisioningStyle = Manual; SystemCapabilities = { com.apple.ApplicationGroups.iOS = { @@ -929,19 +930,19 @@ }; A26075771EEC6F34005DB03E = { CreatedOnToolsVersion = 8.3.3; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Manual; }; A260757F1EEC6F34005DB03E = { CreatedOnToolsVersion = 8.3.3; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; TestTargetID = DC917BD21E2E8231000FDF54; }; A26700231EEC466A00176B8A = { CreatedOnToolsVersion = 8.3.3; DevelopmentTeam = 4WDM8E95VU; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Manual; SystemCapabilities = { com.apple.ApplicationGroups.iOS = { @@ -955,14 +956,14 @@ DC13B14D1E8640810097803F = { CreatedOnToolsVersion = 8.3; DevelopmentTeam = 4WDM8E95VU; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; TestTargetID = DC917BD21E2E8231000FDF54; }; DC917BD21E2E8231000FDF54 = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = 4WDM8E95VU; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Manual; SystemCapabilities = { com.apple.ApplicationGroups.iOS = { @@ -1454,7 +1455,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development me.mssun.passforios.auto-fill-credential-extension"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1480,7 +1481,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore me.mssun.passforios.auto-fill-credential-extension"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -1517,8 +1518,7 @@ SWIFT_INCLUDE_PATHS = ""; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1556,8 +1556,7 @@ SKIP_INSTALL = YES; SWIFT_INCLUDE_PATHS = ""; SWIFT_OBJC_BRIDGING_HEADER = ""; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1579,8 +1578,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).passKitTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/pass.app/pass"; }; name = Debug; @@ -1600,8 +1598,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).passKitTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/pass.app/pass"; }; name = Release; @@ -1628,8 +1625,7 @@ PROVISIONING_PROFILE = "d25c9029-bca6-4b2d-b04e-4abc9d232740"; PROVISIONING_PROFILE_SPECIFIER = "match Development me.mssun.passforios.find-login-action-extension"; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1656,8 +1652,7 @@ PROVISIONING_PROFILE = "cbd86628-6f3e-40f3-b518-20d2330db545"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore me.mssun.passforios.find-login-action-extension"; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -1675,8 +1670,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).passTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/pass.app/pass"; }; name = Debug; @@ -1694,8 +1688,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).passTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/pass.app/pass"; }; name = Release; @@ -1849,8 +1842,7 @@ PROVISIONING_PROFILE = "3c4f599a-ce77-4184-b4c4-edebf09cba3b"; PROVISIONING_PROFILE_SPECIFIER = "match Development me.mssun.passforios"; SWIFT_OBJC_BRIDGING_HEADER = "pass/Helpers/Objective-CBridgingHeader.h"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -1882,8 +1874,7 @@ PROVISIONING_PROFILE = "ee6e841d-ef77-4f00-b534-d7f1fd25dc1d"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore me.mssun.passforios"; SWIFT_OBJC_BRIDGING_HEADER = "pass/Helpers/Objective-CBridgingHeader.h"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/pass/AppDelegate.swift b/pass/AppDelegate.swift index ef7e533..5febb0a 100644 --- a/pass/AppDelegate.swift +++ b/pass/AppDelegate.swift @@ -25,11 +25,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return presenter }() - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. SVProgressHUD.setMinimumSize(CGSize(width: 150, height: 100)) - passcodeLockPresenter.present(windowLevel: UIApplication.shared.windows.last?.windowLevel) - if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { + passcodeLockPresenter.present(windowLevel: UIApplication.shared.windows.last?.windowLevel.rawValue) + if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { if shortcutItem.type == Globals.bundleIdentifier + ".search" { self.perform(#selector(postSearchNotification), with: nil, afterDelay: 0.4) } @@ -67,7 +67,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. // Display a blur effect view - let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light) + let blurEffect = UIBlurEffect(style: UIBlurEffect.Style.light) let blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView.frame = (self.window?.frame)! blurEffectView.tag = ViewTag.blur.rawValue @@ -95,7 +95,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. - passcodeLockPresenter.present(windowLevel: UIApplication.shared.windows.last?.windowLevel) + passcodeLockPresenter.present(windowLevel: UIApplication.shared.windows.last?.windowLevel.rawValue) } func applicationDidBecomeActive(_ application: UIApplication) { diff --git a/pass/Controllers/AboutRepositoryTableViewController.swift b/pass/Controllers/AboutRepositoryTableViewController.swift index fd5e346..8123a71 100644 --- a/pass/Controllers/AboutRepositoryTableViewController.swift +++ b/pass/Controllers/AboutRepositoryTableViewController.swift @@ -15,7 +15,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController { private var needRefresh = false private var indicator: UIActivityIndicatorView = { - let indicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) + let indicator = UIActivityIndicatorView(style: .gray) return indicator }() private let passwordStore = PasswordStore.shared @@ -59,7 +59,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController { guard let strongSelf = self else { return } - let type = UITableViewCellAccessoryType.none + let type = UITableViewCell.AccessoryType.none strongSelf.tableData = [ // section 0 [[.style: CellDataStyle.value1, .accessoryType: type, .title: "Passwords".localize(), .detailText: passwords], diff --git a/pass/Controllers/AdvancedSettingsTableViewController.swift b/pass/Controllers/AdvancedSettingsTableViewController.swift index 09862d0..a775b79 100644 --- a/pass/Controllers/AdvancedSettingsTableViewController.swift +++ b/pass/Controllers/AdvancedSettingsTableViewController.swift @@ -22,7 +22,7 @@ class AdvancedSettingsTableViewController: UITableViewController { let uiSwitch = UISwitch() uiSwitch.onTintColor = Globals.blue uiSwitch.sizeToFit() - uiSwitch.addTarget(self, action: #selector(encryptInASCIIArmoredAction(_:)), for: UIControlEvents.valueChanged) + uiSwitch.addTarget(self, action: #selector(encryptInASCIIArmoredAction(_:)), for: UIControl.Event.valueChanged) return uiSwitch }() @@ -48,19 +48,19 @@ class AdvancedSettingsTableViewController: UITableViewController { override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) if tableView.cellForRow(at: indexPath) == eraseDataTableViewCell { - let alert = UIAlertController(title: "ErasePasswordStoreData?".localize(), message: "EraseExplanation.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "ErasePasswordStoreData".localize(), style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in + let alert = UIAlertController(title: "ErasePasswordStoreData?".localize(), message: "EraseExplanation.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "ErasePasswordStoreData".localize(), style: UIAlertAction.Style.destructive, handler: {[unowned self] (action) -> Void in SVProgressHUD.show(withStatus: "Erasing...".localize()) self.passwordStore.erase() self.navigationController!.popViewController(animated: true) SVProgressHUD.showSuccess(withStatus: "Done".localize()) SVProgressHUD.dismiss(withDelay: 1) })) - alert.addAction(UIAlertAction(title: "Dismiss".localize(), style: UIAlertActionStyle.cancel, handler:nil)) + alert.addAction(UIAlertAction(title: "Dismiss".localize(), style: UIAlertAction.Style.cancel, handler:nil)) self.present(alert, animated: true, completion: nil) } else if tableView.cellForRow(at: indexPath) == discardChangesTableViewCell { - let alert = UIAlertController(title: "DiscardAllLocalChanges?".localize(), message: "DiscardExplanation.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "DiscardAllLocalChanges".localize(), style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in + let alert = UIAlertController(title: "DiscardAllLocalChanges?".localize(), message: "DiscardExplanation.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "DiscardAllLocalChanges".localize(), style: UIAlertAction.Style.destructive, handler: {[unowned self] (action) -> Void in SVProgressHUD.show(withStatus: "Resetting...".localize()) do { let numberDiscarded = try self.passwordStore.reset() @@ -72,7 +72,7 @@ class AdvancedSettingsTableViewController: UITableViewController { } })) - alert.addAction(UIAlertAction(title: "Dismiss".localize(), style: UIAlertActionStyle.cancel, handler:nil)) + alert.addAction(UIAlertAction(title: "Dismiss".localize(), style: UIAlertAction.Style.cancel, handler:nil)) self.present(alert, animated: true, completion: nil) } } diff --git a/pass/Controllers/BasicStaticTableViewController.swift b/pass/Controllers/BasicStaticTableViewController.swift index 9fd77c2..c061e05 100644 --- a/pass/Controllers/BasicStaticTableViewController.swift +++ b/pass/Controllers/BasicStaticTableViewController.swift @@ -65,7 +65,7 @@ class BasicStaticTableViewController: UITableViewController, MFMailComposeViewCo if let detailText = cellData[CellDataKey.detailText] as? String { cell?.detailTextLabel?.text = detailText } - if let accessoryType = cellData[CellDataKey.accessoryType] as? UITableViewCellAccessoryType { + if let accessoryType = cellData[CellDataKey.accessoryType] as? UITableViewCell.AccessoryType { cell?.accessoryType = accessoryType } else { cell?.accessoryType = .disclosureIndicator diff --git a/pass/Controllers/CommitLogsTableViewController.swift b/pass/Controllers/CommitLogsTableViewController.swift index adf7697..1efaa1b 100644 --- a/pass/Controllers/CommitLogsTableViewController.swift +++ b/pass/Controllers/CommitLogsTableViewController.swift @@ -19,7 +19,7 @@ class CommitLogsTableViewController: UITableViewController { NotificationCenter.default.addObserver(self, selector: #selector(updateCommitLogs), name: .passwordStoreUpdated, object: nil) commits = getCommitLogs() self.tableView.estimatedRowHeight = 50 - self.tableView.rowHeight = UITableViewAutomaticDimension + self.tableView.rowHeight = UITableView.automaticDimension } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { diff --git a/pass/Controllers/GeneralSettingsTableViewController.swift b/pass/Controllers/GeneralSettingsTableViewController.swift index 22227b3..521dde1 100644 --- a/pass/Controllers/GeneralSettingsTableViewController.swift +++ b/pass/Controllers/GeneralSettingsTableViewController.swift @@ -16,7 +16,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let uiSwitch = UISwitch() uiSwitch.onTintColor = Globals.blue uiSwitch.sizeToFit() - uiSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControlEvents.valueChanged) + uiSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControl.Event.valueChanged) return uiSwitch }() @@ -24,7 +24,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let uiSwitch = UISwitch() uiSwitch.onTintColor = Globals.blue uiSwitch.sizeToFit() - uiSwitch.addTarget(self, action: #selector(hideOTPSwitchAction(_:)), for: UIControlEvents.valueChanged) + uiSwitch.addTarget(self, action: #selector(hideOTPSwitchAction(_:)), for: UIControl.Event.valueChanged) return uiSwitch }() @@ -32,7 +32,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let uiSwitch = UISwitch() uiSwitch.onTintColor = Globals.blue uiSwitch.sizeToFit() - uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction(_:)), for: UIControlEvents.valueChanged) + uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isRememberPGPPassphraseOn] return uiSwitch }() @@ -41,7 +41,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let uiSwitch = UISwitch() uiSwitch.onTintColor = Globals.blue uiSwitch.sizeToFit() - uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction(_:)), for: UIControlEvents.valueChanged) + uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isRememberGitCredentialPassphraseOn] return uiSwitch }() @@ -50,7 +50,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let uiSwitch = UISwitch() uiSwitch.onTintColor = Globals.blue uiSwitch.sizeToFit() - uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction(_:)), for: UIControlEvents.valueChanged) + uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isShowFolderOn] return uiSwitch }() @@ -59,7 +59,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let uiSwitch = UISwitch() uiSwitch.onTintColor = Globals.blue uiSwitch.sizeToFit() - uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction(_:)), for: UIControlEvents.valueChanged) + uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction(_:)), for: UIControl.Event.valueChanged) uiSwitch.isOn = SharedDefaults[.isHidePasswordImagesOn] return uiSwitch }() @@ -99,7 +99,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let detailButton = UIButton(type: .detailDisclosure) hideUnknownSwitch.frame = CGRect(x: detailButton.bounds.width+10, y: 0, width: hideUnknownSwitch.bounds.width, height: hideUnknownSwitch.bounds.height) detailButton.frame = CGRect(x: 0, y: 5, width: detailButton.bounds.width, height: detailButton.bounds.height) - detailButton.addTarget(self, action: #selector(GeneralSettingsTableViewController.tapHideUnknownSwitchDetailButton(_:)), for: UIControlEvents.touchDown) + detailButton.addTarget(self, action: #selector(GeneralSettingsTableViewController.tapHideUnknownSwitchDetailButton(_:)), for: UIControl.Event.touchDown) let accessoryView = UIView(frame: CGRect(x: 0, y: 0, width: detailButton.bounds.width + hideUnknownSwitch.bounds.width+10, height: hideUnknownSwitch.bounds.height)) accessoryView.addSubview(detailButton) accessoryView.addSubview(hideUnknownSwitch) @@ -111,7 +111,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let detailButton = UIButton(type: .detailDisclosure) hideOTPSwitch.frame = CGRect(x: detailButton.bounds.width+10, y: 0, width: hideOTPSwitch.bounds.width, height: hideOTPSwitch.bounds.height) detailButton.frame = CGRect(x: 0, y: 5, width: detailButton.bounds.width, height: detailButton.bounds.height) - detailButton.addTarget(self, action: #selector(GeneralSettingsTableViewController.tapHideOTPSwitchDetailButton(_:)), for: UIControlEvents.touchDown) + detailButton.addTarget(self, action: #selector(GeneralSettingsTableViewController.tapHideOTPSwitchDetailButton(_:)), for: UIControl.Event.touchDown) let accessoryView = UIView(frame: CGRect(x: 0, y: 0, width: detailButton.bounds.width + hideOTPSwitch.bounds.width+10, height: hideOTPSwitch.bounds.height)) accessoryView.addSubview(detailButton) accessoryView.addSubview(hideOTPSwitch) @@ -135,7 +135,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { let detailButton = UIButton(type: .detailDisclosure) hidePasswordImagesSwitch.frame = CGRect(x: detailButton.bounds.width+10, y: 0, width: hidePasswordImagesSwitch.bounds.width, height: hidePasswordImagesSwitch.bounds.height) detailButton.frame = CGRect(x: 0, y: 5, width: detailButton.bounds.width, height: detailButton.bounds.height) - detailButton.addTarget(self, action: #selector(GeneralSettingsTableViewController.tapHidePasswordImagesSwitchDetailButton(_:)), for: UIControlEvents.touchDown) + detailButton.addTarget(self, action: #selector(GeneralSettingsTableViewController.tapHidePasswordImagesSwitchDetailButton(_:)), for: UIControl.Event.touchDown) let accessoryView = UIView(frame: CGRect(x: 0, y: 0, width: detailButton.bounds.width + hidePasswordImagesSwitch.bounds.width+10, height: hidePasswordImagesSwitch.bounds.height)) accessoryView.addSubview(detailButton) accessoryView.addSubview(hidePasswordImagesSwitch) diff --git a/pass/Controllers/GitConfigSettingTableViewController.swift b/pass/Controllers/GitConfigSettingTableViewController.swift index 30682e7..a9713fd 100644 --- a/pass/Controllers/GitConfigSettingTableViewController.swift +++ b/pass/Controllers/GitConfigSettingTableViewController.swift @@ -18,7 +18,7 @@ class GitConfigSettingTableViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() - tableView.rowHeight = UITableViewAutomaticDimension + tableView.rowHeight = UITableView.automaticDimension let signature = passwordStore.gitSignatureForNow nameTextField.placeholder = signature.name diff --git a/pass/Controllers/GitServerSettingTableViewController.swift b/pass/Controllers/GitServerSettingTableViewController.swift index 3aee6eb..b43a5bd 100644 --- a/pass/Controllers/GitServerSettingTableViewController.swift +++ b/pass/Controllers/GitServerSettingTableViewController.swift @@ -121,16 +121,16 @@ class GitServerSettingTableViewController: UITableViewController { SharedDefaults[.gitBranchName] = branchName SharedDefaults[.gitAuthenticationMethod] = auth SVProgressHUD.dismiss() - let savePassphraseAlert = UIAlertController(title: "Done".localize(), message: "WantToSaveGitCredential?".localize(), preferredStyle: UIAlertControllerStyle.alert) + let savePassphraseAlert = UIAlertController(title: "Done".localize(), message: "WantToSaveGitCredential?".localize(), preferredStyle: UIAlertController.Style.alert) // no - savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertActionStyle.default) { _ in + savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in SharedDefaults[.isRememberGitCredentialPassphraseOn] = false self.passwordStore.gitPassword = nil self.passwordStore.gitSSHPrivateKeyPassphrase = nil self.performSegue(withIdentifier: "saveGitServerSettingSegue", sender: self) }) // yes - savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertActionStyle.destructive) {_ in + savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertAction.Style.destructive) {_ in SharedDefaults[.isRememberGitCredentialPassphraseOn] = true self.performSegue(withIdentifier: "saveGitServerSettingSegue", sender: self) }) @@ -195,12 +195,12 @@ class GitServerSettingTableViewController: UITableViewController { } if passwordStore.repositoryExisted() { - let alert = UIAlertController(title: "Overwrite?".localize(), message: "OperationWillOverwriteData.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Overwrite".localize(), style: UIAlertActionStyle.destructive, handler: { _ in + let alert = UIAlertController(title: "Overwrite?".localize(), message: "OperationWillOverwriteData.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Overwrite".localize(), style: UIAlertAction.Style.destructive, handler: { _ in // perform segue only after a successful clone self.cloneAndSegueIfSuccess() })) - alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertActionStyle.cancel, handler: nil)) + alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertAction.Style.cancel, handler: nil)) self.present(alert, animated: true, completion: nil) } else { // perform segue only after a successful clone @@ -285,12 +285,12 @@ class GitServerSettingTableViewController: UITableViewController { DispatchQueue.main.async { SVProgressHUD.dismiss() - let alert = UIAlertController(title: "Password".localize(), message: message, preferredStyle: UIAlertControllerStyle.alert) + let alert = UIAlertController(title: "Password".localize(), message: message, preferredStyle: UIAlertController.Style.alert) alert.addTextField(configurationHandler: {(textField: UITextField!) in textField.text = lastPassword ?? "" textField.isSecureTextEntry = true }) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in password = alert.textFields!.first!.text sem.signal() })) diff --git a/pass/Controllers/OpenSourceComponentsTableViewController.swift b/pass/Controllers/OpenSourceComponentsTableViewController.swift index 0134926..931b606 100644 --- a/pass/Controllers/OpenSourceComponentsTableViewController.swift +++ b/pass/Controllers/OpenSourceComponentsTableViewController.swift @@ -38,7 +38,7 @@ class OpenSourceComponentsTableViewController: BasicStaticTableViewController { tableData.append([]) for item in openSourceComponents { tableData[0].append( - [CellDataKey.title: item[0], CellDataKey.action: "link", CellDataKey.link: item[1], CellDataKey.accessoryType: UITableViewCellAccessoryType.detailDisclosureButton, CellDataKey.detailDisclosureAction: #selector(actOnDetailDisclosureButton(_:)), CellDataKey.detailDisclosureData: item[2]] + [CellDataKey.title: item[0], CellDataKey.action: "link", CellDataKey.link: item[1], CellDataKey.accessoryType: UITableViewCell.AccessoryType.detailDisclosureButton, CellDataKey.detailDisclosureAction: #selector(actOnDetailDisclosureButton(_:)), CellDataKey.detailDisclosureData: item[2]] ) } super.viewDidLoad() diff --git a/pass/Controllers/PGPKeyArmorSettingTableViewController.swift b/pass/Controllers/PGPKeyArmorSettingTableViewController.swift index 8b85675..76136f1 100644 --- a/pass/Controllers/PGPKeyArmorSettingTableViewController.swift +++ b/pass/Controllers/PGPKeyArmorSettingTableViewController.swift @@ -114,18 +114,18 @@ class PGPKeyArmorSettingTableViewController: AutoCellHeightUITableViewController Utils.alert(title: "CannotSave".localize(), message: "SetPrivateKey.".localize(), controller: self, completion: nil) return } - let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertControllerStyle.alert) + let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertController.Style.alert) // no - savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertActionStyle.default) { _ in + savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in self.pgpPassphrase = nil SharedDefaults[.isRememberPGPPassphraseOn] = false self.performSegue(withIdentifier: "savePGPKeySegue", sender: self) }) // yes - savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertActionStyle.destructive) {_ in + savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertAction.Style.destructive) {_ in // ask for the passphrase - let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in self.pgpPassphrase = alert.textFields?.first?.text SharedDefaults[.isRememberPGPPassphraseOn] = true self.performSegue(withIdentifier: "savePGPKeySegue", sender: self) diff --git a/pass/Controllers/PGPKeySettingTableViewController.swift b/pass/Controllers/PGPKeySettingTableViewController.swift index d18cb8a..195b9d2 100644 --- a/pass/Controllers/PGPKeySettingTableViewController.swift +++ b/pass/Controllers/PGPKeySettingTableViewController.swift @@ -40,18 +40,18 @@ class PGPKeySettingTableViewController: AutoCellHeightUITableViewController { validatePGPKeyURL(input: pgpPrivateKeyURLTextField.text) == true else { return } - let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertControllerStyle.alert) + let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertController.Style.alert) // no - savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertActionStyle.default) { _ in + savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in self.pgpPassphrase = nil SharedDefaults[.isRememberPGPPassphraseOn] = false self.performSegue(withIdentifier: "savePGPKeySegue", sender: self) }) // yes - savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertActionStyle.destructive) {_ in + savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertAction.Style.destructive) {_ in // ask for the passphrase - let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in self.pgpPassphrase = alert.textFields?.first?.text SharedDefaults[.isRememberPGPPassphraseOn] = true self.performSegue(withIdentifier: "savePGPKeySegue", sender: self) diff --git a/pass/Controllers/PasswordDetailTableViewController.swift b/pass/Controllers/PasswordDetailTableViewController.swift index 7a748e4..35173e3 100644 --- a/pass/Controllers/PasswordDetailTableViewController.swift +++ b/pass/Controllers/PasswordDetailTableViewController.swift @@ -51,8 +51,8 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni tableView.addGestureRecognizer(tapGesture) tapGesture.delegate = self - tableView.contentInset = UIEdgeInsetsMake(-36, 0, 44, 0); - tableView.rowHeight = UITableViewAutomaticDimension + tableView.contentInset = UIEdgeInsets.init(top: -36, left: 0, bottom: 44, right: 0); + tableView.rowHeight = UITableView.automaticDimension tableView.estimatedRowHeight = 52 editUIBarButtonItem.isEnabled = false @@ -81,8 +81,8 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni override func viewDidAppear(_ animated: Bool) { super.viewWillAppear(animated) if self.shouldPopCurrentView { - let alert = UIAlertController(title: "Notice".localize(), message: "PreviousChangesDiscarded.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + let alert = UIAlertController(title: "Notice".localize(), message: "PreviousChangesDiscarded.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in _ = self.navigationController?.popViewController(animated: true) })) self.present(alert, animated: true, completion: nil) @@ -93,8 +93,8 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni let sem = DispatchSemaphore(value: 0) var passphrase = "" DispatchQueue.main.async { - let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in passphrase = alert.textFields!.first!.text! sem.signal() })) @@ -127,11 +127,11 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni // remove the wrong passphrase so that users could enter it next time self.passwordStore.pgpKeyPassphrase = nil // alert: cancel or try again - let alert = UIAlertController(title: "CannotShowPassword".localize(), message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertActionStyle.default) { _ in + let alert = UIAlertController(title: "CannotShowPassword".localize(), message: error.localizedDescription, preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertAction.Style.default) { _ in self.navigationController!.popViewController(animated: true) }) - alert.addAction(UIAlertAction(title: "TryAgain".localize(), style: UIAlertActionStyle.destructive) {_ in + alert.addAction(UIAlertAction(title: "TryAgain".localize(), style: UIAlertAction.Style.destructive) {_ in self.decryptThenShowPassword() }) self.present(alert, animated: true, completion: nil) @@ -301,8 +301,8 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni if case let .success(image) = result { let indexPath = IndexPath(row: 0, section: 0) self?.passwordImage = image - self?.tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic) - let imageData = UIImageJPEGRepresentation(image, 1) + self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.automatic) + let imageData = image.jpegData(compressionQuality: 1) if let entity = self?.passwordEntity { self?.passwordStore.updateImage(passwordEntity: entity, image: imageData) } @@ -311,7 +311,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni } @objc private func tapMenu(recognizer: UITapGestureRecognizer) { - if recognizer.state == UIGestureRecognizerState.ended { + if recognizer.state == UIGestureRecognizer.State.ended { let tapLocation = recognizer.location(in: self.tableView) if let tapIndexPath = self.tableView.indexPathForRow(at: tapLocation) { if let tappedCell = self.tableView.cellForRow(at: tapIndexPath) as? LabelTableViewCell { diff --git a/pass/Controllers/PasswordEditorTableViewController.swift b/pass/Controllers/PasswordEditorTableViewController.swift index 0e681a7..6d038d3 100644 --- a/pass/Controllers/PasswordEditorTableViewController.swift +++ b/pass/Controllers/PasswordEditorTableViewController.swift @@ -75,9 +75,9 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl tableView.register(UINib(nibName: "FillPasswordTableViewCell", bundle: nil), forCellReuseIdentifier: "fillPasswordCell") tableView.register(UINib(nibName: "SliderTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordLengthCell") - tableView.rowHeight = UITableViewAutomaticDimension + tableView.rowHeight = UITableView.automaticDimension tableView.estimatedRowHeight = 48 - self.tableView.sectionFooterHeight = UITableViewAutomaticDimension; + self.tableView.sectionFooterHeight = UITableView.automaticDimension; self.tableView.estimatedSectionFooterHeight = 0; } override func viewDidLayoutSubviews() { @@ -161,11 +161,11 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let selectedCell = tableView.cellForRow(at: indexPath) if selectedCell == deletePasswordCell { - let alert = UIAlertController(title: "DeletePassword?".localize(), message: nil, preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Delete".localize(), style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in + let alert = UIAlertController(title: "DeletePassword?".localize(), message: nil, preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Delete".localize(), style: UIAlertAction.Style.destructive, handler: {[unowned self] (action) -> Void in self.performSegue(withIdentifier: "deletePasswordSegue", sender: self) })) - alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertActionStyle.cancel, handler:nil)) + alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertAction.Style.cancel, handler:nil)) self.present(alert, animated: true, completion: nil) } else if selectedCell == scanQRCodeCell { self.performSegue(withIdentifier: "showQRScannerSegue", sender: self) @@ -185,11 +185,11 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl // check whether the current password looks like an OTP field func generateAndCopyPassword() { if let currentPassword = fillPasswordCell?.getContent(), Constants.isOtpRelated(line: currentPassword) { - let alert = UIAlertController(title: "Overwrite?".localize(), message: "OverwriteOtpConfiguration?".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertActionStyle.destructive, handler: {_ in + let alert = UIAlertController(title: "Overwrite?".localize(), message: "OverwriteOtpConfiguration?".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertAction.Style.destructive, handler: {_ in self.generateAndCopyPasswordNoOtpCheck() })) - alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertActionStyle.cancel, handler: nil)) + alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertAction.Style.cancel, handler: nil)) self.present(alert, animated: true, completion: nil) } else { self.generateAndCopyPasswordNoOtpCheck() @@ -337,11 +337,11 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl let copiedLinesSplit = UIPasteboard.general.string?.components(separatedBy: CharacterSet.whitespacesAndNewlines).filter({ !$0.isEmpty }) if copiedLinesSplit?.count ?? 0 > 0 { let generatedPassword = copiedLinesSplit![0] - let alert = UIAlertController(title: "WannaUseIt?".localize(), message: "", preferredStyle: UIAlertControllerStyle.alert) + let alert = UIAlertController(title: "WannaUseIt?".localize(), message: "", preferredStyle: UIAlertController.Style.alert) let message = NSMutableAttributedString(string: "\("SeemsLikeYouHaveCopiedSomething.".localize()) \("FirstStringIs:".localize())\n") message.append(Utils.attributedPassword(plainPassword: generatedPassword)) alert.setValue(message, forKey: "attributedMessage") - alert.addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.default, handler: {[unowned self] (action) -> Void in + alert.addAction(UIAlertAction(title: "Yes", style: UIAlertAction.Style.default, handler: {[unowned self] (action) -> Void in // update tableData so to make sure reloadData() works correctly self.tableData[self.passwordSection][0][PasswordEditorCellKey.content] = generatedPassword // update cell manually, no need to call reloadData() @@ -349,7 +349,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl // make sure the clipboard gets cleared in 45s SecurePasteboard.shared.copy(textToCopy: generatedPassword) })) - alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertActionStyle.cancel, handler:nil)) + alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertAction.Style.cancel, handler:nil)) self.present(alert, animated: true, completion: nil) } } diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index bcc53d3..ff68252 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -44,7 +44,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV }() private lazy var syncControl: UIRefreshControl = { let syncControl = UIRefreshControl() - syncControl.addTarget(self, action: #selector(handleRefresh(_:)), for: UIControlEvents.valueChanged) + syncControl.addTarget(self, action: #selector(handleRefresh(_:)), for: UIControl.Event.valueChanged) return syncControl }() private lazy var searchBarView: UIView? = { @@ -62,21 +62,21 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV private lazy var transitionFromRight: CATransition = { let transition = CATransition() - transition.type = kCATransitionPush - transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) - transition.fillMode = kCAFillModeForwards + transition.type = CATransitionType.push + transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) + transition.fillMode = CAMediaTimingFillMode.forwards transition.duration = 0.25 - transition.subtype = kCATransitionFromRight + transition.subtype = CATransitionSubtype.fromRight return transition }() private lazy var transitionFromLeft: CATransition = { let transition = CATransition() - transition.type = kCATransitionPush - transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) - transition.fillMode = kCAFillModeForwards + transition.type = CATransitionType.push + transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) + transition.fillMode = CAMediaTimingFillMode.forwards transition.duration = 0.25 - transition.subtype = kCATransitionFromLeft + transition.subtype = CATransitionSubtype.fromLeft return transition }() @@ -213,7 +213,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV navigationItem.hidesSearchBarWhenScrolling = false } else { // Fallback on earlier versions - tableView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0) + tableView.contentInset = UIEdgeInsets.init(top: 44, left: 0, bottom: 0, right: 0) view.addSubview(searchBarView!) } tableView.refreshControl = syncControl @@ -231,7 +231,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV // listen to the swipe back guesture let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture)) - swipeRight.direction = UISwipeGestureRecognizerDirection.right + swipeRight.direction = UISwipeGestureRecognizer.Direction.right self.view.addGestureRecognizer(swipeRight) } @@ -337,7 +337,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } @objc func longPressAction(_ gesture: UILongPressGestureRecognizer) { - if gesture.state == UIGestureRecognizerState.began { + if gesture.state == UIGestureRecognizer.State.began { let touchPoint = gesture.location(in: tableView) if let indexPath = tableView.indexPathForRow(at: touchPoint) { decryptThenCopyPassword(from: indexPath) @@ -365,8 +365,8 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV let sem = DispatchSemaphore(value: 0) var passphrase = "" DispatchQueue.main.async { - let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in passphrase = alert.textFields!.first!.text! sem.signal() })) @@ -620,12 +620,12 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV DispatchQueue.main.async { SVProgressHUD.dismiss() - let alert = UIAlertController(title: "Password".localize(), message: message, preferredStyle: UIAlertControllerStyle.alert) + let alert = UIAlertController(title: "Password".localize(), message: message, preferredStyle: UIAlertController.Style.alert) alert.addTextField(configurationHandler: {(textField: UITextField!) in textField.text = lastPassword ?? "" textField.isSecureTextEntry = true }) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in password = alert.textFields!.first!.text sem.signal() })) diff --git a/pass/Controllers/QRScannerController.swift b/pass/Controllers/QRScannerController.swift index a4b695f..4131b47 100644 --- a/pass/Controllers/QRScannerController.swift +++ b/pass/Controllers/QRScannerController.swift @@ -68,7 +68,7 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg // Move the message label to the front scannerOutput.layer.cornerRadius = 10 scannerOutput.text = "NoQrCodeDetected.".localize() - view.bringSubview(toFront: scannerOutput) + view.bringSubviewToFront(scannerOutput) // Initialize QR Code Frame to highlight the QR code qrCodeFrameView = UIView() @@ -77,7 +77,7 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg qrCodeFrameView.layer.borderColor = UIColor.green.cgColor qrCodeFrameView.layer.borderWidth = 2 view.addSubview(qrCodeFrameView) - view.bringSubview(toFront: qrCodeFrameView) + view.bringSubviewToFront(qrCodeFrameView) } } catch { @@ -135,7 +135,7 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "Cancel".localize(), style: .default)) alertController.addAction(UIAlertAction(title: "Settings".localize(), style: .cancel) { _ in - if let url = URL(string: UIApplicationOpenSettingsURLString) { + if let url = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(url, options: [:], completionHandler: { _ in // Handle }) diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift index 5641948..a18b81c 100644 --- a/pass/Controllers/SettingsTableViewController.swift +++ b/pass/Controllers/SettingsTableViewController.swift @@ -201,18 +201,18 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele fileActionTitle.append(" (\("Import".localize()))") let fileAction = UIAlertAction(title: fileActionTitle, style: .default) { _ in // passphrase related - let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertControllerStyle.alert) + let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertController.Style.alert) // no - savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertActionStyle.default) { _ in + savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in self.passwordStore.pgpKeyPassphrase = nil SharedDefaults[.isRememberPGPPassphraseOn] = false self.saveImportedPGPKey() }) // yes - savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertActionStyle.destructive) {_ in + savePassphraseAlert.addAction(UIAlertAction(title: "Yes".localize(), style: UIAlertAction.Style.destructive) {_ in // ask for the passphrase - let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in self.passwordStore.pgpKeyPassphrase = alert.textFields?.first?.text SharedDefaults[.isRememberPGPPassphraseOn] = true self.saveImportedPGPKey() @@ -296,12 +296,12 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele setPasscodeLockAlert?.addTextField(configurationHandler: {(_ textField: UITextField) -> Void in textField.placeholder = "Passcode".localize() textField.isSecureTextEntry = true - textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControlEvents.editingChanged) + textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControl.Event.editingChanged) }) setPasscodeLockAlert?.addTextField(configurationHandler: {(_ textField: UITextField) -> Void in textField.placeholder = "PasswordConfirmation".localize() textField.isSecureTextEntry = true - textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControlEvents.editingChanged) + textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControl.Event.editingChanged) }) // save action diff --git a/pass/Helpers/SecurePasteboard.swift b/pass/Helpers/SecurePasteboard.swift index 8dbbe49..302ca02 100644 --- a/pass/Helpers/SecurePasteboard.swift +++ b/pass/Helpers/SecurePasteboard.swift @@ -11,7 +11,7 @@ import UIKit class SecurePasteboard { public static let shared = SecurePasteboard() - private var backgroundTaskID = UIBackgroundTaskInvalid + private var backgroundTaskID = UIBackgroundTaskIdentifier.invalid func copy(textToCopy: String?, expirationTime: Double = 45) { // copy to the pasteboard @@ -23,21 +23,21 @@ class SecurePasteboard { } // exit the existing background task, if any - if backgroundTaskID != UIBackgroundTaskInvalid { - UIApplication.shared.endBackgroundTask(UIBackgroundTaskInvalid) - self.backgroundTaskID = UIBackgroundTaskInvalid + if backgroundTaskID != UIBackgroundTaskIdentifier.invalid { + UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier.invalid) + self.backgroundTaskID = UIBackgroundTaskIdentifier.invalid } backgroundTaskID = UIApplication.shared.beginBackgroundTask(expirationHandler: { [weak self] in UIPasteboard.general.string = "" - UIApplication.shared.endBackgroundTask(UIBackgroundTaskInvalid) - self?.backgroundTaskID = UIBackgroundTaskInvalid + UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier.invalid) + self?.backgroundTaskID = UIBackgroundTaskIdentifier.invalid }) DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + expirationTime) { [weak self] in UIPasteboard.general.string = "" - UIApplication.shared.endBackgroundTask(UIBackgroundTaskInvalid) - self?.backgroundTaskID = UIBackgroundTaskInvalid + UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier.invalid) + self?.backgroundTaskID = UIBackgroundTaskIdentifier.invalid } } diff --git a/pass/Helpers/UtilsExtension.swift b/pass/Helpers/UtilsExtension.swift index 07e0da6..4112972 100644 --- a/pass/Helpers/UtilsExtension.swift +++ b/pass/Helpers/UtilsExtension.swift @@ -13,8 +13,8 @@ import passKit extension Utils { static func alert(title: String, message: String, controller: UIViewController, handler: ((UIAlertAction) -> Void)? = nil, completion: (() -> Void)? = nil) { SVProgressHUD.dismiss() - let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: handler)) + let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: handler)) controller.present(alert, animated: true, completion: completion) } } diff --git a/pass/UserInterface/AutoCellHeightUITableViewController.swift b/pass/UserInterface/AutoCellHeightUITableViewController.swift index eb09655..bf200f7 100644 --- a/pass/UserInterface/AutoCellHeightUITableViewController.swift +++ b/pass/UserInterface/AutoCellHeightUITableViewController.swift @@ -12,6 +12,6 @@ class AutoCellHeightUITableViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() tableView.estimatedRowHeight = 170 - tableView.rowHeight = UITableViewAutomaticDimension + tableView.rowHeight = UITableView.automaticDimension } } diff --git a/pass/Views/LabelTableViewCell.swift b/pass/Views/LabelTableViewCell.swift index 81d3985..033f0a5 100644 --- a/pass/Views/LabelTableViewCell.swift +++ b/pass/Views/LabelTableViewCell.swift @@ -166,8 +166,8 @@ class LabelTableViewCell: UITableViewCell { passwordDisplayButton!.frame = CGRect(x: 0, y: 0, width: width, height: height) passwordDisplayButton!.setImage(#imageLiteral(resourceName: "Visible"), for: .normal) passwordDisplayButton!.imageView?.contentMode = .scaleAspectFit - passwordDisplayButton!.contentEdgeInsets = UIEdgeInsetsMake(marginY, marginX, marginY, marginX) - passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControlEvents.touchUpInside) + passwordDisplayButton!.contentEdgeInsets = UIEdgeInsets.init(top: marginY, left: marginX, bottom: marginY, right: marginX) + passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControl.Event.touchUpInside) buttons = passwordDisplayButton } case .HOTP: @@ -176,8 +176,8 @@ class LabelTableViewCell: UITableViewCell { nextButton.frame = CGRect(x: 0, y: 0, width: width, height: height) nextButton.setImage(#imageLiteral(resourceName: "Refresh"), for: .normal) nextButton.imageView?.contentMode = .scaleAspectFit - nextButton.contentEdgeInsets = UIEdgeInsetsMake(marginY, marginX, marginY, marginX) - nextButton.addTarget(self, action: #selector(getNextHOTP), for: UIControlEvents.touchUpInside) + nextButton.contentEdgeInsets = UIEdgeInsets.init(top: marginY, left: marginX, bottom: marginY, right: marginX) + nextButton.addTarget(self, action: #selector(getNextHOTP), for: UIControl.Event.touchUpInside) // password button passwordDisplayButton = UIButton(type: .system) @@ -185,8 +185,8 @@ class LabelTableViewCell: UITableViewCell { passwordDisplayButton!.setImage(#imageLiteral(resourceName: "Visible"), for: .normal) passwordDisplayButton!.imageView?.contentMode = .scaleAspectFit - passwordDisplayButton!.contentEdgeInsets = UIEdgeInsetsMake(marginY, marginX, marginY, marginX) - passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControlEvents.touchUpInside) + passwordDisplayButton!.contentEdgeInsets = UIEdgeInsets.init(top: marginY, left: marginX, bottom: marginY, right: marginX) + passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControl.Event.touchUpInside) buttons = UIView() buttons!.frame = CGRect(x: 0, y: 0, width: width * 2, height: height) diff --git a/passExtension/Controllers/ExtensionViewController.swift b/passExtension/Controllers/ExtensionViewController.swift index 84a7a6c..27e4799 100644 --- a/passExtension/Controllers/ExtensionViewController.swift +++ b/passExtension/Controllers/ExtensionViewController.swift @@ -214,8 +214,8 @@ class ExtensionViewController: UIViewController, UITableViewDataSource, UITableV let sem = DispatchSemaphore(value: 0) var passphrase = "" DispatchQueue.main.async { - let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: {_ in + let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in passphrase = alert.textFields!.first!.text! sem.signal() })) diff --git a/passKit/Controllers/PasscodeLockPresenter.swift b/passKit/Controllers/PasscodeLockPresenter.swift index 236a3a6..8d9c356 100644 --- a/passKit/Controllers/PasscodeLockPresenter.swift +++ b/passKit/Controllers/PasscodeLockPresenter.swift @@ -47,8 +47,8 @@ open class PasscodeLockPresenter { } fileprivate func moveWindowsToFront(windowLevel: CGFloat?) { - let windowLevel = windowLevel ?? UIWindowLevelNormal - let maxWinLevel = max(windowLevel, UIWindowLevelNormal) - passcodeLockWindow?.windowLevel = maxWinLevel + 1 + let windowLevel = windowLevel ?? UIWindow.Level.normal.rawValue + let maxWinLevel = max(windowLevel, UIWindow.Level.normal.rawValue) + passcodeLockWindow?.windowLevel = UIWindow.Level(rawValue: maxWinLevel + 1) } } diff --git a/passKit/Controllers/PasscodeLockViewController.swift b/passKit/Controllers/PasscodeLockViewController.swift index 166e7fe..7372a2b 100644 --- a/passKit/Controllers/PasscodeLockViewController.swift +++ b/passKit/Controllers/PasscodeLockViewController.swift @@ -47,12 +47,12 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate { self.passcodeWrongAttemptsLabel = passcodeWrongAttemptsLabel let passcodeTextField = UITextField(frame: CGRect(x: 0, y: 0, width: 300, height: 40)) - passcodeTextField.borderStyle = UITextBorderStyle.roundedRect + passcodeTextField.borderStyle = UITextField.BorderStyle.roundedRect passcodeTextField.placeholder = "Passcode".localize() passcodeTextField.isSecureTextEntry = true - passcodeTextField.clearButtonMode = UITextFieldViewMode.whileEditing + passcodeTextField.clearButtonMode = UITextField.ViewMode.whileEditing passcodeTextField.delegate = self - passcodeTextField.addTarget(self, action: #selector(self.passcodeTextFieldDidChange(_:)), for: UIControlEvents.editingChanged) + passcodeTextField.addTarget(self, action: #selector(self.passcodeTextFieldDidChange(_:)), for: UIControl.Event.editingChanged) self.view.backgroundColor = UIColor.white passcodeTextField.translatesAutoresizingMaskIntoConstraints = false self.view.addSubview(passcodeTextField) @@ -88,7 +88,7 @@ open class PasscodeLockViewController: UIViewController, UITextFieldDelegate { cancelButton.addTarget(self, action: #selector(passcodeLockDidCancel), for: .touchUpInside) cancelButton.isHidden = !self.isCancellable cancelButton.translatesAutoresizingMaskIntoConstraints = false - cancelButton.contentHorizontalAlignment = UIControlContentHorizontalAlignment.left + cancelButton.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.left self.view.addSubview(cancelButton) self.cancelButton = cancelButton diff --git a/passKit/Helpers/Utils.swift b/passKit/Helpers/Utils.swift index f764d6e..3446b00 100644 --- a/passKit/Helpers/Utils.swift +++ b/passKit/Helpers/Utils.swift @@ -13,7 +13,7 @@ import KeychainAccess public class Utils { public static func getPasswordFromKeychain(name: String) -> String? { let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier) - return (try? keychain.getString(name)) ?? nil + return try? keychain.getString(name) } public static func addPasswordToKeychain(name: String, password: String?) { @@ -49,14 +49,14 @@ public class Utils { } else { charColor = Globals.letterColor } - attributedPassword.addAttribute(NSAttributedStringKey.foregroundColor, value: charColor, range: NSRange(location: index, length: 1)) + attributedPassword.addAttribute(NSAttributedString.Key.foregroundColor, value: charColor, range: NSRange(location: index, length: 1)) } return attributedPassword } public static func alert(title: String, message: String, controller: UIViewController, handler: ((UIAlertAction) -> Void)? = nil, completion: (() -> Void)? = nil) { - let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: handler)) + let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: handler)) controller.present(alert, animated: true, completion: completion) } } diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index ece2b98..164c2ac 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -109,7 +109,7 @@ public class PasswordStore { } public var numberOfLocalCommits: Int? { - return (try? getLocalCommits())?.flatMap { $0.count } + return (try? getLocalCommits())?.count } public var lastSyncedTime: Date? {