Hide unknown fields

This commit is contained in:
Bob Sun 2017-02-14 11:16:30 +08:00
parent 3145ddacbe
commit fe1c01c6dc
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
6 changed files with 40 additions and 9 deletions

View file

@ -299,7 +299,7 @@
TargetAttributes = {
DC917BD21E2E8231000FDF54 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 779BQYPRCF;
DevelopmentTeam = 4WDM8E95VU;
ProvisioningStyle = Automatic;
};
};
@ -571,7 +571,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = NO;
DEVELOPMENT_TEAM = 779BQYPRCF;
DEVELOPMENT_TEAM = 4WDM8E95VU;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
@ -600,7 +600,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = NO;
DEVELOPMENT_TEAM = 779BQYPRCF;
DEVELOPMENT_TEAM = 4WDM8E95VU;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",

View file

@ -7,15 +7,39 @@
//
import UIKit
import SwiftyUserDefaults
class GeneralSettingsTableViewController: BasicStaticTableViewController {
let hideUnknownSwitch = UISwitch(frame: CGRect.zero)
override func viewDidLoad() {
navigationItemTitle = "General"
tableData = [
// section 0
[[.title: "About Repository", .action: "segue", .link: "showAboutRepositorySegue"],],
[[.title: "Hide Unkonwn Fields", .action: "none",],],
]
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
if indexPath == IndexPath(row: 0, section: 1) {
cell.accessoryType = .none
hideUnknownSwitch.onTintColor = UIColor(displayP3Red: 0, green: 122.0/255, blue: 1, alpha: 1)
cell.accessoryView = hideUnknownSwitch
cell.selectionStyle = .none
hideUnknownSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControlEvents.valueChanged)
hideUnknownSwitch.isOn = Defaults[.isHideUnknownOn]
}
return cell
}
func hideUnknownSwitchAction(_ sender: Any?) {
Defaults[.isHideUnknownOn] = hideUnknownSwitch.isOn
}
}

View file

@ -8,6 +8,7 @@
import UIKit
import FavIcon
import SwiftyUserDefaults
class PasswordDetailTableViewController: UITableViewController, UIGestureRecognizerDelegate {
var passwordEntity: PasswordEntity?
@ -147,7 +148,10 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
self.tableData.append(TableSection(title: "additions", item: []))
tableDataIndex += 1
for additionKey in password.additionKeys {
self.tableData[tableDataIndex].item.append(TableCell(title: additionKey, content: password.additions[additionKey]!))
if !additionKey.contains("unknown") || !Defaults[.isHideUnknownOn] {
self.tableData[tableDataIndex].item.append(TableCell(title: additionKey, content: password.additions[additionKey]!))
}
}
}

View file

@ -29,4 +29,7 @@ extension DefaultsKeys {
static let isTouchIDOn = DefaultsKey<Bool>("isTouchIDOn")
static let passcodeKey = DefaultsKey<String?>("passcodeKey")
static let isHideUnknownOn = DefaultsKey<Bool>("isHideUnknownOn")
}

View file

@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Pass</string>
<string>Pass for iOS</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>

View file

@ -57,17 +57,17 @@ class Password {
static func getAdditionFields(from additionFieldsPlainText: String) -> [AdditionField]{
var additionFieldsArray = [AdditionField]()
var unkownIndex = 0
var unknownIndex = 0
additionFieldsPlainText.enumerateLines() { line, _ in
let items = line.characters.split(separator: ":", maxSplits: 1, omittingEmptySubsequences: true).map(String.init)
var key = ""
var value = ""
if items.count == 1 {
unkownIndex += 1
key = "unkown \(unkownIndex)"
unknownIndex += 1
key = "unknown \(unknownIndex)"
value = items[0]
} else {
} else if items.count == 2 {
key = items[0]
value = items[1].trimmingCharacters(in: .whitespaces)
}