Some cleanup especially regarding method references (#516)

* Remove superfluous method arguments in method references

* Use 'Self' for internal static access

* Convert static to instance field in singleton class

* Remove class name prefix in references to local methods

* Remove nested frameworks in all extensions and frameworks
This commit is contained in:
Danny Mösch 2021-10-03 05:46:07 +02:00 committed by GitHub
parent e1cbcb5d7a
commit 32b7c9b635
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 57 additions and 57 deletions

View file

@ -100,7 +100,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
if let numberOfCommits = passwordStore.numberOfCommits {
return String(numberOfCommits)
}
return AboutRepositoryTableViewController.VALUE_NOT_AVAILABLE
return Self.VALUE_NOT_AVAILABLE
}
@objc

View file

@ -21,7 +21,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(encryptInASCIIArmoredAction(_:)), for: UIControl.Event.valueChanged)
uiSwitch.addTarget(self, action: #selector(encryptInASCIIArmoredAction), for: UIControl.Event.valueChanged)
return uiSwitch
}()

View file

@ -16,7 +16,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControl.Event.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 = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(hideOTPSwitchAction(_:)), for: UIControl.Event.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 = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(autoCopyOTPSwitchAction(_:)), for: UIControl.Event.valueChanged)
uiSwitch.addTarget(self, action: #selector(autoCopyOTPSwitchAction), for: UIControl.Event.valueChanged)
return uiSwitch
}()
@ -40,7 +40,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged)
uiSwitch.addTarget(self, action: #selector(rememberPGPPassphraseSwitchAction), for: UIControl.Event.valueChanged)
uiSwitch.isOn = Defaults.isRememberPGPPassphraseOn
return uiSwitch
}()
@ -49,7 +49,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction(_:)), for: UIControl.Event.valueChanged)
uiSwitch.addTarget(self, action: #selector(rememberGitCredentialPassphraseSwitchAction), for: UIControl.Event.valueChanged)
uiSwitch.isOn = Defaults.isRememberGitCredentialPassphraseOn
return uiSwitch
}()
@ -58,7 +58,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(enableGPGIDSwitchAction(_:)), for: UIControl.Event.valueChanged)
uiSwitch.addTarget(self, action: #selector(enableGPGIDSwitchAction), for: UIControl.Event.valueChanged)
uiSwitch.isOn = Defaults.isEnableGPGIDOn
return uiSwitch
}()
@ -67,7 +67,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction(_:)), for: UIControl.Event.valueChanged)
uiSwitch.addTarget(self, action: #selector(showFolderSwitchAction), for: UIControl.Event.valueChanged)
uiSwitch.isOn = Defaults.isShowFolderOn
return uiSwitch
}()
@ -76,7 +76,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Colors.systemBlue
uiSwitch.sizeToFit()
uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction(_:)), for: UIControl.Event.valueChanged)
uiSwitch.addTarget(self, action: #selector(hidePasswordImagesSwitchAction), for: UIControl.Event.valueChanged)
uiSwitch.isOn = Defaults.isHidePasswordImagesOn
return uiSwitch
}()

View file

@ -68,7 +68,7 @@ class OpenSourceComponentsTableViewController: BasicStaticTableViewController {
.action: "link",
.link: item[1],
.accessoryType: UITableViewCell.AccessoryType.detailDisclosureButton,
.detailDisclosureAction: #selector(actOnDetailDisclosureButton(_:)),
.detailDisclosureAction: #selector(actOnDetailDisclosureButton),
.detailDisclosureData: item[2],
]
)

View file

@ -21,7 +21,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
private let keychain = AppKeychain.shared
private lazy var editUIBarButtonItem: UIBarButtonItem = {
let uiBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit(_:)))
let uiBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit))
return uiBarButtonItem
}()
@ -47,7 +47,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
tableView.register(UINib(nibName: "LabelTableViewCell", bundle: nil), forCellReuseIdentifier: "labelCell")
tableView.register(UINib(nibName: "PasswordDetailTitleTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordDetailTitleTableViewCell")
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PasswordDetailTableViewController.tapMenu(recognizer:)))
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapMenu))
tapGesture.cancelsTouchesInView = false
tableView.addGestureRecognizer(tapGesture)
tapGesture.delegate = self
@ -326,10 +326,10 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
if let tappedCell = tableView.cellForRow(at: tapIndexPath) as? LabelTableViewCell {
tappedCell.becomeFirstResponder()
let menuController = UIMenuController.shared
let revealItem = UIMenuItem(title: "Reveal".localize(), action: #selector(LabelTableViewCell.revealPassword(_:)))
let concealItem = UIMenuItem(title: "Conceal".localize(), action: #selector(LabelTableViewCell.concealPassword(_:)))
let nextHOTPItem = UIMenuItem(title: "NextPassword".localize(), action: #selector(LabelTableViewCell.getNextHOTP(_:)))
let openURLItem = UIMenuItem(title: "CopyAndOpen".localize(), action: #selector(LabelTableViewCell.openLink(_:)))
let revealItem = UIMenuItem(title: "Reveal".localize(), action: #selector(LabelTableViewCell.revealPassword))
let concealItem = UIMenuItem(title: "Conceal".localize(), action: #selector(LabelTableViewCell.concealPassword))
let nextHOTPItem = UIMenuItem(title: "NextPassword".localize(), action: #selector(LabelTableViewCell.getNextHOTP))
let openURLItem = UIMenuItem(title: "CopyAndOpen".localize(), action: #selector(LabelTableViewCell.openLink))
menuController.menuItems = [revealItem, concealItem, nextHOTPItem, openURLItem]
menuController.setTargetRect(tappedCell.contentLabel.frame, in: tappedCell.contentLabel.superview!)
menuController.setMenuVisible(true, animated: true)
@ -490,7 +490,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
let section = tableData[indexPath.section]
switch section.type {
case .addition, .main:
return action == #selector(UIResponderStandardEditActions.copy(_:))
return action == #selector(UIResponderStandardEditActions.copy)
default:
return false
}

View file

@ -56,10 +56,10 @@ class PasswordNavigationViewController: UIViewController {
let addPasswordButton = UIButton(type: .system)
let plusImage = UIImage(systemName: "plus.circle", withConfiguration: UIImage.SymbolConfiguration(weight: .regular))
addPasswordButton.setImage(plusImage, for: .normal)
addPasswordButton.addTarget(self, action: #selector(self.addPasswordAction(_:)), for: .touchDown)
addPasswordButton.addTarget(self, action: #selector(self.addPasswordAction), for: .touchDown)
addPasswordUIBarButtonItem.customView = addPasswordButton
} else {
addPasswordUIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(self.addPasswordAction(_:)))
addPasswordUIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(self.addPasswordAction))
}
return addPasswordUIBarButtonItem
}()

View file

@ -66,7 +66,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(SettingsTableViewController.actOnPasswordStoreErasedNotification), name: .passwordStoreErased, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(actOnPasswordStoreErasedNotification), name: .passwordStoreErased, object: nil)
passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults.gitURL.host
setPGPKeyTableViewCellDetailText()
setPasscodeLockCell()
@ -243,12 +243,12 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
setPasscodeLockAlert?.addTextField { textField -> Void in
textField.placeholder = "Passcode".localize()
textField.isSecureTextEntry = true
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControl.Event.editingChanged)
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange), for: UIControl.Event.editingChanged)
}
setPasscodeLockAlert?.addTextField { textField -> Void in
textField.placeholder = "PasswordConfirmation".localize()
textField.isSecureTextEntry = true
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: UIControl.Event.editingChanged)
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange), for: UIControl.Event.editingChanged)
}
// save action

View file

@ -80,16 +80,16 @@ class LabelTableViewCell: UITableViewCell {
switch type {
case .password:
if isReveal {
return action == #selector(copy(_:)) || action == #selector(concealPassword(_:))
return action == #selector(copy(_:)) || action == #selector(concealPassword)
}
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:))
return action == #selector(copy(_:)) || action == #selector(revealPassword)
case .URL:
return action == #selector(copy(_:)) || action == #selector(openLink(_:))
return action == #selector(copy(_:)) || action == #selector(openLink)
case .HOTP:
if isReveal {
return action == #selector(copy(_:)) || action == #selector(concealPassword(_:)) || action == #selector(getNextHOTP(_:))
return action == #selector(copy(_:)) || action == #selector(concealPassword) || action == #selector(getNextHOTP)
}
return action == #selector(copy(_:)) || action == #selector(revealPassword(_:)) || action == #selector(getNextHOTP(_:))
return action == #selector(copy(_:)) || action == #selector(revealPassword) || action == #selector(getNextHOTP)
default:
return action == #selector(copy(_:))
}

View file

@ -31,13 +31,13 @@ class UICodeHighlightingLabel: UILocalizedLabel {
let formattedText = text.splitByNewline()
.map { line -> NSAttributedString in
if line.starts(with: " ") {
return NSAttributedString(string: line, attributes: UICodeHighlightingLabel.CODE_ATTRIBUTES)
return NSAttributedString(string: line, attributes: Self.CODE_ATTRIBUTES)
}
return NSAttributedString(string: line)
}
.reduce(into: NSMutableAttributedString(string: "")) {
$0.append($1)
$0.append(UICodeHighlightingLabel.ATTRIBUTED_NEWLINE)
$0.append(Self.ATTRIBUTED_NEWLINE)
}
formattedText.deleteCharacters(in: NSRange(location: formattedText.length - 1, length: 1))
return formattedText