Minor refactoring
This commit is contained in:
parent
8f002f9422
commit
e48db9495d
@ -24,9 +24,9 @@ public class AccessibilityOperation: MVMCoreOperation {
|
||||
|
||||
/**
|
||||
This method will post accessibility notification.
|
||||
If we have announcement notification then operation will wait untill announcement is finished.
|
||||
*/
|
||||
public override func main() {
|
||||
guard !checkAndHandleForCancellation() else { return }
|
||||
guard UIAccessibility.isVoiceOverRunning else {
|
||||
markAsFinished()
|
||||
return
|
||||
@ -37,13 +37,7 @@ public class AccessibilityOperation: MVMCoreOperation {
|
||||
return
|
||||
}
|
||||
UIAccessibility.post(notification: self.notificationType, argument: self.argument)
|
||||
if self.notificationType == .announcement {///Marking task as finished only if announcement did finished so that user will listen complete announcement.
|
||||
NotificationCenter.default.addObserver(forName: UIAccessibility.announcementDidFinishNotification, object: nil, queue: .main) { _ in
|
||||
self.markAsFinished()
|
||||
}
|
||||
} else {
|
||||
self.markAsFinished()
|
||||
}
|
||||
self.markAsFinished()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,16 +125,12 @@ extension AccessibilityHandler {
|
||||
|
||||
/**
|
||||
This method is used to notify rotor handler about page loaded and capturing the accessibilityId if any.
|
||||
Will announce text if the page is has announcementText in the response.
|
||||
*/
|
||||
public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {
|
||||
previousAccessiblityElement = nil
|
||||
rotorHandler.onPageNew(rootMolecules: rootMolecules, delegateObject)
|
||||
guard let loadObject = (delegateObject?.loadDelegate as? MVMCoreViewControllerProtocol)?.loadObject else { return }
|
||||
accessibilityId = loadObject?.pageJSON?.optionalStringForKey("accessibilityId")
|
||||
if let announcementText = loadObject?.pageJSON?.optionalStringForKey("announcementText") {
|
||||
post(notification: .announcement, argument: announcementText)
|
||||
}
|
||||
self.delegateObject = delegateObject
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user