Sfoglia il codice sorgente

accessibility improvements (#1738)

* avoid unaccessible avatars in group chats (appearing as empty entries in VoiceOver), add custom accessibility actions to handle common message actions more easily

* Trim down accessibility/navigation items in AudioRecorderController if VoiceOver is enabled. During recording the screen reader is necessarily muted, so that VoiceOver users cannot orientate themselves auditorily and thus not navigate safely.

* revert accessibility changes that require changing the UI dynamically

* use the normal context menu for accessibility

i thought quite a while over that and played around with VoiceOver,
however, finally came to the conclusion that it is in our situtation,
with very few developmenu resources,
better to leave the accessibility options as close to the normal layout as
possible.

we should spend the resources for accessibility first of all
to provide (1) labels and help (as we do)
and (2) to tweak layouts if things really get unusable otherwise (as we do eg. for voice messages).
however, in (3) other situations, go for the defaults if things are accessible already by that [^1]

we would otherwise risk to getting worse at (1) and (2) or at overall app development
when spending too much resources at (3) (eg. this effort would need to be continued for consistency)

[^1]: the context menu is available quite simple by
  double-tab-hold, this is probably know from other apps already.
  https://www.applevis.com/forum/ios-ipados/how-do-you-perform-long-press-action-using-voice-over

* re-optimize getting sender name

Co-authored-by: B. Petersen <r10s@b44t.com>
cyBerta 2 anni fa
parent
commit
0ebef84b84

+ 2 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -887,8 +887,7 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
             action.image = UIImage(named: "ic_reply_black")
             action.backgroundColor = .systemBlue
         }
-        action.image?.accessibilityTraits = .button
-        action.image?.accessibilityLabel = String.localized("menu_reply")
+        action.accessibilityElements = nil
         let configuration = UISwipeActionsConfiguration(actions: [action])
 
         return configuration
@@ -1843,6 +1842,7 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
     }
 
     override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
+
         // handle standard actions here, but custom actions never trigger this. it still needs to be present for the menu to display, though.
         contextMenu.performAction(action: action, indexPath: indexPath)
     }

+ 3 - 2
deltachat-ios/Chat/Views/Cells/BaseMessageCell.swift

@@ -116,6 +116,7 @@ public class BaseMessageCell: UITableViewCell {
         view.setContentHuggingPriority(.defaultHigh, for: .horizontal)
         view.isHidden = true
         view.isUserInteractionEnabled = true
+        view.isAccessibilityElement = false
         return view
     }()
 
@@ -452,8 +453,8 @@ public class BaseMessageCell: UITableViewCell {
         }
 
         messageLabel.attributedText = MessageUtils.getFormattedSearchResultMessage(messageText: msg.text,
-                                                                                       searchText: searchText,
-                                                                                       highlight: highlight)
+                                                                                   searchText: searchText,
+                                                                                   highlight: highlight)
 
         messageLabel.delegate = self
         accessibilityLabel = configureAccessibilityString(message: msg)

+ 8 - 3
deltachat-ios/Controller/AudioRecorderController.swift

@@ -46,11 +46,14 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
         view.translatesAutoresizingMaskIntoConstraints = false
         view.alpha = 0.0
         view.contentMode = UIView.ContentMode.scaleAspectFit
+        view.isAccessibilityElement = true
+        view.accessibilityLabel = """
+            \(String.localized("perm_required_title"))
+            \(String.localized("perm_explain_access_to_mic_denied"))
+            """
         return view
     }()
 
-    var navigationTitle: NSString?
-
     lazy var cancelButton: UIBarButtonItem = {
         let button = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonItem.SystemItem.cancel,
                                           target: self,
@@ -115,6 +118,7 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
         self.navigationItem.title = String.localized("voice_message")
         self.navigationItem.leftBarButtonItem = cancelButton
         self.navigationItem.rightBarButtonItem = doneButton
+
         waveFormView.frame = self.view.bounds
         self.view.addSubview(waveFormView)
         self.view.addSubview(noRecordingPermissionView)
@@ -157,7 +161,7 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
         if UIAccessibility.isVoiceOverRunning {
             UIAccessibility.post(notification: .layoutChanged, argument: self.doneButton)
         }
-     }
+    }
 
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
@@ -309,4 +313,5 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
             }
         })
     }
+
 }