From 8f0a3d0bf3a149d84b1e82f24908149f28bff4a3 Mon Sep 17 00:00:00 2001 From: Oliver Wiese <oliver.wiese@fu-berlin.de> Date: Tue, 22 Jan 2019 18:59:01 +0100 Subject: [PATCH] refactoring icons --- enzevalos_iphone.xcodeproj/project.pbxproj | 2 +- enzevalos_iphone/AnimatedSendIcon.swift | 4 ++-- enzevalos_iphone/ContactViewController.swift | 14 +++++++------- enzevalos_iphone/FolderViewController.swift | 6 +++--- enzevalos_iphone/InboxTableViewCell.swift | 4 ++-- enzevalos_iphone/Logger.swift | 3 +-- enzevalos_iphone/Onboarding.swift | 6 +++--- enzevalos_iphone/ReadViewController.swift | 6 +++--- enzevalos_iphone/StudySettings.swift | 2 ++ .../{ => study parameters}/IconsStyleKit.swift | 5 +---- 10 files changed, 25 insertions(+), 27 deletions(-) rename enzevalos_iphone/{ => study parameters}/IconsStyleKit.swift (99%) diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj b/enzevalos_iphone.xcodeproj/project.pbxproj index b0c4aa04..992b9e73 100644 --- a/enzevalos_iphone.xcodeproj/project.pbxproj +++ b/enzevalos_iphone.xcodeproj/project.pbxproj @@ -635,6 +635,7 @@ isa = PBXGroup; children = ( 477548E121F77466000B22A8 /* SecurityIndicator.swift */, + F1984D711E1D327200804E1E /* IconsStyleKit.swift */, 477548E321F77BA0000B22A8 /* StudyParameterProtocol.swift */, ); path = "study parameters"; @@ -819,7 +820,6 @@ A198270D1D9A8ABC0027F65C /* enzevalos_iphone-Bridging-Header.h */, A1F9922B1DA7C9100073BF1B /* Main.storyboard */, F1984D731E1E92B300804E1E /* LabelStyleKit.swift */, - F1984D711E1D327200804E1E /* IconsStyleKit.swift */, A1123E6C1DA682850069551C /* Localizable.strings */, A13526841D955BDF00D3BFE1 /* LaunchScreen.storyboard */, A1EB05A31D956E32008659C1 /* Assets.xcassets */, diff --git a/enzevalos_iphone/AnimatedSendIcon.swift b/enzevalos_iphone/AnimatedSendIcon.swift index 01e31e14..a469e485 100644 --- a/enzevalos_iphone/AnimatedSendIcon.swift +++ b/enzevalos_iphone/AnimatedSendIcon.swift @@ -24,8 +24,8 @@ import UIKit class AnimatedSendIcon: UIView { var isPostcardOnTop = false - var square = UIImageView(image:IconsStyleKit.imageOfLetterBG) - var square2 = UIImageView(image:IconsStyleKit.imageOfPostcardBG) + var square = UIImageView(image: StudySettings.securityIndicator.imageOfSecureIndicator(background: true, open: false)) + var square2 = UIImageView(image: StudySettings.securityIndicator.imageOfInsecureIndicator(background: true)) let width = 100.0 let height = 70.0 let f = 0.8 diff --git a/enzevalos_iphone/ContactViewController.swift b/enzevalos_iphone/ContactViewController.swift index 4b1e65d7..56c573e8 100644 --- a/enzevalos_iphone/ContactViewController.swift +++ b/enzevalos_iphone/ContactViewController.swift @@ -156,11 +156,11 @@ class ContactViewController: UIViewController { let frame = CGRect(x: myBounds.size.width / 2 - iconSize / 2, y: myBounds.size.height / 2 - iconSize / 2, width: iconSize, height: iconSize) if keyRecord.hasKey { - IconsStyleKit.drawLetter(frame: frame, fillBackground: true) + StudySettings.securityIndicator.drawOfSecureIndictor(frame: frame, fillbackground: true, open: false) } else if keyRecord.isVerified { - IconsStyleKit.drawLetter(frame: frame, color: UIColor.white) + StudySettings.securityIndicator.drawOfSecureIndictor(frame: frame, color: UIColor.white, fillbackground: true, open: false) } else { - IconsStyleKit.drawPostcard(frame: frame, resizing: .aspectFit, color: UIColor.white) + StudySettings.securityIndicator.drawOfInSecureIndictor(frame: frame, color: UIColor.white, open: false) } let img = UIGraphicsGetImageFromCurrentImageContext(); @@ -372,10 +372,10 @@ extension ContactViewController: UITableViewDataSource { dateFormatter.locale = Locale.current dateFormatter.dateStyle = .medium cell.dateLabel.text = dateFormatter.string(from: time as Date) - cell.iconImage.image = IconsStyleKit.imageOfLetter + cell.iconImage.image = StudySettings.securityIndicator.imageOfSecureIndicator(open: false) } else { cell.dateLabel.text = "" - cell.iconImage.image = IconsStyleKit.imageOfPostcard + cell.iconImage.image = StudySettings.securityIndicator.imageOfInsecureIndicator() } cell.label.text = r[indexPath.row].addresses.first?.mailAddress } @@ -392,10 +392,10 @@ extension ContactViewController: UITableViewDataSource { dateFormatter.locale = Locale.current dateFormatter.dateStyle = .medium cell.dateLabel.text = dateFormatter.string(from: time as Date) - cell.iconImage.image = IconsStyleKit.imageOfLetter + cell.iconImage.image = StudySettings.securityIndicator.imageOfSecureIndicator() } else { cell.dateLabel.text = "" - cell.iconImage.image = IconsStyleKit.imageOfPostcard + cell.iconImage.image = StudySettings.securityIndicator.imageOfInsecureIndicator() } cell.label.text = r[indexPath.row].addresses.first?.mailAddress } diff --git a/enzevalos_iphone/FolderViewController.swift b/enzevalos_iphone/FolderViewController.swift index 145cec85..5dfb6a2b 100644 --- a/enzevalos_iphone/FolderViewController.swift +++ b/enzevalos_iphone/FolderViewController.swift @@ -130,11 +130,11 @@ class FolderViewController: UITableViewController { cell.date.text = mail.timeString if mail.isSecure { - cell.secureImageView.image = IconsStyleKit.imageOfLetter + cell.secureImageView.image = StudySettings.securityIndicator.imageOfSecureIndicator() } else if mail.trouble { - cell.secureImageView.image = IconsStyleKit.imageOfLetterCorrupted + cell.secureImageView.image = StudySettings.securityIndicator.imageOfCorruptedIndicator() } else { - cell.secureImageView.image = IconsStyleKit.imageOfPostcard + cell.secureImageView.image = StudySettings.securityIndicator.imageOfInsecureIndicator() } if !mail.isRead { cell.markImageView.image = "🔵".image() diff --git a/enzevalos_iphone/InboxTableViewCell.swift b/enzevalos_iphone/InboxTableViewCell.swift index e1d6f46e..0c4f76d3 100644 --- a/enzevalos_iphone/InboxTableViewCell.swift +++ b/enzevalos_iphone/InboxTableViewCell.swift @@ -99,9 +99,9 @@ class InboxTableViewCell: UITableViewCell { secondButton.isEnabled = false } if con.isSecure { - iconView.image = IconsStyleKit.imageOfLetterBG + iconView.image = StudySettings.securityIndicator.imageOfSecureIndicator(background: true, open: false) } else { - iconView.image = IconsStyleKit.imageOfPostcardBG + iconView.image = StudySettings.securityIndicator.imageOfInsecureIndicator(background: true) } var cont: Contact diff --git a/enzevalos_iphone/Logger.swift b/enzevalos_iphone/Logger.swift index 23958fc0..3902a867 100644 --- a/enzevalos_iphone/Logger.swift +++ b/enzevalos_iphone/Logger.swift @@ -36,12 +36,11 @@ class Logger { static var studyID = StudySettings.studyID //identifies the participant in the study static fileprivate func sendCheck() { - if nextDeadline <= Date() && AppDelegate.getAppDelegate().currentReachabilityStatus != .notReachable { + if nextDeadline <= Date() && AppDelegate.getAppDelegate().currentReachabilityStatus != .notReachable && UserManager.loadUserValue(Attribute.userName) != nil { //Do not send duplicate mails let tmpNextDeadline = Date(timeIntervalSinceNow: TimeInterval(resendInterval)) nextDeadline = tmpNextDeadline UserManager.storeUserValue(nextDeadline as AnyObject?, attribute: Attribute.nextDeadline) - sendLog() } } diff --git a/enzevalos_iphone/Onboarding.swift b/enzevalos_iphone/Onboarding.swift index 3376c3cb..81842262 100644 --- a/enzevalos_iphone/Onboarding.swift +++ b/enzevalos_iphone/Onboarding.swift @@ -104,12 +104,12 @@ class Onboarding: NSObject { intro1.iconWidth = 80 } UIGraphicsBeginImageContextWithOptions(CGSize(width: intro1.iconWidth, height: intro1.iconHeight), false, 0) - IconsStyleKit.drawLetter(frame: CGRect(x: 0, y: 0, width: intro1.iconWidth, height: intro1.iconHeight), fillBackground: true) + StudySettings.securityIndicator.drawOfSecureIndictor(frame: CGRect(x: 0, y: 0, width: intro1.iconWidth, height: intro1.iconHeight), fillbackground: true, open: false) intro1.iconImageView.image = UIGraphicsGetImageFromCurrentImageContext()! UIGraphicsEndImageContext() intro1.bodyLabel.textAlignment = NSTextAlignment.left - let intro2 = OnboardingContentViewController.content(withTitle: NSLocalizedString("Postcard", comment: ""), body: NSLocalizedString("PostcardDescription", comment: "describe the postcard"), image: IconsStyleKit.imageOfPostcardBG, buttonText: nil, action: nil) + let intro2 = OnboardingContentViewController.content(withTitle: NSLocalizedString("Postcard", comment: ""), body: NSLocalizedString("PostcardDescription", comment: "describe the postcard"), image: StudySettings.securityIndicator.imageOfInsecureIndicator(background: true), buttonText: nil, action: nil) intro2.iconHeight = 70 intro2.iconWidth = 100 @@ -118,7 +118,7 @@ class Onboarding: NSObject { intro2.iconWidth = 80 } UIGraphicsBeginImageContextWithOptions(CGSize(width: intro2.iconWidth, height: intro2.iconHeight), false, 0) - IconsStyleKit.drawPostcard(frame: CGRect(x: 0, y: 0, width: intro2.iconWidth, height: intro2.iconHeight), fillBackground: true) + StudySettings.securityIndicator.drawOfInSecureIndictor(frame: CGRect(x: 0, y: 0, width: intro2.iconWidth, height: intro2.iconHeight), fillbackground: true, open: false) intro2.iconImageView.image = UIGraphicsGetImageFromCurrentImageContext()! UIGraphicsEndImageContext() intro2.bodyLabel.textAlignment = NSTextAlignment.left diff --git a/enzevalos_iphone/ReadViewController.swift b/enzevalos_iphone/ReadViewController.swift index 9032e51f..ae1ed54b 100644 --- a/enzevalos_iphone/ReadViewController.swift +++ b/enzevalos_iphone/ReadViewController.swift @@ -444,11 +444,11 @@ class ReadViewController: UITableViewController { iconView.contentMode = .scaleAspectFit var icon: UIImage if mail.trouble { - icon = IconsStyleKit.imageOfLetterCorrupted + icon = StudySettings.securityIndicator.imageOfCorruptedIndicator() } else if mail.isSecure { - icon = IconsStyleKit.imageOfLetterOpen + icon = StudySettings.securityIndicator.imageOfSecureIndicator() } else { - icon = IconsStyleKit.imageOfPostcard + icon = StudySettings.securityIndicator.imageOfInsecureIndicator() } iconView.image = icon iconButton.setImage(icon, for: UIControlState()) diff --git a/enzevalos_iphone/StudySettings.swift b/enzevalos_iphone/StudySettings.swift index ec9c8e22..22ad9b8c 100644 --- a/enzevalos_iphone/StudySettings.swift +++ b/enzevalos_iphone/StudySettings.swift @@ -80,6 +80,8 @@ class StudySettings { static var studyMode = true static var presentFirstQuestionaireMail = false static let parameters = [StudyParamter.Indicator] + static let securityIndicator = SecurityIndicator.padlock + static let bitcoinStudyBody = """ diff --git a/enzevalos_iphone/IconsStyleKit.swift b/enzevalos_iphone/study parameters/IconsStyleKit.swift similarity index 99% rename from enzevalos_iphone/IconsStyleKit.swift rename to enzevalos_iphone/study parameters/IconsStyleKit.swift index 834f9778..9e14ca2c 100644 --- a/enzevalos_iphone/IconsStyleKit.swift +++ b/enzevalos_iphone/study parameters/IconsStyleKit.swift @@ -9,12 +9,9 @@ // http://www.paintcodeapp.com // // - - - import UIKit -open class IconsStyleKit: NSObject { +internal class IconsStyleKit: NSObject { //// Cache -- GitLab