IOS-462 showing partner data
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 20 Apr 2017 18:03:27 +0200
changeset 20425819b5d16e6e
parent 2041 eaac91f98aab
child 2043 9751ed7e2e2d
IOS-462 showing partner data
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/UI/Handshake/HandshakePartnerTableViewCell.swift
pEpForiOS/UI/Handshake/HandshakeViewController.swift
pEpForiOS/UI/Util/PEP+UI.swift
pEpForiOS/Util/PEPExtensions.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Thu Apr 20 17:31:40 2017 +0200
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Thu Apr 20 18:03:27 2017 +0200
     1.3 @@ -94,7 +94,6 @@
     1.4  		4348EF0D1E27ABA100F441A9 /* LoginSmtpOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4348EF0C1E27ABA100F441A9 /* LoginSmtpOperation.swift */; };
     1.5  		4348EF151E27E37400F441A9 /* Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc in Resources */ = {isa = PBXBuildFile; fileRef = 4348EF141E27E37400F441A9 /* Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc */; };
     1.6  		434B5D191DDF67E400BEDEF0 /* CdMessage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 434B5D181DDF67E400BEDEF0 /* CdMessage+Extension.swift */; };
     1.7 -		434D09491E44A61500F03EAC /* PEPExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 434D09481E44A61500F03EAC /* PEPExtensions.swift */; };
     1.8  		434F84451CEB018A0055B7A9 /* NSData+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 434F84441CEB018A0055B7A9 /* NSData+Extensions.swift */; };
     1.9  		4352FA1F1DC79E9B0081161A /* ShortCircuitSendLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4352FA1E1DC79E9B0081161A /* ShortCircuitSendLayer.swift */; };
    1.10  		43549A8E1E48B54100210D86 /* TrashMailsOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43549A8D1E48B54100210D86 /* TrashMailsOperation.swift */; };
    1.11 @@ -152,6 +151,7 @@
    1.12  		43C046BF1CF48EA500BD0D9D /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43C046BE1CF48EA500BD0D9D /* AddressBook.framework */; };
    1.13  		43C322051EA89EED005073FB /* HandshakePartnerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C322041EA89EED005073FB /* HandshakePartnerTableViewCell.swift */; };
    1.14  		43C322071EA8E7AD005073FB /* UIButton+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C322061EA8E7AD005073FB /* UIButton+Extension.swift */; };
    1.15 +		43C322091EA90192005073FB /* PEP+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C322081EA90192005073FB /* PEP+UI.swift */; };
    1.16  		43C6F35B1CBE7496006A2A18 /* ConnectionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C6F35A1CBE7496006A2A18 /* ConnectionManager.swift */; };
    1.17  		43C7B9D11CEC4DDF007A612F /* MiscTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C7B9D01CEC4DDF007A612F /* MiscTests.swift */; };
    1.18  		43CE63C51DE87FB200FAC505 /* Identity+pEp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43CE63C41DE87FB200FAC505 /* Identity+pEp.swift */; };
    1.19 @@ -332,7 +332,6 @@
    1.20  		4348EF0C1E27ABA100F441A9 /* LoginSmtpOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginSmtpOperation.swift; sourceTree = "<group>"; };
    1.21  		4348EF141E27E37400F441A9 /* Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Unit 1 unittest.ios.1@peptest.ch (0x9CB8DBCC) pub.asc"; sourceTree = "<group>"; };
    1.22  		434B5D181DDF67E400BEDEF0 /* CdMessage+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CdMessage+Extension.swift"; sourceTree = "<group>"; };
    1.23 -		434D09481E44A61500F03EAC /* PEPExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PEPExtensions.swift; sourceTree = "<group>"; };
    1.24  		434F84441CEB018A0055B7A9 /* NSData+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSData+Extensions.swift"; sourceTree = "<group>"; };
    1.25  		4352FA1E1DC79E9B0081161A /* ShortCircuitSendLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShortCircuitSendLayer.swift; sourceTree = "<group>"; };
    1.26  		43549A8D1E48B54100210D86 /* TrashMailsOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrashMailsOperation.swift; sourceTree = "<group>"; };
    1.27 @@ -401,6 +400,7 @@
    1.28  		43C046BE1CF48EA500BD0D9D /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
    1.29  		43C322041EA89EED005073FB /* HandshakePartnerTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HandshakePartnerTableViewCell.swift; sourceTree = "<group>"; };
    1.30  		43C322061EA8E7AD005073FB /* UIButton+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+Extension.swift"; sourceTree = "<group>"; };
    1.31 +		43C322081EA90192005073FB /* PEP+UI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PEP+UI.swift"; sourceTree = "<group>"; };
    1.32  		43C6F35A1CBE7496006A2A18 /* ConnectionManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionManager.swift; sourceTree = "<group>"; };
    1.33  		43C7B9D01CEC4DDF007A612F /* MiscTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MiscTests.swift; sourceTree = "<group>"; };
    1.34  		43CE63C41DE87FB200FAC505 /* Identity+pEp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Identity+pEp.swift"; sourceTree = "<group>"; };
    1.35 @@ -793,7 +793,6 @@
    1.36  				43980EDF1CBD24B000A7FC3C /* Log.swift */,
    1.37  				435B42401D211E5900119048 /* MiscUtil.swift */,
    1.38  				5D039A9B1D0EE7F900AD59EC /* PEPUtil.swift */,
    1.39 -				434D09481E44A61500F03EAC /* PEPExtensions.swift */,
    1.40  				431798761CF87FE6007DD655 /* ReferenceCounter.swift */,
    1.41  				433BCD941D5388C100DD98EF /* ReplyUtil.swift */,
    1.42  				228038671DC9DE6D00F1CB45 /* TextfieldResponder.swift */,
    1.43 @@ -834,6 +833,7 @@
    1.44  		43AA82511E9B925000ABD5A8 /* Util */ = {
    1.45  			isa = PBXGroup;
    1.46  			children = (
    1.47 +				43C322081EA90192005073FB /* PEP+UI.swift */,
    1.48  				43AA82521E9B925C00ABD5A8 /* UIView+Util.swift */,
    1.49  				43C322061EA8E7AD005073FB /* UIButton+Extension.swift */,
    1.50  			);
    1.51 @@ -1219,7 +1219,6 @@
    1.52  				43AA825D1E9BD60600ABD5A8 /* AttachmentsViewDelegate.swift in Sources */,
    1.53  				220DCE371E0AB5CC002FE716 /* MessageSubjectCell.swift in Sources */,
    1.54  				43313DF41DEC7AE600C111C8 /* CreateFoldersOperation.swift in Sources */,
    1.55 -				434D09491E44A61500F03EAC /* PEPExtensions.swift in Sources */,
    1.56  				43ED53771CC77F95006AB156 /* OneValueSettingCell.swift in Sources */,
    1.57  				5D039AA21D0EEA3700AD59EC /* DecryptMessagesOperation.swift in Sources */,
    1.58  				438D5A711EA77CFC001A37E1 /* HandshakeViewController.swift in Sources */,
    1.59 @@ -1281,6 +1280,7 @@
    1.60  				4382E6431CC600FF00AA27EA /* PersistentImapFolder.swift in Sources */,
    1.61  				43CE63CF1DE8845E00FAC505 /* CdAttachment+pEp.swift in Sources */,
    1.62  				43B7154D1CECAADA0027861A /* ViewWidthsAligner.swift in Sources */,
    1.63 +				43C322091EA90192005073FB /* PEP+UI.swift in Sources */,
    1.64  				4323FE921E851D4E006785E1 /* UIImage+Extension.swift in Sources */,
    1.65  				4323FE891E83E517006785E1 /* IdentityImageProvider.swift in Sources */,
    1.66  				43549A8E1E48B54100210D86 /* TrashMailsOperation.swift in Sources */,
     2.1 --- a/pEpForiOS/UI/Handshake/HandshakePartnerTableViewCell.swift	Thu Apr 20 17:31:40 2017 +0200
     2.2 +++ b/pEpForiOS/UI/Handshake/HandshakePartnerTableViewCell.swift	Thu Apr 20 18:03:27 2017 +0200
     2.3 @@ -28,7 +28,18 @@
     2.4          setNeedsLayout()
     2.5      }
     2.6  
     2.7 -    func updateCell(message: Message, indexPath: IndexPath) {
     2.8 +    func updateCell(indexPath: IndexPath, message: Message, partner: Identity,
     2.9 +                    session: PEPSession?, imageProvider: IdentityImageProvider) {
    2.10 +        partnerNameLabel.text = partner.userName ?? partner.address
    2.11  
    2.12 +        let theSession = session ?? PEPSession()
    2.13 +        let rating = partner.pEpRating(session: theSession)
    2.14 +        pEpStatusImageView.image = rating.statusIcon()
    2.15 +
    2.16 +        imageProvider.image(forIdentity: partner) { [weak self] img in
    2.17 +            GCD.onMain() {
    2.18 +                self?.partnerImageView.image = img
    2.19 +            }
    2.20 +        }
    2.21      }
    2.22  }
     3.1 --- a/pEpForiOS/UI/Handshake/HandshakeViewController.swift	Thu Apr 20 17:31:40 2017 +0200
     3.2 +++ b/pEpForiOS/UI/Handshake/HandshakeViewController.swift	Thu Apr 20 18:03:27 2017 +0200
     3.3 @@ -21,6 +21,7 @@
     3.4  
     3.5      var ratingReEvaluator: RatingReEvaluator?
     3.6      var partners = [Identity]()
     3.7 +    let imageProvider = IdentityImageProvider()
     3.8  
     3.9      override func awakeFromNib() {
    3.10          tableView.estimatedRowHeight = 72.0
    3.11 @@ -43,7 +44,9 @@
    3.12              withIdentifier: "handshakePartnerCell",
    3.13              for: indexPath) as? HandshakePartnerTableViewCell {
    3.14              if let m = message {
    3.15 -                cell.updateCell(message: m, indexPath: indexPath)
    3.16 +                let theId = partners[indexPath.row]
    3.17 +                cell.updateCell(indexPath: indexPath, message: m, partner: theId,
    3.18 +                                session: appConfig?.session, imageProvider: imageProvider)
    3.19              }
    3.20              return cell
    3.21          }
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pEpForiOS/UI/Util/PEP+UI.swift	Thu Apr 20 18:03:27 2017 +0200
     4.3 @@ -0,0 +1,64 @@
     4.4 +//
     4.5 +//  PEPExtensions.swift
     4.6 +//  pEpForiOS
     4.7 +//
     4.8 +//  Created by Dirk Zimmermann on 03/02/2017.
     4.9 +//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    4.10 +//
    4.11 +
    4.12 +import UIKit
    4.13 +
    4.14 +extension PEP_color {
    4.15 +    func statusIcon(enabled: Bool = true) -> UIImage? {
    4.16 +        switch self {
    4.17 +        case PEP_color_no_color:
    4.18 +            return nil
    4.19 +        case PEP_color_red:
    4.20 +            return UIImage(named: "pep-status-red")
    4.21 +        case PEP_color_yellow:
    4.22 +            if enabled {
    4.23 +                return UIImage(named: "pep-status-yellow")
    4.24 +            } else {
    4.25 +                return UIImage(named: "pep-status-yellow-gray")
    4.26 +            }
    4.27 +        case PEP_color_green:
    4.28 +            if enabled {
    4.29 +                return UIImage(named: "pep-status-green")
    4.30 +            } else {
    4.31 +                return UIImage(named: "pep-status-green-gray")
    4.32 +            }
    4.33 +        default:
    4.34 +            return nil
    4.35 +        }
    4.36 +    }
    4.37 +
    4.38 +    func uiColor() -> UIColor? {
    4.39 +        switch self {
    4.40 +        case PEP_color_no_color:
    4.41 +            return nil
    4.42 +        case PEP_color_red:
    4.43 +            return UIColor.pEpRed
    4.44 +        case PEP_color_yellow:
    4.45 +            return UIColor.pEpYellow
    4.46 +        case PEP_color_green:
    4.47 +            return UIColor.pEpGreen
    4.48 +        default:
    4.49 +            return nil
    4.50 +        }
    4.51 +    }
    4.52 +}
    4.53 +
    4.54 +extension PEP_rating {
    4.55 +    func pepColor() -> PEP_color {
    4.56 +        return PEPUtil.pEpColor(pEpRating: self)
    4.57 +    }
    4.58 +
    4.59 +    func uiColor() -> UIColor? {
    4.60 +        return PEPUtil.pEpColor(pEpRating: self).uiColor()
    4.61 +    }
    4.62 +
    4.63 +    func statusIcon() -> UIImage? {
    4.64 +        let color = pepColor()
    4.65 +        return color.statusIcon()
    4.66 +    }
    4.67 +}
     5.1 --- a/pEpForiOS/Util/PEPExtensions.swift	Thu Apr 20 17:31:40 2017 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,59 +0,0 @@
     5.4 -//
     5.5 -//  PEPExtensions.swift
     5.6 -//  pEpForiOS
     5.7 -//
     5.8 -//  Created by Dirk Zimmermann on 03/02/2017.
     5.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    5.10 -//
    5.11 -
    5.12 -import UIKit
    5.13 -
    5.14 -extension PEP_color {
    5.15 -    func statusIcon(enabled: Bool = true) -> UIImage? {
    5.16 -        switch self {
    5.17 -        case PEP_color_no_color:
    5.18 -            return nil
    5.19 -        case PEP_color_red:
    5.20 -            return UIImage(named: "pep-status-red")
    5.21 -        case PEP_color_yellow:
    5.22 -            if enabled {
    5.23 -                return UIImage(named: "pep-status-yellow")
    5.24 -            } else {
    5.25 -                return UIImage(named: "pep-status-yellow-gray")
    5.26 -            }
    5.27 -        case PEP_color_green:
    5.28 -            if enabled {
    5.29 -                return UIImage(named: "pep-status-green")
    5.30 -            } else {
    5.31 -                return UIImage(named: "pep-status-green-gray")
    5.32 -            }
    5.33 -        default:
    5.34 -            return nil
    5.35 -        }
    5.36 -    }
    5.37 -
    5.38 -    func uiColor() -> UIColor? {
    5.39 -        switch self {
    5.40 -        case PEP_color_no_color:
    5.41 -            return nil
    5.42 -        case PEP_color_red:
    5.43 -            return UIColor.pEpRed
    5.44 -        case PEP_color_yellow:
    5.45 -            return UIColor.pEpYellow
    5.46 -        case PEP_color_green:
    5.47 -            return UIColor.pEpGreen
    5.48 -        default:
    5.49 -            return nil
    5.50 -        }
    5.51 -    }
    5.52 -}
    5.53 -
    5.54 -extension PEP_rating {
    5.55 -    func pepColor() -> PEP_color {
    5.56 -        return PEPUtil.pEpColor(pEpRating: self)
    5.57 -    }
    5.58 -
    5.59 -    func uiColor() -> UIColor? {
    5.60 -        return PEPUtil.pEpColor(pEpRating: self).uiColor()
    5.61 -    }
    5.62 -}