Make status attachments VoiceOver accessible

This commit is contained in:
Shadowfacts 2021-06-06 22:31:11 -04:00
parent fbc5d6eed9
commit f54d4d757f
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
4 changed files with 19 additions and 5 deletions

View File

@ -75,6 +75,9 @@ class AttachmentView: UIImageView, GIFAnimatable {
NotificationCenter.default.addObserver(self, selector: #selector(gifPlaybackModeChanged), name: .NSProcessInfoPowerStateDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(gifPlaybackModeChanged), name: .NSProcessInfoPowerStateDidChange, object: nil)
addInteraction(UIContextMenuInteraction(delegate: self)) addInteraction(UIContextMenuInteraction(delegate: self))
isAccessibilityElement = true
accessibilityTraits = [.image, .button]
} }
@objc private func preferencesChanged() { @objc private func preferencesChanged() {
@ -294,6 +297,13 @@ class AttachmentView: UIImageView, GIFAnimatable {
showGallery() showGallery()
} }
// MARK: - Accessibility
override func accessibilityActivate() -> Bool {
showGallery()
return true
}
} }
fileprivate extension AttachmentView { fileprivate extension AttachmentView {

View File

@ -248,9 +248,11 @@ class AttachmentsContainerView: UIView {
let attachmentView = AttachmentView(attachment: attachments[index], index: index, expectedSize: size) let attachmentView = AttachmentView(attachment: attachments[index], index: index, expectedSize: size)
attachmentView.delegate = delegate attachmentView.delegate = delegate
attachmentView.translatesAutoresizingMaskIntoConstraints = false attachmentView.translatesAutoresizingMaskIntoConstraints = false
attachmentView.isAccessibilityElement = true
attachmentView.accessibilityTraits = [.image, .button]
attachmentView.accessibilityLabel = String(format: NSLocalizedString("Attachment %d", comment: "attachment at index accessiblity label"), index + 1) attachmentView.accessibilityLabel = String(format: NSLocalizedString("Attachment %d", comment: "attachment at index accessiblity label"), index + 1)
attachmentView.accessibilityLabel = "Attachment \(index + 1)"
if let desc = attachments[index].description {
attachmentView.accessibilityLabel! += ", \(desc)"
}
attachmentViews.add(attachmentView) attachmentViews.add(attachmentView)
return attachmentView return attachmentView
} }

View File

@ -95,7 +95,6 @@ class BaseStatusTableViewCell: UITableViewCell, MenuPreviewProvider {
collapseButton.layer.cornerRadius = 5 collapseButton.layer.cornerRadius = 5
accessibilityElements = [displayNameLabel!, contentWarningLabel!, collapseButton!, contentTextView!, attachmentsView!, pollView!] accessibilityElements = [displayNameLabel!, contentWarningLabel!, collapseButton!, contentTextView!, attachmentsView!, pollView!]
attachmentsView.isAccessibilityElement = true
moreButton.showsMenuAsPrimaryAction = true moreButton.showsMenuAsPrimaryAction = true
@ -157,8 +156,6 @@ class BaseStatusTableViewCell: UITableViewCell, MenuPreviewProvider {
cardView.navigationDelegate = navigationDelegate cardView.navigationDelegate = navigationDelegate
attachmentsView.updateUI(status: status) attachmentsView.updateUI(status: status)
attachmentsView.isAccessibilityElement = status.attachments.count > 0
attachmentsView.accessibilityLabel = String(format: NSLocalizedString("%d attachments", comment: "status attachments count accessibility label"), status.attachments.count)
updateStatusState(status: status) updateStatusState(status: status)

View File

@ -220,6 +220,11 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
set {} set {}
} }
override func accessibilityActivate() -> Bool {
didSelectCell()
return true
}
} }
extension TimelineStatusTableViewCell: SelectableTableViewCell { extension TimelineStatusTableViewCell: SelectableTableViewCell {