mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 15:22:39 +00:00
Update the room description in the rooms list in case of live broadcast (incoming or outgoing) (#7160)
This commit is contained in:
parent
710b09ed44
commit
3e9b3aa877
17 changed files with 119 additions and 10 deletions
|
@ -2698,6 +2698,9 @@ To enable access, tap Settings> Location and select Always";
|
||||||
"notice_crypto_error_unknown_inbound_session_id" = "The sender's session has not sent us the keys for this message.";
|
"notice_crypto_error_unknown_inbound_session_id" = "The sender's session has not sent us the keys for this message.";
|
||||||
"notice_sticker" = "sticker";
|
"notice_sticker" = "sticker";
|
||||||
"notice_in_reply_to" = "In reply to";
|
"notice_in_reply_to" = "In reply to";
|
||||||
|
"notice_voice_broadcast_live" = "Live broadcast";
|
||||||
|
"notice_voice_broadcast_ended" = "%@ ended a voice broadcast.";
|
||||||
|
"notice_voice_broadcast_ended_by_you" = "You ended a voice broadcast.";
|
||||||
|
|
||||||
// room display name
|
// room display name
|
||||||
"room_displayname_empty_room" = "Empty room";
|
"room_displayname_empty_room" = "Empty room";
|
||||||
|
|
|
@ -4323,6 +4323,18 @@ public class VectorL10n: NSObject {
|
||||||
public static var noticeVideoAttachment: String {
|
public static var noticeVideoAttachment: String {
|
||||||
return VectorL10n.tr("Vector", "notice_video_attachment")
|
return VectorL10n.tr("Vector", "notice_video_attachment")
|
||||||
}
|
}
|
||||||
|
/// %@ ended a voice broadcast.
|
||||||
|
public static func noticeVoiceBroadcastEnded(_ p1: String) -> String {
|
||||||
|
return VectorL10n.tr("Vector", "notice_voice_broadcast_ended", p1)
|
||||||
|
}
|
||||||
|
/// You ended a voice broadcast.
|
||||||
|
public static var noticeVoiceBroadcastEndedByYou: String {
|
||||||
|
return VectorL10n.tr("Vector", "notice_voice_broadcast_ended_by_you")
|
||||||
|
}
|
||||||
|
/// Live broadcast
|
||||||
|
public static var noticeVoiceBroadcastLive: String {
|
||||||
|
return VectorL10n.tr("Vector", "notice_voice_broadcast_live")
|
||||||
|
}
|
||||||
/// Always notify
|
/// Always notify
|
||||||
public static var notificationSettingsAlwaysNotify: String {
|
public static var notificationSettingsAlwaysNotify: String {
|
||||||
return VectorL10n.tr("Vector", "notification_settings_always_notify")
|
return VectorL10n.tr("Vector", "notification_settings_always_notify")
|
||||||
|
|
|
@ -80,10 +80,7 @@
|
||||||
// Manage lastEventAttributedTextMessage optional property
|
// Manage lastEventAttributedTextMessage optional property
|
||||||
if (!roomCellData.roomSummary.spaceChildInfo && [roomCellData respondsToSelector:@selector(lastEventAttributedTextMessage)])
|
if (!roomCellData.roomSummary.spaceChildInfo && [roomCellData respondsToSelector:@selector(lastEventAttributedTextMessage)])
|
||||||
{
|
{
|
||||||
// Force the default text color for the last message (cancel highlighted message color)
|
self.lastEventDescription.attributedText = roomCellData.lastEventAttributedTextMessage;
|
||||||
NSMutableAttributedString *lastEventDescription = [[NSMutableAttributedString alloc] initWithAttributedString:roomCellData.lastEventAttributedTextMessage];
|
|
||||||
[lastEventDescription addAttribute:NSForegroundColorAttributeName value:ThemeService.shared.theme.textSecondaryColor range:NSMakeRange(0, lastEventDescription.length)];
|
|
||||||
self.lastEventDescription.attributedText = lastEventDescription;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,3 +16,4 @@
|
||||||
#import "MXKImageView.h"
|
#import "MXKImageView.h"
|
||||||
#import "MXKRoomBubbleCellData.h"
|
#import "MXKRoomBubbleCellData.h"
|
||||||
#import "UserIndicatorCancel.h"
|
#import "UserIndicatorCancel.h"
|
||||||
|
#import "VoiceBroadcastInfo.h"
|
||||||
|
|
|
@ -546,6 +546,40 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - MXRoomSummaryUpdating
|
#pragma mark - MXRoomSummaryUpdating
|
||||||
|
- (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary withLastEvent:(MXEvent *)event eventState:(MXRoomState *)eventState roomState:(MXRoomState *)roomState {
|
||||||
|
|
||||||
|
// Do not display voice broadcast chunk in last message.
|
||||||
|
if (event.eventType == MXEventTypeRoomMessage && event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType])
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update last message if we have a voice broadcast in the room.
|
||||||
|
if ([event.type isEqualToString:VoiceBroadcastSettings.voiceBroadcastInfoContentKeyType])
|
||||||
|
{
|
||||||
|
return [self session:session updateRoomSummary:summary withVoiceBroadcastInfoStateEvent:event roomState:roomState];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MXEvent *stateEvent = [roomState stateEventsWithType:VoiceBroadcastSettings.voiceBroadcastInfoContentKeyType].lastObject;
|
||||||
|
if (stateEvent && ![VoiceBroadcastInfo isStoppedFor:[VoiceBroadcastInfo modelFromJSON: stateEvent.content].state])
|
||||||
|
{
|
||||||
|
return [self session:session updateRoomSummary:summary withVoiceBroadcastInfoStateEvent:stateEvent roomState:roomState];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL updated = [super session:session updateRoomSummary:summary withLastEvent:event eventState:eventState roomState:roomState];
|
||||||
|
|
||||||
|
if (updated) {
|
||||||
|
// Force the default text color for the last message (cancel highlighted message color)
|
||||||
|
NSMutableAttributedString *lastEventDescription = [[NSMutableAttributedString alloc] initWithAttributedString:summary.lastMessage.attributedText];
|
||||||
|
[lastEventDescription addAttribute:NSForegroundColorAttributeName value:ThemeService.shared.theme.textSecondaryColor range:NSMakeRange(0, lastEventDescription.length)];
|
||||||
|
summary.lastMessage.attributedText = lastEventDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
return updated;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary withStateEvents:(NSArray<MXEvent *> *)stateEvents roomState:(MXRoomState *)roomState
|
- (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary withStateEvents:(NSArray<MXEvent *> *)stateEvents roomState:(MXRoomState *)roomState
|
||||||
{
|
{
|
||||||
BOOL updated = [super session:session updateRoomSummary:summary withStateEvents:stateEvents roomState:roomState];
|
BOOL updated = [super session:session updateRoomSummary:summary withStateEvents:stateEvents roomState:roomState];
|
||||||
|
@ -569,6 +603,67 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary withVoiceBroadcastInfoStateEvent:(MXEvent *)stateEvent roomState:(MXRoomState *)roomState
|
||||||
|
{
|
||||||
|
[summary updateLastMessage:[[MXRoomLastMessage alloc] initWithEvent:stateEvent]];
|
||||||
|
if (summary.lastMessage.others == nil)
|
||||||
|
{
|
||||||
|
summary.lastMessage.others = [NSMutableDictionary dictionary];
|
||||||
|
}
|
||||||
|
summary.lastMessage.others[@"lastEventDate"] = [self dateStringFromEvent:stateEvent withTime:YES];
|
||||||
|
|
||||||
|
NSAttributedString *attachmentString = nil;
|
||||||
|
UIColor *textColor;
|
||||||
|
if ([VoiceBroadcastInfo isStoppedFor:[VoiceBroadcastInfo modelFromJSON: stateEvent.content].state])
|
||||||
|
{
|
||||||
|
textColor = ThemeService.shared.theme.textSecondaryColor;
|
||||||
|
NSString *senderDisplayName;
|
||||||
|
if ([stateEvent.stateKey isEqualToString:session.myUser.userId])
|
||||||
|
{
|
||||||
|
summary.lastMessage.text = VectorL10n.noticeVoiceBroadcastEndedByYou;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
senderDisplayName = [self senderDisplayNameForEvent:stateEvent withRoomState:roomState];
|
||||||
|
summary.lastMessage.text = [VectorL10n noticeVoiceBroadcastEnded:senderDisplayName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textColor = ThemeService.shared.theme.colors.alert;
|
||||||
|
UIImage *liveImage = AssetImages.voiceBroadcastLive.image;
|
||||||
|
|
||||||
|
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
|
||||||
|
attachment.image = [liveImage imageWithTintColor:textColor renderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||||
|
attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];
|
||||||
|
|
||||||
|
summary.lastMessage.text = VectorL10n.noticeVoiceBroadcastLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute the attribute text message
|
||||||
|
NSMutableAttributedString *lastMessage;
|
||||||
|
if (attachmentString)
|
||||||
|
{
|
||||||
|
lastMessage = [[NSMutableAttributedString alloc] initWithAttributedString:attachmentString];
|
||||||
|
// Change base line
|
||||||
|
[lastMessage addAttribute:NSBaselineOffsetAttributeName value:@(-3.0f) range:NSMakeRange(0, attachmentString.length)];
|
||||||
|
|
||||||
|
NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", summary.lastMessage.text]];
|
||||||
|
[lastMessage appendAttributedString:attributedText];
|
||||||
|
[lastMessage addAttribute:NSFontAttributeName value:self.defaultTextFont range:NSMakeRange(0, lastMessage.length)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSAttributedString *attributedText = [self renderString:summary.lastMessage.text forEvent:stateEvent];
|
||||||
|
lastMessage = [[NSMutableAttributedString alloc] initWithAttributedString:attributedText];
|
||||||
|
}
|
||||||
|
|
||||||
|
[lastMessage addAttribute:NSForegroundColorAttributeName value:textColor range:NSMakeRange(0, lastMessage.length)];
|
||||||
|
summary.lastMessage.attributedText = lastMessage;
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSAttributedString *)redactedMessageReplacementAttributedString
|
- (NSAttributedString *)redactedMessageReplacementAttributedString
|
||||||
{
|
{
|
||||||
UIFont *font = self.defaultTextFont;
|
UIFont *font = self.defaultTextFont;
|
||||||
|
|
|
@ -76,4 +76,4 @@ targets:
|
||||||
excludes:
|
excludes:
|
||||||
- "**/*.md" # excludes all files with the .md extension
|
- "**/*.md" # excludes all files with the .md extension
|
||||||
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
||||||
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/VoiceBroadcastSettings.swift
|
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/MatrixSDK
|
||||||
|
|
|
@ -82,4 +82,4 @@ targets:
|
||||||
excludes:
|
excludes:
|
||||||
- "**/*.md" # excludes all files with the .md extension
|
- "**/*.md" # excludes all files with the .md extension
|
||||||
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
||||||
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/VoiceBroadcastSettings.swift
|
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/MatrixSDK
|
||||||
|
|
|
@ -63,7 +63,7 @@ targets:
|
||||||
- path: ../Riot/Modules/Analytics/AnalyticsScreen.swift
|
- path: ../Riot/Modules/Analytics/AnalyticsScreen.swift
|
||||||
- path: ../Riot/Modules/LocationSharing/LocationAuthorizationStatus.swift
|
- path: ../Riot/Modules/LocationSharing/LocationAuthorizationStatus.swift
|
||||||
- path: ../Riot/Modules/QRCode/QRCodeGenerator.swift
|
- path: ../Riot/Modules/QRCode/QRCodeGenerator.swift
|
||||||
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/VoiceBroadcastInfoState.swift
|
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/MatrixSDK/VoiceBroadcastInfoState.swift
|
||||||
- path: ../Riot/Assets/en.lproj/Untranslated.strings
|
- path: ../Riot/Assets/en.lproj/Untranslated.strings
|
||||||
buildPhase: resources
|
buildPhase: resources
|
||||||
- path: ../Riot/Assets/Images.xcassets
|
- path: ../Riot/Assets/Images.xcassets
|
||||||
|
|
|
@ -72,7 +72,7 @@ targets:
|
||||||
- path: ../Riot/Modules/Analytics/AnalyticsScreen.swift
|
- path: ../Riot/Modules/Analytics/AnalyticsScreen.swift
|
||||||
- path: ../Riot/Modules/LocationSharing/LocationAuthorizationStatus.swift
|
- path: ../Riot/Modules/LocationSharing/LocationAuthorizationStatus.swift
|
||||||
- path: ../Riot/Modules/QRCode/QRCodeGenerator.swift
|
- path: ../Riot/Modules/QRCode/QRCodeGenerator.swift
|
||||||
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/VoiceBroadcastInfoState.swift
|
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/MatrixSDK/VoiceBroadcastInfoState.swift
|
||||||
- path: ../Riot/Assets/en.lproj/Untranslated.strings
|
- path: ../Riot/Assets/en.lproj/Untranslated.strings
|
||||||
buildPhase: resources
|
buildPhase: resources
|
||||||
- path: ../Riot/Assets/Images.xcassets
|
- path: ../Riot/Assets/Images.xcassets
|
||||||
|
|
|
@ -72,4 +72,4 @@ targets:
|
||||||
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
||||||
- path: ../Riot/Modules/Room/EventMenu/EventMenuBuilder.swift
|
- path: ../Riot/Modules/Room/EventMenu/EventMenuBuilder.swift
|
||||||
- path: ../Riot/Modules/Room/EventMenu/EventMenuItemType.swift
|
- path: ../Riot/Modules/Room/EventMenu/EventMenuItemType.swift
|
||||||
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/VoiceBroadcastSettings.swift
|
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/MatrixSDK/VoiceBroadcastSettings.swift
|
||||||
|
|
|
@ -64,4 +64,4 @@ targets:
|
||||||
excludes:
|
excludes:
|
||||||
- "**/*.md" # excludes all files with the .md extension
|
- "**/*.md" # excludes all files with the .md extension
|
||||||
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
- path: ../Riot/Modules/Room/TimelineCells/Styles/RoomTimelineStyleIdentifier.swift
|
||||||
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/VoiceBroadcastSettings.swift
|
- path: ../Riot/Modules/VoiceBroadcast/VoiceBroadcastSDK/MatrixSDK
|
||||||
|
|
1
changelog.d/pr-7160.change
Normal file
1
changelog.d/pr-7160.change
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Update the room description in the rooms list in case of live broadcast (incoming or outgoing)
|
Loading…
Reference in a new issue