Skip to content

Commit d8931e2

Browse files
philIipfacebook-github-bot
authored andcommitted
provide public hook to programatically turn on voiceover
Summary: Changelog: [Internal] https://fb.workplace.com/groups/rn.support/posts/6677051292343429 ax team is building a tool to extract information about the views for design reviewers, and RN has some AX information that is not working atm because of dependency on whether voiceover is on or not. so, this will give them the ability to programmatically set that field and hopefully be able to get accurate ax info Reviewed By: ikenwoo Differential Revision: D31010566 fbshipit-source-id: 4c8a33fce40266b270dd5994442c8472ca88f5dd
1 parent ea53d3a commit d8931e2

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

Diff for: React/CoreModules/RCTAccessibilityManager+Internal.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#import "RCTAccessibilityManager.h"
9+
10+
#import <React/RCTDefines.h>
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
RCT_EXTERN_C_BEGIN
15+
16+
// Only to be used for testing and internal tooling. Do not use this in production.
17+
void RCTAccessibilityManagerSetIsVoiceOverEnabled(RCTAccessibilityManager *accessibiltyManager, BOOL isVoiceOverEnabled);
18+
19+
RCT_EXTERN_C_END
20+
21+
NS_ASSUME_NONNULL_END

Diff for: React/CoreModules/RCTAccessibilityManager.mm

+18-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#import "RCTAccessibilityManager.h"
9+
#import "RCTAccessibilityManager+Internal.h"
910

1011
#import <FBReactNativeSpec/FBReactNativeSpec.h>
1112
#import <React/RCTBridge.h>
@@ -183,9 +184,14 @@ - (void)reduceTransparencyStatusDidChange:(__unused NSNotification *)notificatio
183184

184185
- (void)voiceVoiceOverStatusDidChange:(__unused NSNotification *)notification
185186
{
186-
BOOL newIsVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning();
187-
if (_isVoiceOverEnabled != newIsVoiceOverEnabled) {
188-
_isVoiceOverEnabled = newIsVoiceOverEnabled;
187+
BOOL isVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning();
188+
[self _setIsVoiceOverEnabled:isVoiceOverEnabled];
189+
}
190+
191+
- (void)_setIsVoiceOverEnabled:(BOOL)isVoiceOverEnabled
192+
{
193+
if (_isVoiceOverEnabled != isVoiceOverEnabled) {
194+
_isVoiceOverEnabled = isVoiceOverEnabled;
189195
#pragma clang diagnostic push
190196
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
191197
[[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"screenReaderChanged"
@@ -350,6 +356,15 @@ static void setMultipliers(
350356
return std::make_shared<facebook::react::NativeAccessibilityManagerSpecJSI>(params);
351357
}
352358

359+
#pragma mark - Internal
360+
361+
void RCTAccessibilityManagerSetIsVoiceOverEnabled(
362+
RCTAccessibilityManager *accessibilityManager,
363+
BOOL isVoiceOverEnabled)
364+
{
365+
[accessibilityManager _setIsVoiceOverEnabled:isVoiceOverEnabled];
366+
}
367+
353368
@end
354369

355370
@implementation RCTBridge (RCTAccessibilityManager)

0 commit comments

Comments
 (0)