From 3dfd19db22cafa4c34148d5688fc40d0c044b306 Mon Sep 17 00:00:00 2001 From: Benjamin Erhart Date: Mon, 14 May 2018 15:07:33 +0200 Subject: [PATCH] Issue #603: Show trusted/untrusted badge on single fingerprint instead of green/red coloured checkmark. --- .../ZomFingerprintBaseViewController.swift | 37 ++++++++++--------- .../ZomVerificationDetailViewController.swift | 2 +- .../ZomVerificationViewController.swift | 2 +- .../ZomFingerprintVerificationCell.swift | 4 +- .../Views/ZomFingerprintVerificationCell.xib | 8 ++-- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Zom/Zom/Classes/View Controllers/ZomFingerprintBaseViewController.swift b/Zom/Zom/Classes/View Controllers/ZomFingerprintBaseViewController.swift index d51bd6a..f2e21de 100644 --- a/Zom/Zom/Classes/View Controllers/ZomFingerprintBaseViewController.swift +++ b/Zom/Zom/Classes/View Controllers/ZomFingerprintBaseViewController.swift @@ -167,6 +167,25 @@ class ZomFingerprintBaseViewController: UIViewController { attributes: attributes) } + /** + Sets the style of `self.badgeLb` - the little badge in the bottom right corner of a user's + avatar to either be read and display shield with an exclamation mark or be green and display + a shield with a check mark. + + - parameter label: The badge label to change + - parameter ok: Set true if all keys aka. fingerprints are ok (none are `.untrustedNew`) + */ + static func setBadge(_ label: UILabel, ok: Bool) { + if ok { + label.backgroundColor = UIColor.zomGreen + label.text = "" // Shield with check mark + } + else { + label.backgroundColor = UIColor.zomRed + label.text = "" // Shield with exclamation mark + } + } + /** - returns: the buddy's `displayName` or "your buddy" as a default value, if no buddy or no `displayName`. @@ -199,22 +218,4 @@ class ZomFingerprintBaseViewController: UIViewController { return untrusted } - - /** - Sets the style of `self.badgeLb` - the little badge in the bottom right corner of a user's - avatar to either be read and display shield with an exclamation mark or be green and display - a shield with a check mark. - - - parameter ok: Set true if all keys aka. fingerprints are ok (none are `.untrustedNew`) - */ - func setBadge(ok: Bool) { - if ok { - badgeLb.backgroundColor = UIColor.zomGreen - badgeLb.text = "" // Shield with check mark - } - else { - badgeLb.backgroundColor = UIColor.zomRed - badgeLb.text = "" // Shield with exclamation mark - } - } } diff --git a/Zom/Zom/Classes/View Controllers/ZomVerificationDetailViewController.swift b/Zom/Zom/Classes/View Controllers/ZomVerificationDetailViewController.swift index 636a326..ccf2e94 100644 --- a/Zom/Zom/Classes/View Controllers/ZomVerificationDetailViewController.swift +++ b/Zom/Zom/Classes/View Controllers/ZomVerificationDetailViewController.swift @@ -91,7 +91,7 @@ class ZomVerificationDetailViewController: ZomFingerprintBaseViewController, UIT private func updateUntrustedNewFingerprintsInfo() { let untrusted = countUntrusted() - setBadge(ok: untrusted < 1) + ZomFingerprintBaseViewController.setBadge(badgeLb, ok: untrusted < 1) subtitleLb.text = NSLocalizedString("\(untrusted) Untrusted New Codes for \(buddyName())", comment: "Subtitle for code verification detail scene") diff --git a/Zom/Zom/Classes/View Controllers/ZomVerificationViewController.swift b/Zom/Zom/Classes/View Controllers/ZomVerificationViewController.swift index 3b42bc2..2273428 100644 --- a/Zom/Zom/Classes/View Controllers/ZomVerificationViewController.swift +++ b/Zom/Zom/Classes/View Controllers/ZomVerificationViewController.swift @@ -53,7 +53,7 @@ class ZomVerificationViewController: ZomFingerprintBaseViewController { OTR fingerprint if no OMEMO device found. */ override func fingerprintsLoaded() { - setBadge(ok: countUntrusted() < 1) + ZomFingerprintBaseViewController.setBadge(badgeLb, ok: countUntrusted() < 1) if let device = omemoDevices .filter({ (device) -> Bool in return device.trustLevel == .untrustedNew }) diff --git a/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.swift b/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.swift index abd5154..852aa75 100644 --- a/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.swift +++ b/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.swift @@ -44,7 +44,7 @@ class ZomFingerprintVerificationCell: UITableViewCell { omemoDevice = device let trusted = device.isTrusted() - trustBadge.backgroundColor = trusted ? UIColor.zomGreen : UIColor.zomRed + ZomFingerprintBaseViewController.setBadge(trustBadge, ok: trusted) var infos: [String] = [] @@ -75,7 +75,7 @@ class ZomFingerprintVerificationCell: UITableViewCell { otrFingerprint = fingerprint let trusted = fingerprint.isTrusted() - trustBadge.backgroundColor = trusted ? UIColor.zomGreen : UIColor.zomRed + ZomFingerprintBaseViewController.setBadge(trustBadge, ok: trusted) infoLb.text = getTrustStateString(trusted) diff --git a/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.xib b/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.xib index 5689d32..15c6747 100644 --- a/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.xib +++ b/Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.xib @@ -11,8 +11,8 @@ - - MaterialIcons-Regular + + icomoon @@ -25,14 +25,14 @@ -