Browse Source

MediaEditCell: Make entire cell accessible

Before just the containing labels were accessible which also had the issue of the cell not being selectable
This change makes the entire cell an accessibilityElement with an expressive accessibilityLabel

(closes #543)
Carola Nitz 6 years ago
parent
commit
eec8ad0466
2 changed files with 8 additions and 0 deletions
  1. 1 0
      Sources/EditController.swift
  2. 7 0
      Sources/MediaEditCell.swift

+ 1 - 0
Sources/EditController.swift

@@ -273,6 +273,7 @@ extension EditController: UICollectionViewDataSource {
                                                          for: indexPath) as? MediaEditCell {
                                                          for: indexPath) as? MediaEditCell {
             cell.media = model.anyfiles[indexPath.row]
             cell.media = model.anyfiles[indexPath.row]
             cell.isChecked = selectedCellIndexPaths.contains(indexPath)
             cell.isChecked = selectedCellIndexPaths.contains(indexPath)
+            cell.isAccessibilityElement = true
             return cell
             return cell
         } else {
         } else {
             assertionFailure("We couldn't dequeue a reusable cell, the cell might not be registered or is not a MediaEditCell")
             assertionFailure("We couldn't dequeue a reusable cell, the cell might not be registered or is not a MediaEditCell")

+ 7 - 0
Sources/MediaEditCell.swift

@@ -64,6 +64,7 @@ class MediaEditCell: BaseCollectionViewCell {
         AudioAspectRatio.isActive = false
         AudioAspectRatio.isActive = false
         VideoAspectRatio.isActive = true
         VideoAspectRatio.isActive = true
         titleLabel.text = movie.title
         titleLabel.text = movie.title
+        accessibilityLabel = movie.accessibilityText(editing: true)
         timeLabel.text = movie.mediaDuration()
         timeLabel.text = movie.mediaDuration()
         sizeLabel.text = movie.formatSize()
         sizeLabel.text = movie.formatSize()
         thumbnailImageView.image = movie.thumbnailImage()
         thumbnailImageView.image = movie.thumbnailImage()
@@ -71,6 +72,7 @@ class MediaEditCell: BaseCollectionViewCell {
 
 
     func updateForAudio(audio: VLCMLMedia) {
     func updateForAudio(audio: VLCMLMedia) {
         titleLabel.text = audio.title
         titleLabel.text = audio.title
+        accessibilityLabel = audio.accessibilityText(editing: true)
         timeLabel.text = audio.mediaDuration()
         timeLabel.text = audio.mediaDuration()
         sizeLabel.text = audio.formatSize()
         sizeLabel.text = audio.formatSize()
         thumbnailImageView.image = audio.thumbnailImage()
         thumbnailImageView.image = audio.thumbnailImage()
@@ -80,6 +82,7 @@ class MediaEditCell: BaseCollectionViewCell {
 
 
     func updateForArtist(artist: VLCMLArtist) {
     func updateForArtist(artist: VLCMLArtist) {
         titleLabel.text = artist.artistName()
         titleLabel.text = artist.artistName()
+        accessibilityLabel = artist.accessibilityText()
         timeLabel.text = artist.numberOfTracksString()
         timeLabel.text = artist.numberOfTracksString()
         thumbnailImageView.layer.masksToBounds = true
         thumbnailImageView.layer.masksToBounds = true
         thumbnailImageView.layer.cornerRadius = thumbnailImageView.frame.size.height / 2
         thumbnailImageView.layer.cornerRadius = thumbnailImageView.frame.size.height / 2
@@ -88,6 +91,7 @@ class MediaEditCell: BaseCollectionViewCell {
 
 
     func updateForAlbum(album: VLCMLAlbum) {
     func updateForAlbum(album: VLCMLAlbum) {
         titleLabel.text = album.albumName()
         titleLabel.text = album.albumName()
+        accessibilityLabel = album.accessibilityText(editing: true)
         timeLabel.text = album.albumArtistName()
         timeLabel.text = album.albumArtistName()
         sizeLabel.text = album.numberOfTracksString()
         sizeLabel.text = album.numberOfTracksString()
         thumbnailImageView.image = album.thumbnail()
         thumbnailImageView.image = album.thumbnail()
@@ -95,6 +99,7 @@ class MediaEditCell: BaseCollectionViewCell {
 
 
     func updateForGenre(genre: VLCMLGenre) {
     func updateForGenre(genre: VLCMLGenre) {
         titleLabel.text = genre.name
         titleLabel.text = genre.name
+        accessibilityLabel = genre.accessibilityText()
         timeLabel.text = genre.numberOfTracksString()
         timeLabel.text = genre.numberOfTracksString()
         thumbnailImageView.layer.masksToBounds = true
         thumbnailImageView.layer.masksToBounds = true
         thumbnailImageView.layer.cornerRadius = thumbnailImageView.frame.size.height / 2
         thumbnailImageView.layer.cornerRadius = thumbnailImageView.frame.size.height / 2
@@ -106,6 +111,7 @@ class MediaEditCell: BaseCollectionViewCell {
         AudioAspectRatio.isActive = false
         AudioAspectRatio.isActive = false
         VideoAspectRatio.isActive = true
         VideoAspectRatio.isActive = true
         titleLabel.text = playlist.name
         titleLabel.text = playlist.name
+        accessibilityLabel = playlist.accessibilityText()
         timeLabel.text = playlist.numberOfTracksString()
         timeLabel.text = playlist.numberOfTracksString()
         thumbnailImageView.image = playlist.thumbnail()
         thumbnailImageView.image = playlist.thumbnail()
     }
     }
@@ -142,6 +148,7 @@ class MediaEditCell: BaseCollectionViewCell {
         titleLabel.text = ""
         titleLabel.text = ""
         timeLabel.text = ""
         timeLabel.text = ""
         sizeLabel.text = ""
         sizeLabel.text = ""
+        accessibilityLabel = ""
         thumbnailImageView.image = nil
         thumbnailImageView.image = nil
         isChecked = false
         isChecked = false
         thumbnailImageView.layer.cornerRadius = 0
         thumbnailImageView.layer.cornerRadius = 0