Skip to content
Snippets Groups Projects
Commit 8f07d767 authored by Oliver Wiese's avatar Oliver Wiese
Browse files

fix copy key to clipboard button

parent 6e8c38bc
No related branches found
No related tags found
1 merge request!25I tunes key import
......@@ -12,11 +12,23 @@ class ButtonCell: UITableViewCell {
@IBOutlet weak var button: UIButton!
var listener: ButtonCellHandler?
var id = 0
var isEnabled: Bool {
set {
button.isEnabled = newValue
self.isUserInteractionEnabled = button.isEnabled
}
get {
self.isUserInteractionEnabled = button.isEnabled
return button.isEnabled
}
}
@IBAction func touchDown(_ sender: UIButton) {
if let l = listener {
if button.isEnabled, let l = listener {
l.touchDown(id: id)
}
}
}
......
......@@ -27,6 +27,7 @@ class KeyViewController: UIViewController {
var openDate: Date = Date() //used for logging issues [see Logger.log(keyViewClose keyID:String, timevisited: Date)]
var record: KeyRecord?
var copyButton: ButtonCell?
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
......@@ -165,12 +166,16 @@ extension KeyViewController: UITableViewDataSource {
cell.button.setTitle(NSLocalizedString("copied", comment: "the key has been copied to the clipboard"), for: .disabled)
cell.id = KeyActions.Copy.hashValue
cell.listener = self
copyButton = cell
}
else if indexPath.row == 1 {
// Change key
cell.button.setTitle("Change prefered key", for: UIControl.State())
cell.id = KeyActions.Change.hashValue
cell.listener = self
if DataHandler.handler.findSecretKeys().count < 2 && !ItunesKeyHandling.iTunesKeyHandler.hasStoredKeys {
cell.isHidden = true
}
}
return cell
}
......@@ -294,7 +299,9 @@ extension KeyViewController: ButtonCellHandler {
let swiftpgp = SwiftPGP()
if let key = swiftpgp.exportKey(id: keyId, isSecretkey: false, autocrypt: false) {
UIPasteboard.general.string = key
//TODO copyButton.isEnabled = false
if let copyCell = copyButton {
copyCell.isEnabled = false
}
} else {
print("Error while getting key")
}
......@@ -303,9 +310,6 @@ extension KeyViewController: ButtonCellHandler {
if let secretKeyCon = SecretKeyTableViewController.storyboardInstance() {
self.navigationController?.pushViewController(secretKeyCon, animated: true)
}
else {
// disable button
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment