From e155cbedb3e0cfbd98e19aef19a825e0df20da95 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Mon, 3 Apr 2017 22:40:17 +0800 Subject: [PATCH 01/32] Update the logic to generate password sections Using localized indexed collation, instead of the first character. --- .../Controllers/PasswordsViewController.swift | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index defb6ec..6fa6f23 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -11,14 +11,15 @@ import SVProgressHUD import SwiftyUserDefaults import PasscodeLock -enum PasswordsTableEntryType { - case password, dir -} - -struct PasswordsTableEntry { +fileprivate class PasswordsTableEntry : NSObject { var title: String var isDir: Bool var passwordEntity: PasswordEntity? + init(title: String, isDir: Bool, passwordEntity: PasswordEntity?) { + self.title = title + self.isDir = isDir + self.passwordEntity = passwordEntity + } } class PasswordsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UITabBarControllerDelegate { @@ -29,7 +30,8 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV private var tapTabBarTime: TimeInterval = 0 - private var sections : [(index: Int, length :Int, title: String)] = Array() + private var sections = [(title: String, entries: [PasswordsTableEntry])]() + private var searchActive : Bool = false private lazy var searchController: UISearchController = { @@ -196,7 +198,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return sections[section].length + return sections[section].entries.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { @@ -241,14 +243,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } private func getPasswordEntry(by indexPath: IndexPath) -> PasswordsTableEntry { - var entry: PasswordsTableEntry - let index = sections[indexPath.section].index + indexPath.row - if searchController.isActive && searchController.searchBar.text != "" { - entry = filteredPasswordsTableEntries[index] - } else { - entry = passwordsTableEntries[index] - } - return entry + return sections[indexPath.section].entries[indexPath.row] } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { @@ -345,25 +340,30 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } private func generateSections(item: [PasswordsTableEntry]) { - sections.removeAll() - guard item.count != 0 else { - return + let collation = UILocalizedIndexedCollation.current() + let sectionTitles = collation.sectionIndexTitles + var newSections = [(title: String, entries: [PasswordsTableEntry])]() + + // initialize all sections + for i in 0.. 0} } func actOnSearchNotification() { From 855e3c34d98a93f01ddfd6648e692122ed5ae2ec Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Tue, 4 Apr 2017 00:03:21 +0800 Subject: [PATCH 02/32] Clear the copied ascii-armor keys 10s after pasting. --- pass/Base.lproj/Main.storyboard | 210 ++++-------------- ...SHKeyArmorSettingTableViewController.swift | 20 +- ...GPKeyArmorSettingTableViewController.swift | 22 +- 3 files changed, 85 insertions(+), 167 deletions(-) diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard index f91974e..912d073 100644 --- a/pass/Base.lproj/Main.storyboard +++ b/pass/Base.lproj/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -89,11 +89,11 @@ - +