Преглед изворни кода

read out audio / voice messages as such, improve voice over navigation

cyberta пре 4 година
родитељ
комит
d6402e1e9d

+ 5 - 0
deltachat-ios/Chat/Views/AudioPlayerView.swift

@@ -7,7 +7,9 @@ open class AudioPlayerView: UIView {
     lazy var playButton: UIButton = {
         let playButton = UIButton(type: .custom)
         let playImage = UIImage(named: "play")
+        playImage?.isAccessibilityElement = false
         let pauseImage = UIImage(named: "pause")
+        pauseImage?.isAccessibilityElement = false
         playButton.setImage(playImage?.withRenderingMode(.alwaysTemplate), for: .normal)
         playButton.setImage(pauseImage?.withRenderingMode(.alwaysTemplate), for: .selected)
         playButton.imageView?.contentMode = .scaleAspectFit
@@ -15,6 +17,7 @@ open class AudioPlayerView: UIView {
         playButton.contentHorizontalAlignment = .fill
         playButton.translatesAutoresizingMaskIntoConstraints = false
         playButton.isUserInteractionEnabled = true
+        playButton.accessibilityLabel = String.localized("menu_play")
         return playButton
     }()
 
@@ -80,6 +83,7 @@ open class AudioPlayerView: UIView {
         progressView.progress = 0
         playButton.isSelected = false
         durationLabel.text = "0:00"
+        playButton.accessibilityLabel = String.localized("menu_play")
     }
 
     open func setProgress(_ progress: Float) {
@@ -106,5 +110,6 @@ open class AudioPlayerView: UIView {
 
     open func showPlayLayout(_ play: Bool) {
         playButton.isSelected = play
+        playButton.accessibilityLabel = play ? String.localized("menu_pause") : String.localized("menu_play")
     }
 }

+ 6 - 0
deltachat-ios/Chat/Views/Cells/AudioMessageCell.swift

@@ -31,6 +31,7 @@ public class AudioMessageCell: BaseMessageCell {
         let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(onPlayButtonTapped))
         gestureRecognizer.numberOfTapsRequired = 1
         audioPlayerView.playButton.addGestureRecognizer(gestureRecognizer)
+        contentView.isAccessibilityElement = true
     }
 
     @objc public func onPlayButtonTapped() {
@@ -46,6 +47,11 @@ public class AudioMessageCell: BaseMessageCell {
         } else {
             mainContentView.spacing = 0
         }
+        if msg.type == DC_MSG_VOICE {
+            contentView.accessibilityLabel = String.localized("voice_message")
+        } else {
+            contentView.accessibilityLabel = String.localized("audio")
+        }
 
         super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible, isGroup: isGroup)
     }