@@ -62,7 +62,7 @@ class PDFReaderViewController: UIViewController, ReaderViewController {
6262 }
6363 }
6464 private var previousTraitCollection : UITraitCollection ?
65- private var accessibilityHandler : AccessibilityViewHandler < PDFReaderViewController > !
65+ private var accessibilityHandler : AccessibilityViewHandler < PDFReaderViewController > ?
6666 var isSidebarVisible : Bool { return sidebarControllerLeft? . constant == 0 }
6767 var isToolbarVisible : Bool { return toolbarState. visible }
6868 var isDocumentLocked : Bool { return viewModel. state. document. isLocked }
@@ -208,15 +208,17 @@ class PDFReaderViewController: UIViewController, ReaderViewController {
208208 viewModel. process ( action: . changeIdleTimerDisabled( true ) )
209209 view. backgroundColor = . systemGray6
210210 setupViews ( )
211- accessibilityHandler = AccessibilityViewHandler (
212- key: viewModel. state. key,
213- libraryId: viewModel. state. library. identifier,
214- viewController: self ,
215- documentContainer: documentController!. view,
216- delegate: self ,
217- dbStorage: viewModel. handler. dbStorage
218- )
219- accessibilityHandler. delegate = self
211+ if FeatureGates . enabled. contains ( . speech) {
212+ accessibilityHandler = AccessibilityViewHandler (
213+ key: viewModel. state. key,
214+ libraryId: viewModel. state. library. identifier,
215+ viewController: self ,
216+ documentContainer: documentController!. view,
217+ delegate: self ,
218+ dbStorage: viewModel. handler. dbStorage
219+ )
220+ accessibilityHandler? . delegate = self
221+ }
220222 setupObserving ( )
221223
222224 if !viewModel. state. document. isLocked, let documentController {
@@ -332,8 +334,21 @@ class PDFReaderViewController: UIViewController, ReaderViewController {
332334 closeButton. accessibilityLabel = L10n . close
333335 closeButton. rx. tap. subscribe ( onNext: { [ weak self] _ in self ? . close ( ) } ) . disposed ( by: disposeBag)
334336
335- let accessibilityButton = accessibilityHandler. createAccessibilityButton ( isSelected: false , isFilled: false , isEnabled: !viewModel. state. document. isLocked)
336-
337+ let accessibilityButton : UIBarButtonItem
338+ if FeatureGates . enabled. contains ( . speech) , let accessibilityHandler {
339+ accessibilityButton = accessibilityHandler. createAccessibilityButton ( isSelected: false , isFilled: false , isEnabled: !viewModel. state. document. isLocked)
340+ } else {
341+ accessibilityButton = UIBarButtonItem ( image: Asset . Images. pdfRawReader. image, style: . plain, target: nil , action: nil )
342+ accessibilityButton. isEnabled = !viewModel. state. document. isLocked
343+ accessibilityButton. accessibilityLabel = L10n . Accessibility. showReader
344+ accessibilityButton. title = L10n . Accessibility. showReader
345+ accessibilityButton. rx. tap
346+ . subscribe ( onNext: { [ weak self] _ in
347+ guard let self else { return }
348+ coordinatorDelegate? . showReader ( document: viewModel. state. document, userInterfaceStyle: viewModel. state. settings. appearanceMode. userInterfaceStyle)
349+ } )
350+ . disposed ( by: disposeBag)
351+ }
337352 navigationItem. leftBarButtonItems = [ closeButton, sidebarButton, accessibilityButton]
338353 navigationItem. rightBarButtonItems = createRightBarButtonItems ( )
339354 }
@@ -404,7 +419,7 @@ class PDFReaderViewController: UIViewController, ReaderViewController {
404419 override func traitCollectionDidChange( _ previousTraitCollection: UITraitCollection ? ) {
405420 super. traitCollectionDidChange ( previousTraitCollection)
406421 updateUserInterfaceStyleIfNeeded ( previousTraitCollection: previousTraitCollection)
407- accessibilityHandler. accessibilityControlsShouldChange ( isNavbarHidden: isNavigationBarHidden)
422+ accessibilityHandler? . accessibilityControlsShouldChange ( isNavbarHidden: isNavigationBarHidden)
408423 }
409424
410425 override func viewWillTransition( to size: CGSize , with coordinator: UIViewControllerTransitionCoordinator ) {
@@ -749,9 +764,9 @@ extension PDFReaderViewController: AnnotationToolbarHandlerDelegate {
749764
750765 func annotationToolbarWillChange( state: AnnotationToolbarHandler . State , statusBarVisible: Bool ) {
751766 if state. visible && state. position == . pinned {
752- accessibilityHandler. accessibilityControlsShouldChange ( isNavbarHidden: true )
767+ accessibilityHandler? . accessibilityControlsShouldChange ( isNavbarHidden: true )
753768 } else {
754- accessibilityHandler. accessibilityControlsShouldChange ( isNavbarHidden: !statusBarVisible)
769+ accessibilityHandler? . accessibilityControlsShouldChange ( isNavbarHidden: !statusBarVisible)
755770 }
756771 }
757772
@@ -912,7 +927,7 @@ extension PDFReaderViewController: PDFDocumentDelegate {
912927 intraDocumentNavigationHandler? . interfaceIsVisible = !isHidden
913928 annotationToolbarHandler? . interfaceVisibilityDidChange ( )
914929 if shouldChangeNavigationBarVisibility {
915- accessibilityHandler. accessibilityControlsShouldChange ( isNavbarHidden: isHidden)
930+ accessibilityHandler? . accessibilityControlsShouldChange ( isNavbarHidden: isHidden)
916931 }
917932
918933 UIView . animate ( withDuration: 0.15 , animations: { [ weak self] in
0 commit comments