diff --git a/Signal/Images.xcassets/Loki V2/Contents.json b/Signal/Images.xcassets/Loki V2/Contents.json index da4a164c9..73c00596a 100644 --- a/Signal/Images.xcassets/Loki V2/Contents.json +++ b/Signal/Images.xcassets/Loki V2/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/Contents.json b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/Contents.json new file mode 100644 index 000000000..4bfca47bb --- /dev/null +++ b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "SessionWhite16.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "SessionWhite16@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "SessionWhite16@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16.png b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16.png new file mode 100644 index 000000000..a941b7f01 Binary files /dev/null and b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16.png differ diff --git a/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16@2x.png b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16@2x.png new file mode 100644 index 000000000..70b01d1c3 Binary files /dev/null and b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16@2x.png differ diff --git a/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16@3x.png b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16@3x.png new file mode 100644 index 000000000..823fb5e1d Binary files /dev/null and b/Signal/Images.xcassets/Loki V2/SessionWhite16.imageset/SessionWhite16@3x.png differ diff --git a/Signal/src/Loki/Components/ConversationTitleView.swift b/Signal/src/Loki/Components/ConversationTitleView.swift index 89c8aee7f..c811495f1 100644 --- a/Signal/src/Loki/Components/ConversationTitleView.swift +++ b/Signal/src/Loki/Components/ConversationTitleView.swift @@ -17,7 +17,7 @@ final class ConversationTitleView : UIView { // MARK: Components private lazy var profilePictureView: ProfilePictureView = { let result = ProfilePictureView() - let size = Values.smallProfilePictureSize + let size: CGFloat = 40 result.set(.width, to: size) result.set(.height, to: size) result.size = size diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 7acc435d0..99701d8fb 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -954,20 +954,8 @@ const CGFloat kIconViewLength = 24; CGFloat horizontalSpacing = isSmallScreen ? LKValues.largeSpacing : LKValues.veryLargeSpacing; stackView.layoutMargins = UIEdgeInsetsMake(LKValues.mediumSpacing, horizontalSpacing, LKValues.mediumSpacing, horizontalSpacing); [stackView setLayoutMarginsRelativeArrangement:YES]; - - if (self.isGroupThread) { - TSGroupThread* groupThread = (TSGroupThread *)self.thread; - if (groupThread.isPublicChat && groupThread.groupModel.groupImage != nil - && ![groupThread.groupModel.groupName isEqual:@"Loki Public Chat"] && ![groupThread.groupModel.groupName isEqual:@"Session Public Chat"]) { - profilePictureView.openGroupProfilePicture = groupThread.groupModel.groupImage; - profilePictureView.isRSSFeed = false; - } else { - profilePictureView.hexEncodedPublicKey = @""; - profilePictureView.isRSSFeed = true; // For now just always show the Session logo - } - } else { - profilePictureView.hexEncodedPublicKey = self.thread.contactIdentifier; - + + if (!self.isGroupThread) { SRCopyableLabel *subtitleView = [SRCopyableLabel new]; subtitleView.textColor = LKColors.text; subtitleView.font = [LKFonts spaceMonoOfSize:LKValues.smallFontSize]; @@ -978,7 +966,7 @@ const CGFloat kIconViewLength = 24; [stackView addArrangedSubview:subtitleView]; } - [profilePictureView update]; + [profilePictureView updateForThread:self.thread]; return stackView; } diff --git a/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift b/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift index d1242cdc8..305ab0d2f 100644 --- a/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift +++ b/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift @@ -3,6 +3,8 @@ public final class ProfilePictureView : UIView { private var imageViewWidthConstraint: NSLayoutConstraint! private var imageViewHeightConstraint: NSLayoutConstraint! + private var additionalImageViewWidthConstraint: NSLayoutConstraint! + private var additionalImageViewHeightConstraint: NSLayoutConstraint! @objc public var size: CGFloat = 0 // Not an implicitly unwrapped optional due to Obj-C limitations @objc public var isRSSFeed = false @objc public var hexEncodedPublicKey: String! @@ -37,8 +39,8 @@ public final class ProfilePictureView : UIView { additionalImageView.pin(.trailing, to: .trailing, of: self) additionalImageView.pin(.bottom, to: .bottom, of: self) let additionalImageViewSize = CGFloat(Values.smallProfilePictureSize) - additionalImageView.set(.width, to: additionalImageViewSize) - additionalImageView.set(.height, to: additionalImageViewSize) + additionalImageViewWidthConstraint = additionalImageView.set(.width, to: additionalImageViewSize) + additionalImageViewHeightConstraint = additionalImageView.set(.height, to: additionalImageViewSize) additionalImageView.layer.cornerRadius = additionalImageViewSize / 2 } @@ -46,16 +48,16 @@ public final class ProfilePictureView : UIView { @objc(updateForThread:) public func update(for thread: TSThread) { openGroupProfilePicture = nil - if thread.isGroupThread() { + if let thread = thread as? TSGroupThread { if thread.name() == "Loki Public Chat" || thread.name() == "Session Public Chat" { // Override the profile picture for the Loki Public Chat and the Session Public Chat hexEncodedPublicKey = "" isRSSFeed = true - } else if let openGroupProfilePicture = (thread as! TSGroupThread).groupModel.groupImage { // An open group with a profile picture + } else if let openGroupProfilePicture = thread.groupModel.groupImage { // An open group with a profile picture self.openGroupProfilePicture = openGroupProfilePicture isRSSFeed = false - } else if (thread as! TSGroupThread).groupModel.groupType == .openGroup - || (thread as! TSGroupThread).groupModel.groupType == .rssFeed { // An open group without a profile picture or an RSS feed + } else if thread.groupModel.groupType == .openGroup + || thread.groupModel.groupType == .rssFeed { // An open group without a profile picture or an RSS feed hexEncodedPublicKey = "" isRSSFeed = true } else { // A closed group @@ -66,7 +68,7 @@ public final class ProfilePictureView : UIView { additionalHexEncodedPublicKey = randomUsers.count >= 2 ? randomUsers[1] : "" isRSSFeed = false } - } else { // A one-on-one chat + } else { // A one-to-one chat hexEncodedPublicKey = thread.contactIdentifier()! additionalHexEncodedPublicKey = nil isRSSFeed = false @@ -78,13 +80,26 @@ public final class ProfilePictureView : UIView { AssertIsOnMainThread() func getProfilePicture(of size: CGFloat, for hexEncodedPublicKey: String) -> UIImage? { guard !hexEncodedPublicKey.isEmpty else { return nil } - return OWSProfileManager.shared().profileAvatar(forRecipientId: hexEncodedPublicKey) ?? Identicon.generatePlaceholderIcon(seed: hexEncodedPublicKey, text: OWSProfileManager.shared().profileNameForRecipient(withID: hexEncodedPublicKey) ?? hexEncodedPublicKey, size: size) + if let profilePicture = OWSProfileManager.shared().profileAvatar(forRecipientId: hexEncodedPublicKey) { + return profilePicture + } else { + let displayName = OWSProfileManager.shared().profileNameForRecipient(withID: hexEncodedPublicKey) ?? hexEncodedPublicKey + return Identicon.generatePlaceholderIcon(seed: hexEncodedPublicKey, text: displayName, size: size) + } } let size: CGFloat if let additionalHexEncodedPublicKey = additionalHexEncodedPublicKey, !isRSSFeed, openGroupProfilePicture == nil { - size = Values.smallProfilePictureSize + if self.size == 40 { + size = 32 + } else if self.size == Values.largeProfilePictureSize { + size = 56 + } else { + size = Values.smallProfilePictureSize + } imageViewWidthConstraint.constant = size imageViewHeightConstraint.constant = size + additionalImageViewWidthConstraint.constant = size + additionalImageViewHeightConstraint.constant = size additionalImageView.isHidden = false additionalImageView.image = getProfilePicture(of: size, for: additionalHexEncodedPublicKey) } else { @@ -98,9 +113,14 @@ public final class ProfilePictureView : UIView { imageView.image = isRSSFeed ? nil : (openGroupProfilePicture ?? getProfilePicture(of: size, for: hexEncodedPublicKey)) imageView.backgroundColor = isRSSFeed ? UIColor(rgbHex: 0x353535) : Colors.unimportant imageView.layer.cornerRadius = size / 2 + additionalImageView.layer.cornerRadius = size / 2 imageView.contentMode = isRSSFeed ? .center : .scaleAspectFit if isRSSFeed { - imageView.image = (size == 45) ? #imageLiteral(resourceName: "SessionWhite24") : #imageLiteral(resourceName: "SessionWhite40") + switch size { + case Values.smallProfilePictureSize..