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

improve accessibility of voice message recording #493

cyberta пре 5 година
родитељ
комит
372e30efb5

+ 18 - 5
deltachat-ios/Controller/AudioRecorderController.swift

@@ -87,6 +87,8 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
                                            target: self,
                                            action: #selector(recordingButtonAction))
         button.tintColor = UIColor.themeColor(light: .darkGray, dark: .lightGray)
+        button.accessibilityLabel = String.localized("start_recording")
+        button.accessibilityHint = String.localized("recording_hint")
         return button
     }()
 
@@ -150,6 +152,11 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
         validateMicrophoneAccess()
     }
 
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+        UIAccessibility.post(notification: .layoutChanged, argument: self.startRecordingButton)
+    }
+
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
 
@@ -189,7 +196,13 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
 
     @objc func recordingButtonAction() {
         logger.debug("start recording")
-        self.setToolbarItems([flexItem, cancelRecordingButton, flexItem, pauseButton, flexItem], animated: true)
+        if !UIAccessibility.isVoiceOverRunning {
+            self.setToolbarItems([flexItem, cancelRecordingButton, flexItem, pauseButton, flexItem], animated: true)
+        } else {
+            self.setToolbarItems([], animated: true)
+        }
+
+        UIAccessibility.post(notification: .screenChanged, argument: self.doneButton)
         cancelRecordingButton.isEnabled = true
         doneButton.isEnabled = true
         if FileManager.default.fileExists(atPath: recordingFilePath) {
@@ -276,13 +289,13 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
                 if let self = self {
                     self.noRecordingPermissionView.alpha = granted ? 0.0 : 1.0
                     self.waveFormView.alpha = granted ? 1.0 : 0.0
-                    self.doneButton.isEnabled = granted
+                    self.doneButton.isEnabled = granted && !UIAccessibility.isVoiceOverRunning
 
                     if self.isFirstUsage {
-                        if !granted {
+                        if !granted || UIAccessibility.isVoiceOverRunning {
                             self.setToolbarItems([self.flexItem, self.startRecordingButton, self.flexItem], animated: true)
-                            self.startRecordingButton.isEnabled = false
-                        } else {
+                            self.startRecordingButton.isEnabled = granted
+                        } else { 
                             self.pauseButton.isEnabled = granted
                             self.recordingButtonAction()
                         }

+ 2 - 0
deltachat-ios/en.lproj/Localizable.strings

@@ -649,3 +649,5 @@
 "import_contacts" = "Import device contacts";
 "import_contacts_message" = "To chat with contacts from your device open Settings and enable Contacts.";
 "stop_sharing_location" = "Stop sharing location";
+"start_recording" = "Start recording";
+"recording_hint" = "After recording started double tap again to send the message.";

+ 2 - 0
tools/untranslated.xml

@@ -5,4 +5,6 @@
     <string name="import_contacts">Import device contacts</string>
     <string name="import_contacts_message">To chat with contacts from your device open Settings and enable Contacts.</string>
     <string name="stop_sharing_location">Stop sharing location</string>
+    <string name="start_recording">Start recording</string>
+    <string name="recording_hint">After recording started double tap again to send the message.</string>
 </resources>