From c59300b2e3ca22a3255ea0a82bbd1dcec69c12bf Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 17 Apr 2018 09:16:24 -0700 Subject: [PATCH] Enable 'Speak Screen' and 'Switch Control' for iOS (flutter/engine#5016) --- .../framework/Source/FlutterViewController.mm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 17e9a4eff4..2e13ffb738 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -272,10 +272,20 @@ object:nil]; [center addObserver:self - selector:@selector(onVoiceOverChanged:) + selector:@selector(onAccessibilityStatusChanged:) name:UIAccessibilityVoiceOverStatusChanged object:nil]; + [center addObserver:self + selector:@selector(onAccessibilityStatusChanged:) + name:UIAccessibilitySwitchControlStatusDidChangeNotification + object:nil]; + + [center addObserver:self + selector:@selector(onAccessibilityStatusChanged:) + name:UIAccessibilitySpeakScreenStatusDidChangeNotification + object:nil]; + [center addObserver:self selector:@selector(onMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification @@ -393,7 +403,7 @@ TRACE_EVENT0("flutter", "viewDidAppear"); [self onLocaleUpdated:nil]; [self onUserSettingsChanged:nil]; - [self onVoiceOverChanged:nil]; + [self onAccessibilityStatusChanged:nil]; [_lifecycleChannel.get() sendMessage:@"AppLifecycleState.resumed"]; [super viewDidAppear:animated]; @@ -739,14 +749,15 @@ static inline blink::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* to #pragma mark - Accessibility -- (void)onVoiceOverChanged:(NSNotification*)notification { +- (void)onAccessibilityStatusChanged:(NSNotification*)notification { #if TARGET_OS_SIMULATOR // There doesn't appear to be any way to determine whether the accessibility // inspector is enabled on the simulator. We conservatively always turn on the // accessibility bridge in the simulator. bool enabled = true; #else - bool enabled = UIAccessibilityIsVoiceOverRunning(); + bool enabled = UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning() || + UIAccessibilityIsSpeakScreenEnabled(); #endif _shell->GetPlatformView()->SetSemanticsEnabled(enabled); }