mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-01 05:36:57 +02:00
Merge commit '98594fd01fc18ee18fde60a45542f1b4d7040c41' into feature/4699_basis_update_element
* commit '98594fd01fc18ee18fde60a45542f1b4d7040c41': (59 commits) finish version++ Tidy up event formatter issues. version++ changelog.d: Upgrade MatrixSDK version ([v0.26.9](https://github.com/matrix-org/matrix-ios-sdk/releases/tag/v0.26.9)). Translated using Weblate (Russian) Translated using Weblate (Chinese (Traditional)) Translated using Weblate (Albanian) Translated using Weblate (Hungarian) Translated using Weblate (Chinese (Traditional)) Translated using Weblate (Chinese (Traditional)) Translated using Weblate (Chinese (Traditional)) Translated using Weblate (German) Translated using Weblate (Slovak) Translated using Weblate (Chinese (Traditional)) Translated using Weblate (Indonesian) Translated using Weblate (Estonian) Translated using Weblate (Ukrainian) Translated using Weblate (Italian) Translated using Weblate (Chinese (Traditional)) Translated using Weblate (German) ... # Conflicts: # Config/AppVersion.xcconfig # Riot/Utils/EventFormatter.m # fastlane/Fastfile
This commit is contained in:
@@ -14,46 +14,52 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import HTMLParser
|
||||
import UIKit
|
||||
import WysiwygComposer
|
||||
|
||||
extension RoomViewController {
|
||||
// MARK: - Override
|
||||
open override func mention(_ roomMember: MXRoomMember) {
|
||||
guard let inputToolbar = inputToolbar else {
|
||||
return
|
||||
}
|
||||
|
||||
let newAttributedString = NSMutableAttributedString(attributedString: inputToolbar.attributedTextMessage)
|
||||
|
||||
if inputToolbar.attributedTextMessage.length > 0 {
|
||||
if #available(iOS 15.0, *) {
|
||||
newAttributedString.append(PillsFormatter.mentionPill(withRoomMember: roomMember,
|
||||
isHighlighted: false,
|
||||
font: inputToolbar.textDefaultFont))
|
||||
} else {
|
||||
newAttributedString.appendString(roomMember.displayname.count > 0 ? roomMember.displayname : roomMember.userId)
|
||||
}
|
||||
newAttributedString.appendString(" ")
|
||||
} else if roomMember.userId == self.mainSession.myUser.userId {
|
||||
newAttributedString.appendString("/me ")
|
||||
if let wysiwygInputToolbar, wysiwygInputToolbar.textFormattingEnabled {
|
||||
wysiwygInputToolbar.mention(roomMember)
|
||||
wysiwygInputToolbar.becomeFirstResponder()
|
||||
} else {
|
||||
if #available(iOS 15.0, *) {
|
||||
newAttributedString.append(PillsFormatter.mentionPill(withRoomMember: roomMember,
|
||||
isHighlighted: false,
|
||||
font: inputToolbar.textDefaultFont))
|
||||
} else {
|
||||
newAttributedString.appendString(roomMember.displayname.count > 0 ? roomMember.displayname : roomMember.userId)
|
||||
}
|
||||
newAttributedString.appendString(": ")
|
||||
}
|
||||
guard let attributedText = inputToolbarView.attributedTextMessage else { return }
|
||||
let newAttributedString = NSMutableAttributedString(attributedString: attributedText)
|
||||
|
||||
inputToolbar.attributedTextMessage = newAttributedString
|
||||
inputToolbar.becomeFirstResponder()
|
||||
if attributedText.length > 0 {
|
||||
if #available(iOS 15.0, *) {
|
||||
newAttributedString.append(PillsFormatter.mentionPill(withRoomMember: roomMember,
|
||||
isHighlighted: false,
|
||||
font: inputToolbarView.defaultFont))
|
||||
} else {
|
||||
newAttributedString.appendString(roomMember.displayname.count > 0 ? roomMember.displayname : roomMember.userId)
|
||||
}
|
||||
newAttributedString.appendString(" ")
|
||||
} else if roomMember.userId == self.mainSession.myUser.userId {
|
||||
newAttributedString.appendString("/me ")
|
||||
newAttributedString.addAttribute(.font,
|
||||
value: inputToolbarView.defaultFont,
|
||||
range: .init(location: 0, length: newAttributedString.length))
|
||||
} else {
|
||||
if #available(iOS 15.0, *) {
|
||||
newAttributedString.append(PillsFormatter.mentionPill(withRoomMember: roomMember,
|
||||
isHighlighted: false,
|
||||
font: inputToolbarView.defaultFont))
|
||||
} else {
|
||||
newAttributedString.appendString(roomMember.displayname.count > 0 ? roomMember.displayname : roomMember.userId)
|
||||
}
|
||||
newAttributedString.appendString(": ")
|
||||
}
|
||||
|
||||
inputToolbarView.attributedTextMessage = newAttributedString
|
||||
inputToolbarView.becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Send the formatted text message and its raw counterpat to the room
|
||||
/// Send the formatted text message and its raw counterpart to the room
|
||||
///
|
||||
/// - Parameter rawTextMsg: the raw text message
|
||||
/// - Parameter htmlMsg: the html text message
|
||||
@@ -369,6 +375,48 @@ extension RoomViewController: ComposerLinkActionBridgePresenterDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - PermalinkReplacer
|
||||
extension RoomViewController: PermalinkReplacer {
|
||||
public func replacementForLink(_ url: String, text: String) -> NSAttributedString? {
|
||||
guard #available(iOS 15.0, *),
|
||||
let url = URL(string: url),
|
||||
let session = roomDataSource.mxSession,
|
||||
let eventFormatter = roomDataSource.eventFormatter,
|
||||
let roomState = roomDataSource.roomState else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return PillsFormatter.mentionPill(withUrl: url,
|
||||
andLabel: text,
|
||||
session: session,
|
||||
eventFormatter: eventFormatter,
|
||||
roomState: roomState)
|
||||
}
|
||||
|
||||
public func postProcessMarkdown(in attributedString: NSAttributedString) -> NSAttributedString {
|
||||
guard #available(iOS 15.0, *),
|
||||
let roomDataSource,
|
||||
let session = roomDataSource.mxSession,
|
||||
let eventFormatter = roomDataSource.eventFormatter,
|
||||
let roomState = roomDataSource.roomState else {
|
||||
return attributedString
|
||||
}
|
||||
return PillsFormatter.insertPills(in: attributedString,
|
||||
withSession: session,
|
||||
eventFormatter: eventFormatter,
|
||||
roomState: roomState,
|
||||
font: inputToolbarView.defaultFont)
|
||||
}
|
||||
|
||||
public func restoreMarkdown(in attributedString: NSAttributedString) -> String {
|
||||
if #available(iOS 15.0, *) {
|
||||
return PillsFormatter.stringByReplacingPills(in: attributedString, mode: .markdown)
|
||||
} else {
|
||||
return attributedString.string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - VoiceBroadcast
|
||||
extension RoomViewController {
|
||||
@objc func stopUncompletedVoiceBroadcastIfNeeded() {
|
||||
|
||||
Reference in New Issue
Block a user