|
|
@ -28,10 +28,16 @@ public class LongTextViewController: OWSViewController {
|
|
|
|
|
|
|
|
|
|
|
|
let viewItem: ConversationViewItem
|
|
|
|
let viewItem: ConversationViewItem
|
|
|
|
|
|
|
|
|
|
|
|
let messageBody: String
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var messageTextView: UITextView!
|
|
|
|
var messageTextView: UITextView!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var displayableText: DisplayableText? {
|
|
|
|
|
|
|
|
return viewItem.displayableBodyText
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fullText: String {
|
|
|
|
|
|
|
|
return displayableText?.fullText ?? ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Initializers
|
|
|
|
// MARK: Initializers
|
|
|
|
|
|
|
|
|
|
|
|
@available(*, unavailable, message:"use other constructor instead.")
|
|
|
|
@available(*, unavailable, message:"use other constructor instead.")
|
|
|
@ -42,23 +48,9 @@ public class LongTextViewController: OWSViewController {
|
|
|
|
@objc
|
|
|
|
@objc
|
|
|
|
public required init(viewItem: ConversationViewItem) {
|
|
|
|
public required init(viewItem: ConversationViewItem) {
|
|
|
|
self.viewItem = viewItem
|
|
|
|
self.viewItem = viewItem
|
|
|
|
|
|
|
|
|
|
|
|
self.messageBody = LongTextViewController.displayableText(viewItem: viewItem)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
super.init(nibName: nil, bundle: nil)
|
|
|
|
super.init(nibName: nil, bundle: nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private class func displayableText(viewItem: ConversationViewItem) -> String {
|
|
|
|
|
|
|
|
guard viewItem.hasBodyText else {
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
guard let displayableText = viewItem.displayableBodyText else {
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let messageBody = displayableText.fullText
|
|
|
|
|
|
|
|
return messageBody
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: View Lifecycle
|
|
|
|
// MARK: View Lifecycle
|
|
|
|
|
|
|
|
|
|
|
|
public override func viewDidLoad() {
|
|
|
|
public override func viewDidLoad() {
|
|
|
@ -137,8 +129,13 @@ public class LongTextViewController: OWSViewController {
|
|
|
|
messageTextView.showsVerticalScrollIndicator = true
|
|
|
|
messageTextView.showsVerticalScrollIndicator = true
|
|
|
|
messageTextView.isUserInteractionEnabled = true
|
|
|
|
messageTextView.isUserInteractionEnabled = true
|
|
|
|
messageTextView.textColor = Theme.primaryColor
|
|
|
|
messageTextView.textColor = Theme.primaryColor
|
|
|
|
messageTextView.dataDetectorTypes = kOWSAllowedDataDetectorTypes
|
|
|
|
if let displayableText = displayableText {
|
|
|
|
messageTextView.text = messageBody
|
|
|
|
messageTextView.text = fullText
|
|
|
|
|
|
|
|
messageTextView.ensureShouldLinkifyText(displayableText.shouldAllowLinkification)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
owsFailDebug("displayableText was unexpectedly nil")
|
|
|
|
|
|
|
|
messageTextView.text = ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RADAR #18669
|
|
|
|
// RADAR #18669
|
|
|
|
// https://github.com/lionheart/openradar-mirror/issues/18669
|
|
|
|
// https://github.com/lionheart/openradar-mirror/issues/18669
|
|
|
@ -153,8 +150,9 @@ public class LongTextViewController: OWSViewController {
|
|
|
|
|
|
|
|
|
|
|
|
view.addSubview(messageTextView)
|
|
|
|
view.addSubview(messageTextView)
|
|
|
|
messageTextView.autoPinEdge(toSuperviewEdge: .top)
|
|
|
|
messageTextView.autoPinEdge(toSuperviewEdge: .top)
|
|
|
|
messageTextView.autoPinEdge(toSuperviewMargin: .leading)
|
|
|
|
messageTextView.autoPinEdge(toSuperviewEdge: .leading)
|
|
|
|
messageTextView.autoPinEdge(toSuperviewMargin: .trailing)
|
|
|
|
messageTextView.autoPinEdge(toSuperviewEdge: .trailing)
|
|
|
|
|
|
|
|
messageTextView.textContainerInset = UIEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
|
|
|
|
|
|
|
|
|
|
|
|
let footer = UIToolbar()
|
|
|
|
let footer = UIToolbar()
|
|
|
|
view.addSubview(footer)
|
|
|
|
view.addSubview(footer)
|
|
|
@ -172,6 +170,6 @@ public class LongTextViewController: OWSViewController {
|
|
|
|
// MARK: - Actions
|
|
|
|
// MARK: - Actions
|
|
|
|
|
|
|
|
|
|
|
|
@objc func shareButtonPressed() {
|
|
|
|
@objc func shareButtonPressed() {
|
|
|
|
AttachmentSharing.showShareUI(forText: messageBody)
|
|
|
|
AttachmentSharing.showShareUI(forText: fullText)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|