From a209933c204e54ca822987dbaeaff07e92aa9355 Mon Sep 17 00:00:00 2001 From: Petteri Valkonen Date: Thu, 9 Mar 2017 22:22:41 +0200 Subject: [PATCH 01/16] Fix typo --- pass/Controllers/GeneralSettingsTableViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pass/Controllers/GeneralSettingsTableViewController.swift b/pass/Controllers/GeneralSettingsTableViewController.swift index b341d7b..c94f3a0 100644 --- a/pass/Controllers/GeneralSettingsTableViewController.swift +++ b/pass/Controllers/GeneralSettingsTableViewController.swift @@ -154,7 +154,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController { } func tapHideUnknownSwitchDetailButton(_ sender: Any?) { - let alertMessage = "Only \"key: value\" format in additional fields is supported. Unsupported fields will be given \"unkown\" keys. Turn on this switch to hide unsupported fields." + let alertMessage = "Only \"key: value\" format in additional fields is supported. Unsupported fields will be given \"unknown\" keys. Turn on this switch to hide unsupported fields." let alertTitle = "Hide Unknown Fields" Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil) } From 453e6d251a77c6fb69d08b004d151d3e9e52c2b0 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Fri, 10 Mar 2017 23:04:33 +0800 Subject: [PATCH 02/16] Fix the overlap between a long password and the "Generate" button --- pass/Views/FillPasswordTableViewCell.xib | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pass/Views/FillPasswordTableViewCell.xib b/pass/Views/FillPasswordTableViewCell.xib index 2955f45..0f6d8b2 100644 --- a/pass/Views/FillPasswordTableViewCell.xib +++ b/pass/Views/FillPasswordTableViewCell.xib @@ -19,8 +19,8 @@ - - + + @@ -29,7 +29,10 @@ - + - + - + From 11066d0bb6ca75a93b31429903723824238aa564 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Sat, 11 Mar 2017 00:48:15 +0800 Subject: [PATCH 03/16] Automatically update the "about repository" page when the repository gets updated --- .../AboutRepositoryTableViewController.swift | 63 ++++++++++++++----- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/pass/Controllers/AboutRepositoryTableViewController.swift b/pass/Controllers/AboutRepositoryTableViewController.swift index 6a4d7d0..c8a1a1f 100644 --- a/pass/Controllers/AboutRepositoryTableViewController.swift +++ b/pass/Controllers/AboutRepositoryTableViewController.swift @@ -9,23 +9,48 @@ import UIKit class AboutRepositoryTableViewController: BasicStaticTableViewController { + + var needRefresh = false + var indicatorLabel: UILabel! + var indicator: UIActivityIndicatorView! override func viewDidLoad() { navigationItemTitle = "About Repository" super.viewDidLoad() - let indicatorLable = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 21)) - indicatorLable.center = CGPoint(x: view.frame.size.width / 2, y: view.frame.size.height * 0.382 + 22) - indicatorLable.backgroundColor = UIColor.clear - indicatorLable.textColor = UIColor.gray - indicatorLable.text = "calculating" - indicatorLable.textAlignment = .center - indicatorLable.font = UIFont.preferredFont(forTextStyle: .footnote) - let indicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) + + indicatorLabel = UILabel(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 21)) + indicatorLabel.center = CGPoint(x: view.frame.size.width / 2, y: view.frame.size.height * 0.382 + 22) + indicatorLabel.backgroundColor = UIColor.clear + indicatorLabel.textColor = UIColor.gray + indicatorLabel.text = "calculating" + indicatorLabel.textAlignment = .center + indicatorLabel.font = UIFont.preferredFont(forTextStyle: .footnote) + indicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) indicator.center = CGPoint(x: view.frame.size.width / 2, y: view.frame.size.height * 0.382) - indicator.startAnimating() tableView.addSubview(indicator) - tableView.addSubview(indicatorLable) + tableView.addSubview(indicatorLabel) + setTableData() + addNotificationObservers() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + if needRefresh { + indicatorLabel.text = "reloading" + setTableData() + } + } + + private func setTableData() { + + // clear current contents (if any) + self.tableData.removeAll(keepingCapacity: true) + self.tableView.reloadData() + indicatorLabel.isHidden = false + indicator.startAnimating() + + // reload the table DispatchQueue.global(qos: .userInitiated).async { let numberFormatter = NumberFormatter() numberFormatter.numberStyle = NumberFormatter.Style.decimal @@ -46,8 +71,8 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController { let numberOfCommits = PasswordStore.shared.storeRepository?.numberOfCommits(inCurrentBranch: NSErrorPointer(nilLiteral: ())) ?? 0 let numberOfCommitsString = numberFormatter.string(from: NSNumber(value: numberOfCommits))! - - + + DispatchQueue.main.async { [weak self] in let type = UITableViewCellAccessoryType.none self?.tableData = [ @@ -59,11 +84,19 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController { [.title: "Commit Logs", .action: "segue", .link: "showCommitLogsSegue"], ], ] - indicator.stopAnimating() - indicatorLable.isHidden = true + self?.indicator.stopAnimating() + self?.indicatorLabel.isHidden = true self?.tableView.reloadData() } } } - + + private func addNotificationObservers() { + NotificationCenter.default.addObserver(self, selector: #selector(setNeedRefresh), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(setNeedRefresh), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil) + } + + func setNeedRefresh() { + needRefresh = true + } } From 5ea9a3118b6401812d2bbd8ef5a4c35e475bb264 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Sat, 11 Mar 2017 02:07:04 +0800 Subject: [PATCH 04/16] Go back to the "password store" view if user discards all local changes. - Otherwise, editing an updated entry will crash the app. - Showing an deleted entry is not reasonable. --- .../PasswordDetailTableViewController.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pass/Controllers/PasswordDetailTableViewController.swift b/pass/Controllers/PasswordDetailTableViewController.swift index 05a6f4f..6dd2586 100644 --- a/pass/Controllers/PasswordDetailTableViewController.swift +++ b/pass/Controllers/PasswordDetailTableViewController.swift @@ -17,6 +17,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni var password: Password? var passwordImage: UIImage? var oneTimePasswordIndexPath : IndexPath? + var shouldPopCurrentView = false let indicatorLable: UILabel = { let label = UILabel(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 21)) @@ -118,6 +119,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni } self.setupUpdateOneTimePassword() + self.addNotificationObservers() } @@ -386,4 +388,22 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni return true } + private func addNotificationObservers() { + NotificationCenter.default.addObserver(self, selector: #selector(setShouldPopCurrentView), name: NSNotification.Name(rawValue: "passwordStoreChangeDiscarded"), object: nil) + } + + func setShouldPopCurrentView() { + self.shouldPopCurrentView = true + } + + override func viewDidAppear(_ animated: Bool) { + super.viewWillAppear(animated) + if self.shouldPopCurrentView { + let alert = UIAlertController(title: "Notice", message: "All previous local changes have been discarded. Your current Password Store will be shown.", preferredStyle: UIAlertControllerStyle.alert) + alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {_ in + _ = self.navigationController?.popViewController(animated: true) + })) + self.present(alert, animated: true, completion: nil) + } + } } From 9d653acc0d5fda17cec2d8d42f6608092b0f16c1 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Sat, 11 Mar 2017 02:14:53 +0800 Subject: [PATCH 05/16] Polish the "discard all local changes" feature --- pass/Controllers/AdvancedSettingsTableViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pass/Controllers/AdvancedSettingsTableViewController.swift b/pass/Controllers/AdvancedSettingsTableViewController.swift index 0454c60..2ef6023 100644 --- a/pass/Controllers/AdvancedSettingsTableViewController.swift +++ b/pass/Controllers/AdvancedSettingsTableViewController.swift @@ -35,13 +35,15 @@ class AdvancedSettingsTableViewController: UITableViewController { tableView.deselectRow(at: indexPath, animated: true) } else if tableView.cellForRow(at: indexPath) == discardChangesTableViewCell { let alert = UIAlertController(title: "Discard All Changes?", message: "Do you want to permanently discard all changes to the local copy of your password data? You cannot undo this action.", preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Discard All Changesa", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in + alert.addAction(UIAlertAction(title: "Discard All Changes", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in DispatchQueue.global(qos: .userInitiated).async { SVProgressHUD.show(withStatus: "Resetting ...") DispatchQueue.main.async { do { let numberDiscarded = try PasswordStore.shared.reset() - NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded"))) + if numberDiscarded > 0 { + NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded"))) + } self.navigationController!.popViewController(animated: true) SVProgressHUD.showSuccess(withStatus: "Discarded \(numberDiscarded) commits") SVProgressHUD.dismiss(withDelay: 1) From db4413d6ba12930e0fd4a01de3f77284b517a9cc Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Sat, 11 Mar 2017 02:14:53 +0800 Subject: [PATCH 06/16] Polish the "discard all local changes" feature --- .../AdvancedSettingsTableViewController.swift | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pass/Controllers/AdvancedSettingsTableViewController.swift b/pass/Controllers/AdvancedSettingsTableViewController.swift index 0454c60..b73305b 100644 --- a/pass/Controllers/AdvancedSettingsTableViewController.swift +++ b/pass/Controllers/AdvancedSettingsTableViewController.swift @@ -35,15 +35,24 @@ class AdvancedSettingsTableViewController: UITableViewController { tableView.deselectRow(at: indexPath, animated: true) } else if tableView.cellForRow(at: indexPath) == discardChangesTableViewCell { let alert = UIAlertController(title: "Discard All Changes?", message: "Do you want to permanently discard all changes to the local copy of your password data? You cannot undo this action.", preferredStyle: UIAlertControllerStyle.alert) - alert.addAction(UIAlertAction(title: "Discard All Changesa", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in + alert.addAction(UIAlertAction(title: "Discard All Changes", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in DispatchQueue.global(qos: .userInitiated).async { SVProgressHUD.show(withStatus: "Resetting ...") DispatchQueue.main.async { do { let numberDiscarded = try PasswordStore.shared.reset() - NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded"))) + if numberDiscarded > 0 { + NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded"))) + } self.navigationController!.popViewController(animated: true) - SVProgressHUD.showSuccess(withStatus: "Discarded \(numberDiscarded) commits") + switch numberDiscarded { + case 0: + SVProgressHUD.showSuccess(withStatus: "No local commits") + case 1: + SVProgressHUD.showSuccess(withStatus: "Discarded 1 commit") + default: + SVProgressHUD.showSuccess(withStatus: "Discarded \(numberDiscarded) commits") + } SVProgressHUD.dismiss(withDelay: 1) } catch { DispatchQueue.main.async { From d1476c1d4013492746ac6112aca9ccbd4ccf51a4 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Sat, 11 Mar 2017 02:21:01 +0800 Subject: [PATCH 07/16] Improve the about repository page refresh --- pass/Controllers/AboutRepositoryTableViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/pass/Controllers/AboutRepositoryTableViewController.swift b/pass/Controllers/AboutRepositoryTableViewController.swift index c8a1a1f..36588ee 100644 --- a/pass/Controllers/AboutRepositoryTableViewController.swift +++ b/pass/Controllers/AboutRepositoryTableViewController.swift @@ -39,6 +39,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController { if needRefresh { indicatorLabel.text = "reloading" setTableData() + needRefresh = false } } From d82396a3225a1167410a8a6862fb6735228a4d37 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Wed, 8 Mar 2017 21:52:07 -0800 Subject: [PATCH 08/16] Separate two advanced settings --- pass/Base.lproj/Main.storyboard | 64 +++++++++++++++++---------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard index 05ccc23..0a1cd55 100644 --- a/pass/Base.lproj/Main.storyboard +++ b/pass/Base.lproj/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -292,7 +292,7 @@