Merge branch 'dev' into voice-calls-2
This commit is contained in:
commit
37614fe3d8
|
@ -236,7 +236,6 @@
|
|||
B8566C6C256F60F50045A0B9 /* OWSUserProfile.m in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2D1255B6DAF007E1867 /* OWSUserProfile.m */; };
|
||||
B8566C7D256F62030045A0B9 /* OWSUserProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = C38EF2D3255B6DAF007E1867 /* OWSUserProfile.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B8569AC325CB5D2900DBA3DB /* ConversationVC+Interaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8569AC225CB5D2900DBA3DB /* ConversationVC+Interaction.swift */; };
|
||||
B8569AD325CBA13D00DBA3DB /* MediaTextOverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8569AD225CBA13D00DBA3DB /* MediaTextOverlayView.swift */; };
|
||||
B8569AE325CBB19A00DBA3DB /* DocumentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8569AE225CBB19A00DBA3DB /* DocumentView.swift */; };
|
||||
B866CE112581C1A900535CC4 /* Sodium+Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E7134E251C867C009649BB /* Sodium+Conversion.swift */; };
|
||||
B86BD08423399ACF000F5AE3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B86BD08323399ACF000F5AE3 /* Modal.swift */; };
|
||||
|
@ -283,8 +282,6 @@
|
|||
B894D0752339EDCF00B4D94D /* NukeDataModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B894D0742339EDCF00B4D94D /* NukeDataModal.swift */; };
|
||||
B897621C25D201F7004F83B2 /* ScrollToBottomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B897621B25D201F7004F83B2 /* ScrollToBottomButton.swift */; };
|
||||
B8AE75A425A6C6A6001A84D2 /* Data+Trimming.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8AE75A325A6C6A6001A84D2 /* Data+Trimming.swift */; };
|
||||
B8AE760B25ABFB5A001A84D2 /* GeneralUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = B8AE760A25ABFB5A001A84D2 /* GeneralUtilities.m */; };
|
||||
B8AE761425ABFBB9001A84D2 /* GeneralUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B8AE760925ABFB00001A84D2 /* GeneralUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B8AF4BB426A5204600583500 /* SendSeedModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8AF4BB326A5204600583500 /* SendSeedModal.swift */; };
|
||||
B8B32021258B1A650020074B /* Contact.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8B32020258B1A650020074B /* Contact.swift */; };
|
||||
B8B32033258B235D0020074B /* Storage+Contacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8B32032258B235D0020074B /* Storage+Contacts.swift */; };
|
||||
|
@ -1283,7 +1280,6 @@
|
|||
B8544E3223D50E4900299F14 /* SNAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SNAppearance.swift; sourceTree = "<group>"; };
|
||||
B8566C62256F55930045A0B9 /* OWSLinkPreview+Conversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OWSLinkPreview+Conversion.swift"; sourceTree = "<group>"; };
|
||||
B8569AC225CB5D2900DBA3DB /* ConversationVC+Interaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConversationVC+Interaction.swift"; sourceTree = "<group>"; };
|
||||
B8569AD225CBA13D00DBA3DB /* MediaTextOverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaTextOverlayView.swift; sourceTree = "<group>"; };
|
||||
B8569AE225CBB19A00DBA3DB /* DocumentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentView.swift; sourceTree = "<group>"; };
|
||||
B86BD08323399ACF000F5AE3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; };
|
||||
B86BD08523399CEF000F5AE3 /* SeedModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedModal.swift; sourceTree = "<group>"; };
|
||||
|
@ -1307,8 +1303,6 @@
|
|||
B894D0742339EDCF00B4D94D /* NukeDataModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NukeDataModal.swift; sourceTree = "<group>"; };
|
||||
B897621B25D201F7004F83B2 /* ScrollToBottomButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollToBottomButton.swift; sourceTree = "<group>"; };
|
||||
B8AE75A325A6C6A6001A84D2 /* Data+Trimming.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Trimming.swift"; sourceTree = "<group>"; };
|
||||
B8AE760925ABFB00001A84D2 /* GeneralUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneralUtilities.h; sourceTree = "<group>"; };
|
||||
B8AE760A25ABFB5A001A84D2 /* GeneralUtilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GeneralUtilities.m; sourceTree = "<group>"; };
|
||||
B8AF4BB326A5204600583500 /* SendSeedModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendSeedModal.swift; sourceTree = "<group>"; };
|
||||
B8B32020258B1A650020074B /* Contact.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Contact.swift; sourceTree = "<group>"; };
|
||||
B8B32032258B235D0020074B /* Storage+Contacts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Storage+Contacts.swift"; sourceTree = "<group>"; };
|
||||
|
@ -2268,7 +2262,6 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
34A8B3502190A40E00218A25 /* MediaAlbumView.swift */,
|
||||
B8569AD225CBA13D00DBA3DB /* MediaTextOverlayView.swift */,
|
||||
3488F9352191CC4000E524CC /* MediaView.swift */,
|
||||
B8041A9425C8FA1D003C2166 /* MediaLoaderView.swift */,
|
||||
B8F5F71925F1B35C003BF8D4 /* MediaPlaceholderView.swift */,
|
||||
|
@ -3350,8 +3343,6 @@
|
|||
C3BBE0C62554F1570050F1E3 /* FixedWidthInteger+BigEndian.swift */,
|
||||
C33FDB7F255A581100E217F9 /* FullTextSearchFinder.swift */,
|
||||
C33FDBC1255A581700E217F9 /* General.swift */,
|
||||
B8AE760925ABFB00001A84D2 /* GeneralUtilities.h */,
|
||||
B8AE760A25ABFB5A001A84D2 /* GeneralUtilities.m */,
|
||||
B82A0C3726B9098200C1BCE3 /* MessageInvalidator.swift */,
|
||||
C3A71D0A2558989C0043A11F /* MessageWrapper.swift */,
|
||||
C3A71D4E25589FF30043A11F /* NSData+messagePadding.h */,
|
||||
|
@ -3901,7 +3892,6 @@
|
|||
C32C5BF8256DC8F6003C73A2 /* OWSDisappearingMessagesJob.h in Headers */,
|
||||
C32C5AAA256DBE8F003C73A2 /* TSIncomingMessage.h in Headers */,
|
||||
B8856D72256F1421001CE70E /* OWSWindowManager.h in Headers */,
|
||||
B8AE761425ABFBB9001A84D2 /* GeneralUtilities.h in Headers */,
|
||||
C32C5B6B256DC357003C73A2 /* OWSDisappearingConfigurationUpdateInfoMessage.h in Headers */,
|
||||
C32C5BBA256DC7E3003C73A2 /* ProfileManagerProtocol.h in Headers */,
|
||||
C3A3A193256E20D4004D228D /* SignalRecipient.h in Headers */,
|
||||
|
@ -4902,7 +4892,6 @@
|
|||
C32C5E5B256DDF45003C73A2 /* OWSStorage.m in Sources */,
|
||||
C32C5E15256DDC78003C73A2 /* SSKPreferences.swift in Sources */,
|
||||
C32C5D9C256DD6DC003C73A2 /* OWSOutgoingReceiptManager.m in Sources */,
|
||||
B8AE760B25ABFB5A001A84D2 /* GeneralUtilities.m in Sources */,
|
||||
C32C5C4F256DCC36003C73A2 /* Storage+OpenGroups.swift in Sources */,
|
||||
C3DA9C0725AE7396008F7C7E /* ConfigurationMessage.swift in Sources */,
|
||||
B8856CEE256F1054001CE70E /* OWSAudioPlayer.m in Sources */,
|
||||
|
|
|
@ -564,14 +564,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
} else {
|
||||
guard let albumView = cell.albumView else { return }
|
||||
let locationInCell = gestureRecognizer.location(in: cell)
|
||||
// Figure out whether the "read more" button was tapped
|
||||
if let overlayView = cell.mediaTextOverlayView {
|
||||
let locationInOverlayView = cell.convert(locationInCell, to: overlayView)
|
||||
if let readMoreButton = overlayView.readMoreButton, readMoreButton.frame.contains(locationInOverlayView) {
|
||||
return showFullText(viewItem) // HACK: This is a dirty way to do this
|
||||
}
|
||||
}
|
||||
// Otherwise, figure out which of the media views was tapped
|
||||
// Figure out which of the media views was tapped
|
||||
let locationInAlbumView = cell.convert(locationInCell, to: albumView)
|
||||
guard let mediaView = albumView.mediaView(forLocation: locationInAlbumView) else { return }
|
||||
if albumView.isMoreItemsView(mediaView: mediaView) && viewItem.mediaAlbumHasFailedAttachment() {
|
||||
|
@ -616,10 +609,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
navigationController!.present(shareVC, animated: true, completion: nil)
|
||||
}
|
||||
case .textOnlyMessage:
|
||||
if let preview = viewItem.linkPreview, let urlAsString = preview.urlString, let url = URL(string: urlAsString) {
|
||||
// Open the link preview URL
|
||||
openURL(url)
|
||||
} else if let reply = viewItem.quotedReply {
|
||||
if let reply = viewItem.quotedReply {
|
||||
// Scroll to the source of the reply
|
||||
guard let indexPath = viewModel.ensureLoadWindowContainsQuotedReply(reply) else { return }
|
||||
messagesTableView.scrollToRow(at: indexPath, at: UITableView.ScrollPosition.middle, animated: true)
|
||||
|
|
|
@ -12,6 +12,7 @@ final class LinkPreviewView : UIView {
|
|||
let isOutgoing = (viewItem!.interaction.interactionType() == .outgoingMessage)
|
||||
switch (isOutgoing, AppModeManager.shared.currentAppMode) {
|
||||
case (true, .dark), (false, .light): return .black
|
||||
case (true, .light): return Colors.grey
|
||||
default: return .white
|
||||
}
|
||||
}()
|
||||
|
@ -58,6 +59,8 @@ final class LinkPreviewView : UIView {
|
|||
return result
|
||||
}()
|
||||
|
||||
var bodyTextView: UITextView?
|
||||
|
||||
// MARK: Settings
|
||||
private static let loaderSize: CGFloat = 24
|
||||
private static let cancelButtonSize: CGFloat = 45
|
||||
|
@ -133,15 +136,7 @@ final class LinkPreviewView : UIView {
|
|||
loader.alpha = (image != nil) ? 0 : 1
|
||||
if image != nil { loader.stopAnimating() } else { loader.startAnimating() }
|
||||
// Title
|
||||
let isSent = (linkPreviewState is LinkPreviewSent)
|
||||
let isOutgoing = (viewItem?.interaction.interactionType() == .outgoingMessage)
|
||||
let textColor: UIColor
|
||||
if isSent && isOutgoing && isLightMode {
|
||||
textColor = .white
|
||||
} else {
|
||||
textColor = isDarkMode ? .white : .black
|
||||
}
|
||||
titleLabel.textColor = textColor
|
||||
titleLabel.textColor = sentLinkPreviewTextColor
|
||||
titleLabel.text = linkPreviewState.title()
|
||||
// Horizontal stack view
|
||||
switch linkPreviewState {
|
||||
|
@ -152,6 +147,7 @@ final class LinkPreviewView : UIView {
|
|||
bodyTextViewContainer.subviews.forEach { $0.removeFromSuperview() }
|
||||
if let viewItem = viewItem {
|
||||
let bodyTextView = VisibleMessageCell.getBodyTextView(for: viewItem, with: maxWidth, textColor: sentLinkPreviewTextColor, searchText: delegate.lastSearchedText, delegate: delegate)
|
||||
self.bodyTextView = bodyTextView
|
||||
bodyTextViewContainer.addSubview(bodyTextView)
|
||||
bodyTextView.pin(to: bodyTextViewContainer, withInset: 12)
|
||||
}
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
import UIKit
|
||||
|
||||
/// Shown over a media message if it has a message body.
|
||||
final class MediaTextOverlayView : UIView {
|
||||
private let viewItem: ConversationViewItem
|
||||
private let albumViewWidth: CGFloat
|
||||
private let delegate: MessageCellDelegate
|
||||
private let textColor: UIColor
|
||||
var readMoreButton: UIButton?
|
||||
|
||||
// MARK: Settings
|
||||
private static let maxHeight: CGFloat = 88;
|
||||
|
||||
// MARK: Lifecycle
|
||||
init(viewItem: ConversationViewItem, albumViewWidth: CGFloat, textColor: UIColor, delegate: MessageCellDelegate) {
|
||||
self.viewItem = viewItem
|
||||
self.albumViewWidth = albumViewWidth
|
||||
self.delegate = delegate
|
||||
self.textColor = textColor
|
||||
super.init(frame: CGRect.zero)
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
preconditionFailure("Use init(text:) instead.")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
preconditionFailure("Use init(text:) instead.")
|
||||
}
|
||||
|
||||
private func setUpViewHierarchy() {
|
||||
guard let message = viewItem.interaction as? TSMessage, let body = message.body, body.count > 0 else { return }
|
||||
// Body label
|
||||
let bodyLabel = UILabel()
|
||||
bodyLabel.numberOfLines = 0
|
||||
bodyLabel.lineBreakMode = .byTruncatingTail
|
||||
bodyLabel.text = given(body) { MentionUtilities.highlightMentions(in: $0, threadID: viewItem.interaction.uniqueThreadId) }
|
||||
bodyLabel.textColor = self.textColor
|
||||
bodyLabel.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
// Content stack view
|
||||
let contentStackView = UIStackView(arrangedSubviews: [ bodyLabel ])
|
||||
contentStackView.axis = .horizontal
|
||||
contentStackView.spacing = Values.smallSpacing
|
||||
addSubview(contentStackView)
|
||||
let inset: CGFloat = 12
|
||||
contentStackView.pin(.left, to: .left, of: self, withInset: inset)
|
||||
contentStackView.pin(.top, to: .top, of: self)
|
||||
contentStackView.pin(.right, to: .right, of: self, withInset: -inset)
|
||||
// Max height
|
||||
bodyLabel.heightAnchor.constraint(lessThanOrEqualToConstant: MediaTextOverlayView.maxHeight).isActive = true
|
||||
// Overflow button
|
||||
let bodyLabelTargetSize = bodyLabel.sizeThatFits(CGSize(width: albumViewWidth - 2 * inset, height: .greatestFiniteMagnitude))
|
||||
if bodyLabelTargetSize.height > MediaTextOverlayView.maxHeight {
|
||||
let readMoreButton = UIButton()
|
||||
self.readMoreButton = readMoreButton
|
||||
readMoreButton.setTitle("Read More", for: UIControl.State.normal)
|
||||
readMoreButton.titleLabel!.font = .boldSystemFont(ofSize: Values.smallFontSize)
|
||||
readMoreButton.setTitleColor(self.textColor, for: UIControl.State.normal)
|
||||
readMoreButton.addTarget(self, action: #selector(readMore), for: UIControl.Event.touchUpInside)
|
||||
addSubview(readMoreButton)
|
||||
readMoreButton.pin(.left, to: .left, of: self, withInset: inset)
|
||||
readMoreButton.pin(.top, to: .bottom, of: contentStackView, withInset: Values.smallSpacing)
|
||||
readMoreButton.pin(.bottom, to: .bottom, of: self, withInset: -Values.smallSpacing)
|
||||
} else {
|
||||
contentStackView.pin(.bottom, to: .bottom, of: self, withInset: -inset)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Interaction
|
||||
@objc private func readMore() {
|
||||
delegate.showFullText(viewItem)
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
|
|||
private var previousX: CGFloat = 0
|
||||
var albumView: MediaAlbumView?
|
||||
var bodyTextView: UITextView?
|
||||
var mediaTextOverlayView: MediaTextOverlayView?
|
||||
// Constraints
|
||||
private lazy var headerViewTopConstraint = headerView.pin(.top, to: .top, of: self, withInset: 1)
|
||||
private lazy var authorLabelHeightConstraint = authorLabel.set(.height, to: 0)
|
||||
|
@ -260,8 +259,9 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
|
|||
let authorLabelSize = authorLabel.sizeThatFits(authorLabelAvailableSpace)
|
||||
authorLabelHeightConstraint.constant = (viewItem.senderName != nil) ? authorLabelSize.height : 0
|
||||
// Message status image view
|
||||
let (image, backgroundColor) = getMessageStatusImage(for: message)
|
||||
let (image, tintColor, backgroundColor) = getMessageStatusImage(for: message)
|
||||
messageStatusImageView.image = image
|
||||
messageStatusImageView.tintColor = tintColor
|
||||
messageStatusImageView.backgroundColor = backgroundColor
|
||||
if let message = message as? TSOutgoingMessage {
|
||||
messageStatusImageView.isHidden = (message.isCallMessage || message.messageState == .sent && thread?.lastInteraction != message)
|
||||
|
@ -318,7 +318,6 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
|
|||
}
|
||||
albumView = nil
|
||||
bodyTextView = nil
|
||||
mediaTextOverlayView = nil
|
||||
let isOutgoing = (viewItem.interaction.interactionType() == .outgoingMessage)
|
||||
switch viewItem.messageCellType {
|
||||
case .textOnlyMessage:
|
||||
|
@ -331,6 +330,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
|
|||
snContentView.addSubview(linkPreviewView)
|
||||
linkPreviewView.pin(to: snContentView)
|
||||
linkPreviewView.layer.mask = bubbleViewMaskLayer
|
||||
self.bodyTextView = linkPreviewView.bodyTextView
|
||||
} else if let openGroupInvitationName = message.openGroupInvitationName, let openGroupInvitationURL = message.openGroupInvitationURL {
|
||||
let openGroupInvitationView = OpenGroupInvitationView(name: openGroupInvitationName, url: openGroupInvitationURL, textColor: bodyLabelTextColor, isOutgoing: isOutgoing)
|
||||
openGroupInvitationView.layer.mask = bubbleViewMaskLayer
|
||||
|
@ -380,11 +380,12 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
|
|||
albumView.layer.mask = bubbleViewMaskLayer
|
||||
stackView.addArrangedSubview(albumView)
|
||||
// Body text view
|
||||
if let message = viewItem.interaction as? TSMessage, let body = message.body, body.count > 0,
|
||||
let delegate = delegate { // delegate should always be set at this point
|
||||
let overlayView = MediaTextOverlayView(viewItem: viewItem, albumViewWidth: size.width, textColor: bodyLabelTextColor, delegate: delegate)
|
||||
self.mediaTextOverlayView = overlayView
|
||||
stackView.addArrangedSubview(overlayView)
|
||||
if let message = viewItem.interaction as? TSMessage, let body = message.body, body.count > 0 {
|
||||
let inset: CGFloat = 12
|
||||
let maxWidth = size.width - 2 * inset
|
||||
let bodyTextView = VisibleMessageCell.getBodyTextView(for: viewItem, with: maxWidth, textColor: bodyLabelTextColor, searchText: delegate?.lastSearchedText, delegate: self)
|
||||
self.bodyTextView = bodyTextView
|
||||
stackView.addArrangedSubview(UIView(wrapping: bodyTextView, withInsets: UIEdgeInsets(top: 0, left: inset, bottom: inset, right: inset)))
|
||||
}
|
||||
unloadContent = { albumView.unloadMedia() }
|
||||
// Constraints
|
||||
|
@ -620,20 +621,33 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private func getMessageStatusImage(for message: TSMessage) -> (image: UIImage?, backgroundColor: UIColor?) {
|
||||
guard let message = message as? TSOutgoingMessage else { return (nil, nil) }
|
||||
private func getMessageStatusImage(for message: TSMessage) -> (image: UIImage?, tintColor: UIColor?, backgroundColor: UIColor?) {
|
||||
guard let message = message as? TSOutgoingMessage else { return (nil, nil, nil) }
|
||||
|
||||
let image: UIImage
|
||||
var tintColor: UIColor? = nil
|
||||
var backgroundColor: UIColor? = nil
|
||||
let status = MessageRecipientStatusUtils.recipientStatus(outgoingMessage: message)
|
||||
|
||||
switch status {
|
||||
case .uploading, .sending: image = #imageLiteral(resourceName: "CircleDotDotDot").asTintedImage(color: Colors.text)!
|
||||
case .sent, .skipped, .delivered: image = #imageLiteral(resourceName: "CircleCheck").asTintedImage(color: Colors.text)!
|
||||
case .read:
|
||||
backgroundColor = isLightMode ? .black : .white
|
||||
image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode")
|
||||
case .failed: image = #imageLiteral(resourceName: "message_status_failed").asTintedImage(color: Colors.destructive)!
|
||||
case .uploading, .sending:
|
||||
image = #imageLiteral(resourceName: "CircleDotDotDot").withRenderingMode(.alwaysTemplate)
|
||||
tintColor = Colors.text
|
||||
|
||||
case .sent, .skipped, .delivered:
|
||||
image = #imageLiteral(resourceName: "CircleCheck").withRenderingMode(.alwaysTemplate)
|
||||
tintColor = Colors.text
|
||||
|
||||
case .read:
|
||||
image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode")
|
||||
backgroundColor = isLightMode ? .black : .white
|
||||
|
||||
case .failed:
|
||||
image = #imageLiteral(resourceName: "message_status_failed").withRenderingMode(.alwaysTemplate)
|
||||
tintColor = Colors.destructive
|
||||
}
|
||||
return (image, backgroundColor)
|
||||
|
||||
return (image, tintColor, backgroundColor)
|
||||
}
|
||||
|
||||
private func getSize(for viewItem: ConversationViewItem) -> CGSize {
|
||||
|
|
|
@ -25,7 +25,7 @@ final class NewConversationButtonSet : UIView {
|
|||
private lazy var newDMLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.translatesAutoresizingMaskIntoConstraints = false
|
||||
result.font = UIFont.systemFont(ofSize: Values.verySmallFontSize)
|
||||
result.font = UIFont.systemFont(ofSize: Values.verySmallFontSize, weight: .bold)
|
||||
result.text = NSLocalizedString("NEW_CONVERSATION_MENU_DIRECT_MESSAGE", comment: "").uppercased()
|
||||
result.textColor = Colors.grey
|
||||
result.textAlignment = .center
|
||||
|
@ -36,7 +36,7 @@ final class NewConversationButtonSet : UIView {
|
|||
private lazy var createClosedGroupLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.translatesAutoresizingMaskIntoConstraints = false
|
||||
result.font = UIFont.systemFont(ofSize: Values.verySmallFontSize)
|
||||
result.font = UIFont.systemFont(ofSize: Values.verySmallFontSize, weight: .bold)
|
||||
result.text = NSLocalizedString("NEW_CONVERSATION_MENU_CLOSED_GROUP", comment: "").uppercased()
|
||||
result.textColor = Colors.grey
|
||||
result.textAlignment = .center
|
||||
|
@ -47,7 +47,7 @@ final class NewConversationButtonSet : UIView {
|
|||
private lazy var joinOpenGroupLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.translatesAutoresizingMaskIntoConstraints = false
|
||||
result.font = UIFont.systemFont(ofSize: Values.verySmallFontSize)
|
||||
result.font = UIFont.systemFont(ofSize: Values.verySmallFontSize, weight: .bold)
|
||||
result.text = NSLocalizedString("NEW_CONVERSATION_MENU_OPEN_GROUP", comment: "").uppercased()
|
||||
result.textColor = Colors.grey
|
||||
result.textAlignment = .center
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import UIKit
|
||||
import SessionUIKit
|
||||
import SessionSnodeKit
|
||||
import SessionMessagingKit
|
||||
|
||||
@objc(LKNukeDataModal)
|
||||
final class NukeDataModal : Modal {
|
||||
|
@ -132,6 +135,7 @@ final class NukeDataModal : Modal {
|
|||
appDelegate.forceSyncConfigurationNowIfNeeded().ensure(on: DispatchQueue.main) {
|
||||
self?.dismiss(animated: true, completion: nil) // Dismiss the loader
|
||||
UserDefaults.removeAll() // Not done in the nuke data implementation as unlinking requires this to happen later
|
||||
General.Cache.cachedEncodedPublicKey = nil // Remove the cached key so it gets re-cached on next access
|
||||
NotificationCenter.default.post(name: .dataNukeRequested, object: nil)
|
||||
}.retainUntilComplete()
|
||||
}
|
||||
|
@ -143,6 +147,7 @@ final class NukeDataModal : Modal {
|
|||
self?.dismiss(animated: true, completion: nil) // Dismiss the loader
|
||||
let potentiallyMaliciousSnodes = confirmations.compactMap { $0.value == false ? $0.key : nil }
|
||||
if potentiallyMaliciousSnodes.isEmpty {
|
||||
General.Cache.cachedEncodedPublicKey = nil // Remove the cached key so it gets re-cached on next access
|
||||
UserDefaults.removeAll() // Not done in the nuke data implementation as unlinking requires this to happen later
|
||||
NotificationCenter.default.post(name: .dataNukeRequested, object: nil)
|
||||
} else {
|
||||
|
|
|
@ -106,6 +106,9 @@ class BaseVC : UIViewController {
|
|||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
if #available(iOS 13.0, *) {
|
||||
SNLog("Current trait collection: \(UITraitCollection.current), previous trait collection: \(previousTraitCollection)")
|
||||
}
|
||||
if LKAppModeUtilities.isSystemDefault {
|
||||
NotificationCenter.default.post(name: .appModeChanged, object: nil)
|
||||
}
|
||||
|
|
|
@ -321,19 +321,31 @@ final class ConversationCell : UITableViewCell {
|
|||
statusIndicatorView.backgroundColor = nil
|
||||
let lastMessage = threadViewModel.lastMessageForInbox
|
||||
if let lastMessage = lastMessage as? TSOutgoingMessage, !lastMessage.isCallMessage {
|
||||
let image: UIImage
|
||||
|
||||
let status = MessageRecipientStatusUtils.recipientStatus(outgoingMessage: lastMessage)
|
||||
|
||||
switch status {
|
||||
case .uploading, .sending: image = #imageLiteral(resourceName: "CircleDotDotDot").asTintedImage(color: Colors.text)!
|
||||
case .sent, .skipped, .delivered: image = #imageLiteral(resourceName: "CircleCheck").asTintedImage(color: Colors.text)!
|
||||
case .read:
|
||||
statusIndicatorView.backgroundColor = isLightMode ? .black : .white
|
||||
image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode")
|
||||
case .failed: image = #imageLiteral(resourceName: "message_status_failed").asTintedImage(color: Colors.text)!
|
||||
case .uploading, .sending:
|
||||
statusIndicatorView.image = #imageLiteral(resourceName: "CircleDotDotDot").withRenderingMode(.alwaysTemplate)
|
||||
statusIndicatorView.tintColor = Colors.text
|
||||
|
||||
case .sent, .skipped, .delivered:
|
||||
statusIndicatorView.image = #imageLiteral(resourceName: "CircleCheck").withRenderingMode(.alwaysTemplate)
|
||||
statusIndicatorView.tintColor = Colors.text
|
||||
|
||||
case .read:
|
||||
statusIndicatorView.image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode")
|
||||
statusIndicatorView.tintColor = nil
|
||||
statusIndicatorView.backgroundColor = (isLightMode ? .black : .white)
|
||||
|
||||
case .failed:
|
||||
statusIndicatorView.image = #imageLiteral(resourceName: "message_status_failed").withRenderingMode(.alwaysTemplate)
|
||||
statusIndicatorView.tintColor = Colors.destructive
|
||||
}
|
||||
statusIndicatorView.image = image
|
||||
|
||||
statusIndicatorView.isHidden = false
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
statusIndicatorView.isHidden = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,16 +83,22 @@ final class UserCell : UITableViewCell {
|
|||
profilePictureView.publicKey = publicKey
|
||||
profilePictureView.update()
|
||||
displayNameLabel.text = Storage.shared.getContact(with: publicKey)?.displayName(for: .regular) ?? publicKey
|
||||
|
||||
switch accessory {
|
||||
case .none: accessoryImageView.isHidden = true
|
||||
case .lock:
|
||||
accessoryImageView.isHidden = false
|
||||
accessoryImageView.image = #imageLiteral(resourceName: "ic_lock_outline").asTintedImage(color: Colors.text.withAlphaComponent(Values.mediumOpacity))!
|
||||
case .tick(let isSelected):
|
||||
accessoryImageView.isHidden = false
|
||||
let icon = isSelected ? #imageLiteral(resourceName: "CircleCheck") : #imageLiteral(resourceName: "Circle")
|
||||
accessoryImageView.image = isDarkMode ? icon : icon.asTintedImage(color: Colors.text)!
|
||||
case .none: accessoryImageView.isHidden = true
|
||||
|
||||
case .lock:
|
||||
accessoryImageView.isHidden = false
|
||||
accessoryImageView.image = #imageLiteral(resourceName: "ic_lock_outline").withRenderingMode(.alwaysTemplate)
|
||||
accessoryImageView.tintColor = Colors.text.withAlphaComponent(Values.mediumOpacity)
|
||||
|
||||
case .tick(let isSelected):
|
||||
let icon: UIImage = (isSelected ? #imageLiteral(resourceName: "CircleCheck") : #imageLiteral(resourceName: "Circle"))
|
||||
accessoryImageView.isHidden = false
|
||||
accessoryImageView.image = icon.withRenderingMode(.alwaysTemplate)
|
||||
accessoryImageView.tintColor = Colors.text
|
||||
}
|
||||
|
||||
let alpha: CGFloat = isZombie ? 0.5 : 1
|
||||
[ profilePictureView, displayNameLabel, accessoryImageView ].forEach { $0.alpha = alpha }
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ extension ConfigurationMessage {
|
|||
hasIsApproved: true,
|
||||
isApproved: contact.isApproved,
|
||||
hasIsBlocked: true,
|
||||
isBlocked: contact.isBlocked,
|
||||
isBlocked: SSKEnvironment.shared.blockingManager.isRecipientIdBlocked(contact.sessionID),
|
||||
hasDidApproveMe: true,
|
||||
didApproveMe: contact.didApproveMe
|
||||
)
|
||||
|
|
|
@ -5,7 +5,6 @@ FOUNDATION_EXPORT const unsigned char SessionMessagingKitVersionString[];
|
|||
|
||||
#import <SessionMessagingKit/AppReadiness.h>
|
||||
#import <SessionMessagingKit/Environment.h>
|
||||
#import <SessionMessagingKit/GeneralUtilities.h>
|
||||
#import <SessionMessagingKit/NotificationsProtocol.h>
|
||||
#import <SessionMessagingKit/NSData+messagePadding.h>
|
||||
#import <SessionMessagingKit/OWSAudioPlayer.h>
|
||||
|
|
|
@ -18,6 +18,7 @@ public final class OpenGroupAPIV2 : NSObject {
|
|||
}()
|
||||
|
||||
// MARK: Settings
|
||||
public static let legacyDefaultServerDNS = "open.getsession.org"
|
||||
public static let defaultServer = "http://116.203.70.33"
|
||||
public static let defaultServerPublicKey = "a03c383cf63c3c4efe67acc52112a6dd734b3a946b9545f488aaa93da7991238"
|
||||
|
||||
|
|
|
@ -29,12 +29,53 @@ public final class OpenGroupManagerV2 : NSObject {
|
|||
}
|
||||
|
||||
// MARK: Adding & Removing
|
||||
|
||||
public func hasExistingOpenGroup(room: String, server: String, publicKey: String, using transaction: YapDatabaseReadWriteTransaction) -> Bool {
|
||||
let schemeFreeServer: String = (server.starts(with: "https://") ? server.substring(from: "https://".count) : server.substring(from: "http://".count))
|
||||
let schemeFreeDefaultServer: String = OpenGroupAPIV2.defaultServer.substring(from: "http://".count)
|
||||
var serverOptions: Set<String> = Set([
|
||||
schemeFreeServer,
|
||||
"http://\(schemeFreeServer)",
|
||||
"https://\(schemeFreeServer)"
|
||||
])
|
||||
|
||||
if schemeFreeServer == OpenGroupAPIV2.legacyDefaultServerDNS {
|
||||
let defaultServerOptions: Set<String> = Set([
|
||||
schemeFreeDefaultServer,
|
||||
OpenGroupAPIV2.defaultServer,
|
||||
"https://\(schemeFreeDefaultServer)"
|
||||
])
|
||||
serverOptions = serverOptions.union(defaultServerOptions)
|
||||
}
|
||||
else if schemeFreeServer == schemeFreeDefaultServer {
|
||||
let legacyServerOptions: Set<String> = Set([
|
||||
OpenGroupAPIV2.legacyDefaultServerDNS,
|
||||
"http://\(OpenGroupAPIV2.legacyDefaultServerDNS)",
|
||||
"https://\(OpenGroupAPIV2.legacyDefaultServerDNS)"
|
||||
])
|
||||
serverOptions = serverOptions.union(legacyServerOptions)
|
||||
}
|
||||
|
||||
// First check if there is no poller for the specified server
|
||||
if serverOptions.first(where: { OpenGroupManagerV2.shared.pollers[$0] != nil }) == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// Then check if there is an existing open group thread
|
||||
let hasExistingThread: Bool = serverOptions.contains(where: { serverName in
|
||||
let groupId: Data = LKGroupUtilities.getEncodedOpenGroupIDAsData("\(serverName).\(room)")
|
||||
|
||||
return (TSGroupThread.fetch(groupId: groupId, transaction: transaction) != nil)
|
||||
})
|
||||
|
||||
return hasExistingThread
|
||||
}
|
||||
|
||||
public func add(room: String, server: String, publicKey: String, using transaction: Any) -> Promise<Void> {
|
||||
// If we are currently polling for this server and already have a TSGroupThread for this room the do nothing
|
||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||
let groupId: Data = LKGroupUtilities.getEncodedOpenGroupIDAsData("\(server).\(room)")
|
||||
|
||||
if OpenGroupManagerV2.shared.pollers[server] != nil && TSGroupThread.fetch(groupId: groupId, transaction: transaction) != nil {
|
||||
if hasExistingOpenGroup(room: room, server: server, publicKey: publicKey, using: transaction) {
|
||||
SNLog("Ignoring join open group attempt (already joined)")
|
||||
return Promise.value(())
|
||||
}
|
||||
|
@ -126,7 +167,10 @@ public final class OpenGroupManagerV2 : NSObject {
|
|||
// https://143.198.213.225:443/main?public_key=658d29b91892a2389505596b135e76a53db6e11d613a51dbd3d0816adffb231c
|
||||
// 143.198.213.255:80/main?public_key=658d29b91892a2389505596b135e76a53db6e11d613a51dbd3d0816adffb231c
|
||||
let useTLS = (url.scheme == "https")
|
||||
let updatedPath = (url.path.starts(with: "/r/") ? url.path.substring(from: 2) : url.path)
|
||||
|
||||
// If there is no scheme then the host is included in the path (so handle that case)
|
||||
let hostFreePath = (url.host != nil || !url.path.starts(with: host) ? url.path : url.path.substring(from: host.count))
|
||||
let updatedPath = (hostFreePath.starts(with: "/r/") ? hostFreePath.substring(from: 2) : hostFreePath)
|
||||
let room = String(updatedPath.dropFirst()) // Drop the leading slash
|
||||
let queryParts = query.split(separator: "=")
|
||||
guard !room.isEmpty && !room.contains("/"), queryParts.count == 2, queryParts[0] == "public_key" else { return nil }
|
||||
|
|
|
@ -48,6 +48,7 @@ public final class OpenGroupPollerV2 : NSObject {
|
|||
guard let self = self else { return }
|
||||
self.isPolling = false
|
||||
bodies.forEach { self.handleCompactPollBody($0, isBackgroundPoll: isBackgroundPoll) }
|
||||
SNLog("Open group polling finished for \(self.server).")
|
||||
seal.fulfill(())
|
||||
}.catch(on: OpenGroupAPIV2.workQueue) { error in
|
||||
SNLog("Open group polling failed due to error: \(error).")
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
import Foundation
|
||||
|
||||
public enum General {
|
||||
public enum Cache {
|
||||
public static var cachedEncodedPublicKey: String? = nil
|
||||
}
|
||||
}
|
||||
|
||||
@objc(SNGeneralUtilities)
|
||||
public class GeneralUtilities: NSObject {
|
||||
@objc public static func getUserPublicKey() -> String {
|
||||
return getUserHexEncodedPublicKey()
|
||||
}
|
||||
}
|
||||
|
||||
public func getUserHexEncodedPublicKey() -> String {
|
||||
if let cachedKey: String = General.Cache.cachedEncodedPublicKey { return cachedKey }
|
||||
|
||||
if let keyPair = OWSIdentityManager.shared().identityKeyPair() { // Can be nil under some circumstances
|
||||
General.Cache.cachedEncodedPublicKey = keyPair.hexEncodedPublicKey
|
||||
return keyPair.hexEncodedPublicKey
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SNGeneralUtilities : NSObject
|
||||
|
||||
+ (NSString *)getUserPublicKey;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -1,16 +0,0 @@
|
|||
#import <SessionUtilitiesKit/SessionUtilitiesKit.h>
|
||||
#import "GeneralUtilities.h"
|
||||
#import "OWSIdentityManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation SNGeneralUtilities
|
||||
|
||||
+ (NSString *)getUserPublicKey
|
||||
{
|
||||
return OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -13,14 +13,14 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
|||
// to check if this is the only message request thread (group threads can't be message requests
|
||||
// so just ignore those and if the user has hidden message requests then we want to show the
|
||||
// notification regardless of how many message requests there are)
|
||||
if !thread.isGroupThread() && thread.isMessageRequest() && !CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||
if !thread.isGroupThread() && thread.isMessageRequest(using: transaction) && !CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||
let threads = transaction.ext(TSThreadDatabaseViewExtensionName) as! YapDatabaseViewTransaction
|
||||
let numMessageRequests = threads.numberOfItems(inGroup: TSMessageRequestGroup)
|
||||
|
||||
// Allow this to show a notification if there are no message requests (ie. this is the first one)
|
||||
guard numMessageRequests == 0 else { return }
|
||||
}
|
||||
else if thread.isMessageRequest() && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||
else if thread.isMessageRequest(using: transaction) && CurrentAppContext().appUserDefaults()[.hasHiddenMessageRequests] {
|
||||
// If there are other interactions on this thread already then don't show the notification
|
||||
if thread.numberOfInteractions(with: transaction) > 1 { return }
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
|||
}
|
||||
|
||||
let senderPublicKey = incomingMessage.authorId
|
||||
let userPublicKey = SNGeneralUtilities.getUserPublicKey()
|
||||
let userPublicKey = GeneralUtilities.getUserPublicKey()
|
||||
guard senderPublicKey != userPublicKey else {
|
||||
// Ignore PNs for messages sent by the current user
|
||||
// after handling the message. Otherwise the closed
|
||||
|
@ -85,7 +85,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
|||
|
||||
// If it's a message request then overwrite the body to be something generic (only show a notification
|
||||
// when receiving a new message request if there aren't any others or the user had hidden them)
|
||||
if thread.isMessageRequest() {
|
||||
if thread.isMessageRequest(using: transaction) {
|
||||
notificationContent.title = "Session"
|
||||
notificationContent.body = "MESSAGE_REQUESTS_NOTIFICATION".localized()
|
||||
}
|
||||
|
@ -93,8 +93,16 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
|||
// Add request
|
||||
let identifier = incomingMessage.notificationIdentifier ?? UUID().uuidString
|
||||
let request = UNNotificationRequest(identifier: identifier, content: notificationContent, trigger: nil)
|
||||
SNLog("Add remote notification request")
|
||||
UNUserNotificationCenter.current().add(request)
|
||||
SNLog("Add remote notification request: \(notificationContent.body)")
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
UNUserNotificationCenter.current().add(request) { error in
|
||||
if let error = error {
|
||||
SNLog("Failed to add notification request due to error:\(error)")
|
||||
}
|
||||
semaphore.signal()
|
||||
}
|
||||
semaphore.wait()
|
||||
SNLog("Finish adding remote notification request")
|
||||
}
|
||||
|
||||
public func cancelNotification(_ identifier: String) {
|
||||
|
|
|
@ -43,7 +43,10 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
|||
let envelope = try? MessageWrapper.unwrap(data: data), let envelopeAsData = try? envelope.serializedData() else {
|
||||
return self.handleFailure(for: notificationContent)
|
||||
}
|
||||
Storage.write { transaction in // Intentionally capture self
|
||||
// HACK: It is important to use writeSync() here to avoid a race condition
|
||||
// where the completeSilenty() is called before the local notification request
|
||||
// is added to notification center.
|
||||
Storage.writeSync { transaction in // Intentionally capture self
|
||||
do {
|
||||
let (message, proto) = try MessageReceiver.parse(envelopeAsData, openGroupMessageServerID: nil, using: transaction)
|
||||
switch message {
|
||||
|
|
|
@ -204,7 +204,11 @@ public enum OnionRequestAPI {
|
|||
} else {
|
||||
return buildPaths(reusing: []).map2 { paths in
|
||||
if let snode = snode {
|
||||
return paths.filter { !$0.contains(snode) }.randomElement()!
|
||||
if let path = paths.filter({ !$0.contains(snode) }).randomElement() {
|
||||
return path
|
||||
} else {
|
||||
throw Error.insufficientSnodes
|
||||
}
|
||||
} else {
|
||||
return paths.randomElement()!
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue