From d508df8bb1a1b77f0df8d4c0db4668e57080673b Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Mon, 8 Feb 2021 21:53:52 -0800 Subject: [PATCH] VoiceOver improvements --- Extensions/Attachment+Extensions.swift | 4 -- Localizations/Localizable.strings | 4 -- Localizations/Localizable.stringsdict | 64 ++++++++++++++++++++++ Views/UIKit/AttachmentsView.swift | 13 ++++- Views/UIKit/Content Views/StatusView.swift | 2 +- 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/Extensions/Attachment+Extensions.swift b/Extensions/Attachment+Extensions.swift index e2b5df2..4164bc1 100644 --- a/Extensions/Attachment+Extensions.swift +++ b/Extensions/Attachment+Extensions.swift @@ -18,10 +18,6 @@ extension Attachment.AttachmentType { } func accessibilityNames(count: Int) -> String { - if count == 1 { - return accessibilityName - } - let format: String switch self { diff --git a/Localizations/Localizable.strings b/Localizations/Localizable.strings index 1857692..034fdb7 100644 --- a/Localizations/Localizable.strings +++ b/Localizations/Localizable.strings @@ -58,13 +58,9 @@ "attachment.sensitive-content" = "Sensitive content"; "attachment.media-hidden" = "Media hidden"; "attachment.type.image" = "Image"; -"attachment.type.images-%ld" = "%ld images"; "attachment.type.audio" = "Audio file"; -"attachment.type.audios-%ld" = "%ld audio files"; "attachment.type.video" = "Video"; -"attachment.type.videos-%ld" = "%ld videos"; "attachment.type.unknown" = "Attachment"; -"attachment.type.unknown-%ld" = "%ld attachments"; "attachment.unable-to-export-media" = "Unable to export media"; "bookmarks" = "Bookmarks"; "card.link.accessibility-label" = "Link"; diff --git a/Localizations/Localizable.stringsdict b/Localizations/Localizable.stringsdict index 6c25399..02775f5 100644 --- a/Localizations/Localizable.stringsdict +++ b/Localizations/Localizable.stringsdict @@ -98,5 +98,69 @@ %ld Followers + attachment.type.images-%ld + + NSStringLocalizedFormatKey + %#@images@ + images + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + one + %ld image + other + %ld images + + + attachment.type.audios-%ld + + NSStringLocalizedFormatKey + %#@audios@ + audios + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + one + %ld audio file + other + %ld audio files + + + attachment.type.videos-%ld + + NSStringLocalizedFormatKey + %#@videos@ + videos + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + one + %ld video file + other + %ld video files + + + attachment.type.unknowns-%ld + + NSStringLocalizedFormatKey + %#@unknowns@ + unknowns + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + one + %ld attachment + other + %ld attachments + + diff --git a/Views/UIKit/AttachmentsView.swift b/Views/UIKit/AttachmentsView.swift index ca98a16..3443883 100644 --- a/Views/UIKit/AttachmentsView.swift +++ b/Views/UIKit/AttachmentsView.swift @@ -82,7 +82,18 @@ final class AttachmentsView: UIView { type = .unknown } - accessibilityLabel = type.accessibilityNames(count: viewModel.attachmentViewModels.count) + var accessibilityLabel = type.accessibilityNames(count: viewModel.attachmentViewModels.count) + + for attachmentViewModel in viewModel.attachmentViewModels { + guard let description = attachmentViewModel.attachment.description, + !description.isEmpty + else { continue } + + accessibilityLabel.appendWithSeparator(attachmentViewModel.attachment.type.accessibilityName) + accessibilityLabel.appendWithSeparator(description) + } + + self.accessibilityLabel = accessibilityLabel } else { accessibilityLabel = curtainButton.title(for: .normal) } diff --git a/Views/UIKit/Content Views/StatusView.swift b/Views/UIKit/Content Views/StatusView.swift index 5862bff..d854543 100644 --- a/Views/UIKit/Content Views/StatusView.swift +++ b/Views/UIKit/Content Views/StatusView.swift @@ -487,7 +487,7 @@ private extension StatusView { displayNameLabel.attributedText = mutableDisplayName accountLabel.text = viewModel.accountName - let nameButtonAccessibilityAttributedLabel = mutableDisplayName + let nameButtonAccessibilityAttributedLabel = NSMutableAttributedString(attributedString: mutableDisplayName) nameButtonAccessibilityAttributedLabel.appendWithSeparator(viewModel.accountName) nameButton.accessibilityAttributedLabel = nameButtonAccessibilityAttributedLabel