mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 11:02:48 +02:00
@@ -90,4 +90,9 @@ typedef NS_ENUM(NSInteger, RoomBubbleCellDataTag)
|
||||
- (BOOL)showAllReactionsForEvent:(NSString*)eventId;
|
||||
- (void)setShowAllReactions:(BOOL)showAllReactions forEvent:(NSString*)eventId;
|
||||
|
||||
|
||||
#pragma mark - Accessibility
|
||||
|
||||
- (NSString*)accessibilityLabel;
|
||||
|
||||
@end
|
||||
|
||||
@@ -698,4 +698,58 @@ static NSAttributedString *timestampVerticalWhitespace = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityLabel
|
||||
{
|
||||
NSString *accessibilityLabel;
|
||||
|
||||
// Only media require manual handling for accessibility
|
||||
if (self.attachment)
|
||||
{
|
||||
NSString *mediaName = [self accessibilityLabelForAttachmentType:self.attachment.type];
|
||||
|
||||
MXJSONModelSetString(accessibilityLabel, self.events.firstObject.content[@"body"]);
|
||||
if (accessibilityLabel)
|
||||
{
|
||||
accessibilityLabel = [NSString stringWithFormat:@"%@ %@", mediaName, accessibilityLabel];
|
||||
}
|
||||
else
|
||||
{
|
||||
accessibilityLabel = mediaName;
|
||||
}
|
||||
}
|
||||
|
||||
return accessibilityLabel;
|
||||
}
|
||||
|
||||
- (NSString*)accessibilityLabelForAttachmentType:(MXKAttachmentType)attachmentType
|
||||
{
|
||||
NSString *accessibilityLabel;
|
||||
switch (attachmentType)
|
||||
{
|
||||
case MXKAttachmentTypeImage:
|
||||
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_image", @"Vector", nil);
|
||||
break;
|
||||
case MXKAttachmentTypeAudio:
|
||||
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_audio", @"Vector", nil);
|
||||
break;
|
||||
case MXKAttachmentTypeVideo:
|
||||
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_video", @"Vector", nil);
|
||||
break;
|
||||
case MXKAttachmentTypeLocation:
|
||||
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_location", @"Vector", nil);
|
||||
break;
|
||||
case MXKAttachmentTypeFile:
|
||||
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_file", @"Vector", nil);
|
||||
break;
|
||||
case MXKAttachmentTypeSticker:
|
||||
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_sticker", @"Vector", nil);
|
||||
break;
|
||||
default:
|
||||
accessibilityLabel = @"";
|
||||
break;
|
||||
}
|
||||
|
||||
return accessibilityLabel;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -196,6 +196,8 @@
|
||||
if ([cell isKindOfClass:MXKRoomBubbleTableViewCell.class])
|
||||
{
|
||||
MXKRoomBubbleTableViewCell *bubbleCell = (MXKRoomBubbleTableViewCell*)cell;
|
||||
[self resetAccessibilityForCell:bubbleCell];
|
||||
|
||||
RoomBubbleCellData *cellData = (RoomBubbleCellData*)bubbleCell.bubbleData;
|
||||
NSArray *bubbleComponents = cellData.bubbleComponents;
|
||||
|
||||
@@ -507,6 +509,8 @@
|
||||
|
||||
// Auto animate the sticker in case of animated gif
|
||||
bubbleCell.isAutoAnimatedGif = (cellData.attachment && cellData.attachment.type == MXKAttachmentTypeSticker);
|
||||
|
||||
[self setupAccessibilityForCell:bubbleCell withCellData:cellData];
|
||||
}
|
||||
|
||||
return cell;
|
||||
@@ -563,6 +567,35 @@
|
||||
[self sendVideo:videoLocalURL withThumbnail:videoThumbnail success:success failure:failure];
|
||||
}
|
||||
|
||||
|
||||
#pragma - Accessibility
|
||||
|
||||
- (void)setupAccessibilityForCell:(MXKRoomBubbleTableViewCell *)cell withCellData:(RoomBubbleCellData*)cellData
|
||||
{
|
||||
// Set accessibility only on media. Let VoiceOver automatically manages text messages
|
||||
if (cellData.attachment)
|
||||
{
|
||||
NSString *accessibilityLabel = [cellData accessibilityLabel];
|
||||
if (cell.messageTextView.text.length)
|
||||
{
|
||||
// Files are presented as text with link
|
||||
cell.messageTextView.accessibilityLabel = accessibilityLabel;
|
||||
cell.messageTextView.isAccessibilityElement = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
cell.attachmentView.accessibilityLabel = accessibilityLabel;
|
||||
cell.attachmentView.isAccessibilityElement = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resetAccessibilityForCell:(MXKRoomBubbleTableViewCell *)cell
|
||||
{
|
||||
cell.messageTextView.accessibilityLabel = nil;
|
||||
cell.attachmentView.accessibilityLabel = nil;
|
||||
}
|
||||
|
||||
#pragma mark - BubbleReactionsViewModelDelegate
|
||||
|
||||
- (void)bubbleReactionsViewModel:(BubbleReactionsViewModel *)viewModel didAddReaction:(MXReactionCount *)reactionCount forEventId:(NSString *)eventId
|
||||
|
||||
Reference in New Issue
Block a user