Utilize default settings values
This commit is contained in:
parent
f9c19b3ca4
commit
c2cd6481fd
6 changed files with 13 additions and 15 deletions
|
|
@ -13,7 +13,6 @@
|
||||||
301F6463216162550071A4CE /* AdditionField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301F6462216162550071A4CE /* AdditionField.swift */; };
|
301F6463216162550071A4CE /* AdditionField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301F6462216162550071A4CE /* AdditionField.swift */; };
|
||||||
301F6468216165290071A4CE /* ConstantsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301F6467216165290071A4CE /* ConstantsTest.swift */; };
|
301F6468216165290071A4CE /* ConstantsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301F6467216165290071A4CE /* ConstantsTest.swift */; };
|
||||||
301F646D216166AA0071A4CE /* AdditionFieldTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301F646C216166AA0071A4CE /* AdditionFieldTest.swift */; };
|
301F646D216166AA0071A4CE /* AdditionFieldTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301F646C216166AA0071A4CE /* AdditionFieldTest.swift */; };
|
||||||
302202EF222F14E400555236 /* SearchBarScope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302202EE222F14E400555236 /* SearchBarScope.swift */; };
|
|
||||||
302E85612125ECC70031BA64 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302E85602125ECC70031BA64 /* Parser.swift */; };
|
302E85612125ECC70031BA64 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302E85602125ECC70031BA64 /* Parser.swift */; };
|
||||||
302E85632125EE550031BA64 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302E85622125EE550031BA64 /* Constants.swift */; };
|
302E85632125EE550031BA64 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302E85622125EE550031BA64 /* Constants.swift */; };
|
||||||
30697C2A21F63C5A0064FCAC /* NotificationNames.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C2321F63C580064FCAC /* NotificationNames.swift */; };
|
30697C2A21F63C5A0064FCAC /* NotificationNames.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C2321F63C580064FCAC /* NotificationNames.swift */; };
|
||||||
|
|
@ -42,6 +41,7 @@
|
||||||
30697C5421F63E0B0064FCAC /* CredentialProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C5221F63E0B0064FCAC /* CredentialProviderViewController.swift */; };
|
30697C5421F63E0B0064FCAC /* CredentialProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C5221F63E0B0064FCAC /* CredentialProviderViewController.swift */; };
|
||||||
30697C5F21F674800064FCAC /* String+UtilitiesTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C5E21F674800064FCAC /* String+UtilitiesTest.swift */; };
|
30697C5F21F674800064FCAC /* String+UtilitiesTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30697C5E21F674800064FCAC /* String+UtilitiesTest.swift */; };
|
||||||
307BF39921BC2298003A082D /* TestBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307BF39821BC2297003A082D /* TestBase.swift */; };
|
307BF39921BC2298003A082D /* TestBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307BF39821BC2297003A082D /* TestBase.swift */; };
|
||||||
|
308C273A2279F9CB0016D0E2 /* SearchBarScope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302202EE222F14E400555236 /* SearchBarScope.swift */; };
|
||||||
30A1D29C21AF451E00E2D1F7 /* PasswordGeneratorFlavourTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D29B21AF451E00E2D1F7 /* PasswordGeneratorFlavourTest.swift */; };
|
30A1D29C21AF451E00E2D1F7 /* PasswordGeneratorFlavourTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D29B21AF451E00E2D1F7 /* PasswordGeneratorFlavourTest.swift */; };
|
||||||
30A1D2A221B2BC6F00E2D1F7 /* TokenBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D2A121B2BC6F00E2D1F7 /* TokenBuilder.swift */; };
|
30A1D2A221B2BC6F00E2D1F7 /* TokenBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D2A121B2BC6F00E2D1F7 /* TokenBuilder.swift */; };
|
||||||
30A1D2A621B2D46100E2D1F7 /* OtpType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D2A521B2D46100E2D1F7 /* OtpType.swift */; };
|
30A1D2A621B2D46100E2D1F7 /* OtpType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A1D2A521B2D46100E2D1F7 /* OtpType.swift */; };
|
||||||
|
|
@ -602,6 +602,7 @@
|
||||||
30697C2421F63C590064FCAC /* Globals.swift */,
|
30697C2421F63C590064FCAC /* Globals.swift */,
|
||||||
30697C2321F63C580064FCAC /* NotificationNames.swift */,
|
30697C2321F63C580064FCAC /* NotificationNames.swift */,
|
||||||
30697C2621F63C590064FCAC /* PasswordGeneratorFlavour.swift */,
|
30697C2621F63C590064FCAC /* PasswordGeneratorFlavour.swift */,
|
||||||
|
302202EE222F14E400555236 /* SearchBarScope.swift */,
|
||||||
30697C2721F63C590064FCAC /* Utils.swift */,
|
30697C2721F63C590064FCAC /* Utils.swift */,
|
||||||
);
|
);
|
||||||
path = Helpers;
|
path = Helpers;
|
||||||
|
|
@ -665,7 +666,6 @@
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
A2BC54C71EEE5669001FAFBD /* Objective-CBridgingHeader.h */,
|
A2BC54C71EEE5669001FAFBD /* Objective-CBridgingHeader.h */,
|
||||||
302202EE222F14E400555236 /* SearchBarScope.swift */,
|
|
||||||
A20691F31F2A3D0E0096483D /* SecurePasteboard.swift */,
|
A20691F31F2A3D0E0096483D /* SecurePasteboard.swift */,
|
||||||
A2A61C1F1EEFABAD00CFE063 /* UtilsExtension.swift */,
|
A2A61C1F1EEFABAD00CFE063 /* UtilsExtension.swift */,
|
||||||
);
|
);
|
||||||
|
|
@ -1233,6 +1233,7 @@
|
||||||
30697C4821F63CAB0064FCAC /* PasswordStore.swift in Sources */,
|
30697C4821F63CAB0064FCAC /* PasswordStore.swift in Sources */,
|
||||||
A26075AD1EEC7125005DB03E /* pass.xcdatamodeld in Sources */,
|
A26075AD1EEC7125005DB03E /* pass.xcdatamodeld in Sources */,
|
||||||
30697C2D21F63C5A0064FCAC /* PasswordGeneratorFlavour.swift in Sources */,
|
30697C2D21F63C5A0064FCAC /* PasswordGeneratorFlavour.swift in Sources */,
|
||||||
|
308C273A2279F9CB0016D0E2 /* SearchBarScope.swift in Sources */,
|
||||||
30697C2F21F63C5A0064FCAC /* DefaultsKeys.swift in Sources */,
|
30697C2F21F63C5A0064FCAC /* DefaultsKeys.swift in Sources */,
|
||||||
30A1D2A821B2D53200E2D1F7 /* PasswordChange.swift in Sources */,
|
30A1D2A821B2D53200E2D1F7 /* PasswordChange.swift in Sources */,
|
||||||
30697C3E21F63C990064FCAC /* String+Utilities.swift in Sources */,
|
30697C3E21F63C990064FCAC /* String+Utilities.swift in Sources */,
|
||||||
|
|
@ -1300,7 +1301,6 @@
|
||||||
DCFB77AB1E503729008DE471 /* ContentTableViewCell.swift in Sources */,
|
DCFB77AB1E503729008DE471 /* ContentTableViewCell.swift in Sources */,
|
||||||
DCA0499C1E3362F400522E8F /* PGPKeySettingTableViewController.swift in Sources */,
|
DCA0499C1E3362F400522E8F /* PGPKeySettingTableViewController.swift in Sources */,
|
||||||
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */,
|
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */,
|
||||||
302202EF222F14E400555236 /* SearchBarScope.swift in Sources */,
|
|
||||||
DC5F385B1E56AADB00C69ACA /* PGPKeyArmorSettingTableViewController.swift in Sources */,
|
DC5F385B1E56AADB00C69ACA /* PGPKeyArmorSettingTableViewController.swift in Sources */,
|
||||||
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */,
|
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */,
|
||||||
DCFB77A71E502DF9008DE471 /* EditPasswordTableViewController.swift in Sources */,
|
DCFB77A71E502DF9008DE471 /* EditPasswordTableViewController.swift in Sources */,
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
self.perform(#selector(postSearchNotification), with: nil, afterDelay: 0.4)
|
self.perform(#selector(postSearchNotification), with: nil, afterDelay: 0.4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign default values to global settings.
|
|
||||||
SharedDefaults.register(defaults: [DefaultsKeys.gitBranchName._key: "master"])
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -585,14 +585,14 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
|
|
||||||
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
|
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
|
||||||
// update the default search scope
|
// update the default search scope
|
||||||
SharedDefaults[.isSearchDefaultAll] = SearchBarScope(rawValue: selectedScope) == .all
|
SharedDefaults[.searchDefault] = SearchBarScope(rawValue: selectedScope) ?? .all
|
||||||
updateSearchResults(for: searchController)
|
updateSearchResults(for: searchController)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
|
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
|
||||||
// set the default search scope to "all"
|
// set the default search scope to "all"
|
||||||
if SharedDefaults[.isShowFolderOn] && SharedDefaults[.isSearchDefaultAll] {
|
if SharedDefaults[.isShowFolderOn] && SharedDefaults[.searchDefault] == .all {
|
||||||
searchController.searchBar.selectedScopeButtonIndex = SearchBarScope.all.rawValue
|
searchController.searchBar.selectedScopeButtonIndex = SearchBarScope.all.rawValue
|
||||||
} else {
|
} else {
|
||||||
searchController.searchBar.selectedScopeButtonIndex = SearchBarScope.current.rawValue
|
searchController.searchBar.selectedScopeButtonIndex = SearchBarScope.current.rawValue
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public extension DefaultsKeys {
|
||||||
static let gitURL = DefaultsKey<URL?>("gitURL")
|
static let gitURL = DefaultsKey<URL?>("gitURL")
|
||||||
static let gitAuthenticationMethod = DefaultsKey<String?>("gitAuthenticationMethod")
|
static let gitAuthenticationMethod = DefaultsKey<String?>("gitAuthenticationMethod")
|
||||||
static let gitUsername = DefaultsKey<String?>("gitUsername")
|
static let gitUsername = DefaultsKey<String?>("gitUsername")
|
||||||
static let gitBranchName = DefaultsKey<String?>("gitBranchName")
|
static let gitBranchName = DefaultsKey<String>("gitBranchName", defaultValue: "master")
|
||||||
static let gitSSHPrivateKeyURL = DefaultsKey<URL?>("gitSSHPrivateKeyURL")
|
static let gitSSHPrivateKeyURL = DefaultsKey<URL?>("gitSSHPrivateKeyURL")
|
||||||
static let gitSSHKeySource = DefaultsKey<String?>("gitSSHKeySource")
|
static let gitSSHKeySource = DefaultsKey<String?>("gitSSHKeySource")
|
||||||
static let gitSSHPrivateKeyArmor = DefaultsKey<String?>("gitSSHPrivateKeyArmor")
|
static let gitSSHPrivateKeyArmor = DefaultsKey<String?>("gitSSHPrivateKeyArmor")
|
||||||
|
|
@ -40,7 +40,7 @@ public extension DefaultsKeys {
|
||||||
static let isRememberGitCredentialPassphraseOn = DefaultsKey<Bool>("isRememberGitCredentialPassphraseOn", defaultValue: false)
|
static let isRememberGitCredentialPassphraseOn = DefaultsKey<Bool>("isRememberGitCredentialPassphraseOn", defaultValue: false)
|
||||||
static let isShowFolderOn = DefaultsKey<Bool>("isShowFolderOn", defaultValue: true)
|
static let isShowFolderOn = DefaultsKey<Bool>("isShowFolderOn", defaultValue: true)
|
||||||
static let isHidePasswordImagesOn = DefaultsKey<Bool>("isHidePasswordImagesOn", defaultValue: false)
|
static let isHidePasswordImagesOn = DefaultsKey<Bool>("isHidePasswordImagesOn", defaultValue: false)
|
||||||
static let isSearchDefaultAll = DefaultsKey<Bool>("isSearchDefaultAll", defaultValue: true)
|
static let searchDefault = DefaultsKey<SearchBarScope>("searchDefault", defaultValue: .all)
|
||||||
static let passwordGeneratorFlavor = DefaultsKey<String>("passwordGeneratorFlavor", defaultValue: "Apple")
|
static let passwordGeneratorFlavor = DefaultsKey<String>("passwordGeneratorFlavor", defaultValue: "Apple")
|
||||||
|
|
||||||
static let encryptInArmored = DefaultsKey<Bool>("encryptInArmored", defaultValue: false)
|
static let encryptInArmored = DefaultsKey<Bool>("encryptInArmored", defaultValue: false)
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@
|
||||||
// Copyright © 2019 Bob Sun. All rights reserved.
|
// Copyright © 2019 Bob Sun. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
enum SearchBarScope: Int, CaseIterable {
|
import SwiftyUserDefaults
|
||||||
|
|
||||||
|
public enum SearchBarScope: Int, CaseIterable, DefaultsSerializable {
|
||||||
case current
|
case current
|
||||||
case all
|
case all
|
||||||
|
|
||||||
var localizedName: String {
|
public var localizedName: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .current:
|
case .current:
|
||||||
return "Current".localize()
|
return "Current".localize()
|
||||||
|
|
@ -582,7 +582,7 @@ public class PasswordStore {
|
||||||
do {
|
do {
|
||||||
let credentialProvider = try credential.credentialProvider(requestGitPassword: requestGitPassword)
|
let credentialProvider = try credential.credentialProvider(requestGitPassword: requestGitPassword)
|
||||||
let options = [GTRepositoryRemoteOptionsCredentialProvider: credentialProvider]
|
let options = [GTRepositoryRemoteOptionsCredentialProvider: credentialProvider]
|
||||||
if let branch = try getLocalBranch(withName: SharedDefaults[.gitBranchName]!) {
|
if let branch = try getLocalBranch(withName: SharedDefaults[.gitBranchName]) {
|
||||||
let remote = try GTRemote(name: "origin", in: storeRepository)
|
let remote = try GTRemote(name: "origin", in: storeRepository)
|
||||||
try storeRepository.push(branch, to: remote, withOptions: options, progress: transferProgressBlock)
|
try storeRepository.push(branch, to: remote, withOptions: options, progress: transferProgressBlock)
|
||||||
}
|
}
|
||||||
|
|
@ -805,7 +805,7 @@ public class PasswordStore {
|
||||||
throw AppError.RepositoryNotSet
|
throw AppError.RepositoryNotSet
|
||||||
}
|
}
|
||||||
// get the remote branch
|
// get the remote branch
|
||||||
let remoteBranchName = SharedDefaults[.gitBranchName]!
|
let remoteBranchName = SharedDefaults[.gitBranchName]
|
||||||
guard let remoteBranch = try storeRepository.remoteBranches().first(where: { $0.shortName == remoteBranchName }) else {
|
guard let remoteBranch = try storeRepository.remoteBranches().first(where: { $0.shortName == remoteBranchName }) else {
|
||||||
throw AppError.RepositoryRemoteBranchNotFound(remoteBranchName)
|
throw AppError.RepositoryRemoteBranchNotFound(remoteBranchName)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue